Hi, thanks for the reply. I’m quite new to this, but here’s what I try to achieve:
- Configure a model with iParts/iAssemblies using an iLogic form (this part is OK)
- Generate an .idw drawing of the selected iAssembly row, which creates views and adds some dimensions
The “generate drawing” function works, when running from the assembly file. And the “add dimensions” works when running the rule from the drawing. But, I’m having trouble melting these togheter. I get an error saying error “ThisDrawing: This document "iassemblylogic2" is not a drawing.” Could someone help me in the right direction?
I have also have a couple of question about further possibilities:
- Is it possible to add balloons using iLogic?
- I use “Dim oModelName As String = "location\filename.iam". But isn’t it possible to just use the current assembly without specifying filename, so this can be a general rule?
Dim oModel As Document
Dim oSheet As Sheet
Dim oModelName As String = "location\file.iam"
oModel= ThisApplication.Documents.Open(oModelName, False)
'Determine the drawing template
Dim IDWTemplate As String = "location\template.idw"
'Create a drawing
oDrawingDoc = ThisApplication.documents.Add(DocumentTypeEnum.kDrawingDocumentObject, IDWtemplate, True)
oDrawingDoc.Activate()
oSheet = oDrawingDoc.Sheets.Item(1)
'Create base view
Dim oPoint1 As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(25,40)
oBaseView = oSheet.DrawingViews.AddBaseView(oModel, oPoint1, 0.2, ViewOrientationTypeEnum.kLeftViewOrientation, DrawingViewStyleEnum.kHiddenLineDrawingViewStyle)
Dim oPoint2 As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(60,40)
Dim otopview As DrawingView
otopview = oSheet.DrawingViews.AddProjectedView(oBaseView, oPoint2, DrawingViewStyleEnum.kFromBaseDrawingViewStyle)
'Adding dimensions
Dim oView As DrawingView = ActiveSheet.View("VIEW1").View
Dim oDoc As Document = oView.ReferencedDocumentDescriptor.ReferencedDocument
Dim oGeomIntent1 As Inventor.GeometryIntent
Dim oGeomIntent2 As Inventor.GeometryIntent
Dim oWP1 As Inventor.WorkPoint = oDoc.ComponentDefinition.WorkPoints.Item("WP1")
Dim oWP2 As Inventor.WorkPoint = oDoc.ComponentDefinition.WorkPoints.Item("WP2")
oView.SetIncludeStatus(oWP1, True)
oView.SetIncludeStatus(oWP2, True)
Dim oCenterMark1 As Inventor.Centermark
Dim oCenterMark2 As Inventor.Centermark
Dim oCenterMark As Inventor.Centermark
For Each oCenterMark In oSheet.Centermarks
If oCenterMark.Attached Then
If oCenterMark.AttachedEntity Is oWP1 Then
oCenterMark1 = oCenterMark
End If
If oCenterMark.AttachedEntity Is oWP2 Then
oCenterMark2 = oCenterMark
End If
End If
Next
oGeomIntent1 = oSheet.CreateGeometryIntent(oCenterMark1, kPoint2dIntent)
oGeomIntent2 = oSheet.CreateGeometryIntent(oCenterMark2, kPoint2dIntent)
oCenterMark1.Visible = False
oCenterMark2.Visible = False
Dim textPoint As Inventor.Point2d = ThisServer.TransientGeometry.CreatePoint2d(40,40)
Dim oDim as GeneralDimension = oSheet.DrawingDimensions.GeneralDimensions.AddLinear(textPoint, oGeomIntent1, oGeomIntent2, DimensionTypeEnum.kVerticalDimensionType)