Добрый день. Решил адаптировать правило ilogic для addin.
Вот само правило ilogic для создания чертежа
Imports Inventor.ViewOrientationTypeEnum
Imports Inventor.DrawingViewStyleEnum
doc = ThisDoc.ModelDocument
If (doc.SubType <> "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}") Then
MessageBox.Show("Это не файл сортамента", "iLogic")
Return
End If
Dim oDrawingDoc as DrawingDocument
Dim oPartDoc as Document
Dim oSheet As sheet
Dim oView1 as DrawingView
Dim oView2 as DrawingView
Dim oView3 as DrawingView
ViewScale = 1/2
'Ask to create drawing?
dwgQuery=MsgBox("Создать чертеж сортамента?", vbYesNo,"Выбирите действие")
If dwgQuery = vbYes Then
oPartDoc = ThisDoc.Document
'Define DWG Template File Location
oDrawingDoc = ThisApplication.Documents.Add(kDrawingDocumentObject, "d:\Программы\Autodesk_Inventor_2013\Templates\Шаблоны-Никитин\Сортамент.dwg", True)
'oDrawingDoc = ThisApplication.Documents.Add(kDrawingDocumentObject, "", True)
oSheet = oDrawingDoc.Sheets.Item(1)
' Create a new NameValueMap object
Dim oBaseViewOptions As NameValueMap
oBaseViewOptions = ThisApplication.TransientObjects.CreateNameValueMap
'True = folded view
'False = flat pattern view
oBaseViewOptions.Add("SheetMetalFoldedModel", False)
'Define 2d view bottom left corner points for four views
oPoint1 = ThisApplication.TransientGeometry.CreatePoint2d(10, 20) ' front view
oPoint2 = ThisApplication.TransientGeometry.CreatePoint2d(20, 20) ' right view
oPoint3 = ThisApplication.TransientGeometry.CreatePoint2d(10, 15)' top view
oBaseView = oSheet.DrawingViews.AddBaseView(oPartDoc,oPoint1, ViewScale,kFrontViewOrientation, kHiddenLineRemovedDrawingViewStyle, "Главный")
oView2 = oSheet.DrawingViews.AddProjectedView(oBaseView,oPoint2, kFromBaseDrawingViewStyle, ViewScale)
oView3 = oSheet.DrawingViews.AddProjectedView(oBaseView,oPoint3, kFromBaseDrawingViewStyle, ViewScale)
End If
На пользовательском элементе создана кнопка. На кнопку помещаю код:
Dim doc As Document = m_inventorApplication.ActiveDocument
If (doc.SubType <> "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}") Then
MsgBox("Это не файл сортамента", , "myAddIn")
Return
End If
Dim oDrawingDoc As DrawingDocument
Dim oSheet As Sheet
Dim oView1 As DrawingView
Dim oView2 As DrawingView
Dim oView3 As DrawingView
Dim ViewScale As Double = 1 / 2
'Ask to create drawing?
Dim dwgQuery As Integer = MsgBox("Создать чертеж сортамента?", vbYesNo, "Выберите действие")
If dwgQuery = vbYes Then
'Define DWG Template File Location
oDrawingDoc = m_inventorApplication.Documents.Add(DocumentTypeEnum.kDrawingDocumentObject, "d:\Программы\Autodesk_Inventor_2013\Templates\Шаблоны-Никитин\Сортамент.dwg", True)
'oDrawingDoc = ThisApplication.Documents.Add(kDrawingDocumentObject, "", True)
oSheet = oDrawingDoc.Sheets.Item(1)
' Create a new NameValueMap object
Dim oBaseViewOptions As NameValueMap
oBaseViewOptions = m_inventorApplication.TransientObjects.CreateNameValueMap
'True = folded view
'False = flat pattern view
oBaseViewOptions.Add("SheetMetalFoldedModel", False)
'Define 2d view bottom left corner points for four views
Dim oPoint1 As Point = m_inventorApplication.TransientGeometry.CreatePoint2d(10, 20) ' front view
Dim oPoint2 As Point = m_inventorApplication.TransientGeometry.CreatePoint2d(20, 20) ' right view
Dim oPoint3 As Point = m_inventorApplication.TransientGeometry.CreatePoint2d(10, 15) ' top view
oView1 = oSheet.DrawingViews.AddBaseView(doc, oPoint1, ViewScale, ViewOrientationTypeEnum.kFrontViewOrientation, _
DrawingViewStyleEnum.kHiddenLineRemovedDrawingViewStyle, "Главный")
oView2 = oSheet.DrawingViews.AddProjectedView(oView1, oPoint2, DrawingViewStyleEnum.kFromBaseDrawingViewStyle, ViewScale)
oView3 = oSheet.DrawingViews.AddProjectedView(oView1, oPoint3, DrawingViewStyleEnum.kFromBaseDrawingViewStyle, ViewScale)
End If
После нажатия на кнопку инвентор зависает. Чего не хватает в коде для работы кнопки? Спасибо.