@Anonymous,
Hoping that below VBA code help to created aligned(Isometric) dimension for assembly document.
Public Sub DimBtwnWorkpoints()
'Creates a dimension between two work points
'Active document is inventor drawing
'Active sheet has view(s)
'First view is of assembly
'First component occurrence of assembly is part
'Part has two work points
'Dimension will be created between these two work points
Dim oDrawingDocument As Inventor.DrawingDocument
Set oDrawingDocument = ThisApplication.ActiveDocument
Dim oSheet As Inventor.Sheet
Set oSheet = oDrawingDocument.ActiveSheet
Dim oView As Inventor.DrawingView
Set oView = oSheet.DrawingViews.Item(1)
Dim oAssemblyDoc As Inventor.AssemblyDocument
Set oAssemblyDoc = oView.ReferencedDocumentDescriptor.ReferencedDocument
'Get the first component occurrence of the assembly
Dim oComponentOcc As Inventor.ComponentOccurrence
Set oComponentOcc = oAssemblyDoc.ComponentDefinition.Occurrences.Item(1)
Dim oPartDocument As Inventor.PartDocument
Set oPartDocument = oComponentOcc.Definition.Document
'Get the first two work points (WorkPoints.Item(1) is the origin)
Dim oWorkPoint1 As Inventor.WorkPoint
Dim oWP2 As Inventor.WorkPoint
Set oWorkPoint1 = oPartDocument.ComponentDefinition.WorkPoints.Item(2)
Set oWP2 = oPartDocument.ComponentDefinition.WorkPoints.Item(3)
'Create a proxy for the two work points
Dim oWorkPointProx1 As Inventor.WorkPointProxy
Dim oWorkPointProx2 As Inventor.WorkPointProxy
oComponentOcc.CreateGeometryProxy oWorkPoint1, oWorkPointProx1
oComponentOcc.CreateGeometryProxy oWP2, oWorkPointProx2
'Include the work points in the drawing view
oView.SetIncludeStatus oWorkPointProx1, True
oView.SetIncludeStatus oWorkPointProx2, True
'Now we need to find the two centermarks that represent the work point proxies
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 oWorkPointProx1 Then
Set oCenterMark1 = oCenterMark
ElseIf oCenterMark.AttachedEntity Is oWorkPointProx2 Then
Set oCenterMark2 = oCenterMark
End If
End If
Next
'From the two work points, we create the geometry intent
Dim oGeomIntent1 As Inventor.GeometryIntent
Dim oGeomIntent2 As Inventor.GeometryIntent
Set oGeomIntent1 = oSheet.CreateGeometryIntent(oCenterMark1, Inventor.kPoint2dIntent)
Set oGeomIntent2 = oSheet.CreateGeometryIntent(oCenterMark2, Inventor.kPoint2dIntent)
'Create a point for the text
Dim oTextPoint As Inventor.Point2d
Set oTextPoint = ThisApplication.TransientGeometry.CreatePoint2d()
oTextPoint.X = (oGeomIntent1.PointOnSheet.X + oGeomIntent2.PointOnSheet.X) / 2
oTextPoint.Y = (oGeomIntent1.PointOnSheet.Y) + 1
'Create the dimension
Call oSheet.DrawingDimensions.GeneralDimensions.AddLinear(oTextPoint, oGeomIntent1, oGeomIntent2, kAlignedDimensionType)
'For extra credit, hide the work points
oCenterMark1.Visible = False
oCenterMark2.Visible = False
End Sub
Thanks and regards,
CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network