create an isometric dimension from two work points automatically.

create an isometric dimension from two work points automatically.

Anonymous
Not applicable
589 Views
3 Replies
Message 1 of 4

create an isometric dimension from two work points automatically.

Anonymous
Not applicable

Hi,

 

Have been working on a project to automatically create various drawing sheets with different views (front, rear, side, isometric etc), and populating them with dimensions. Now i have found plenty of code to do this except one thing.........

 

How do you generate an isometric dimension using work points automatically? is it possible i'm not so sure, do i need to attack the isometric views in a different manner?

 

I did try using a sketch with "driven" dimensions but it seems that you cant automatically "retrieve" driven dimensions hence the change to work points. 

 

any help with this would be much appreciated.

 

cheers

 

Chris

0 Likes
Accepted solutions (1)
590 Views
3 Replies
Replies (3)
Message 2 of 4

chandra.shekar.g
Autodesk Support
Autodesk Support
Accepted solution

@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



Message 3 of 4

Anonymous
Not applicable

@chandra.shekar.g 

 

Is this approach still possible with assembly-based workpoints? Do you still need need WorkPointProxies?

 

Thanks,

Tom

0 Likes
Message 4 of 4

chandra.shekar.g
Autodesk Support
Autodesk Support

@Anonymous,

 

Yes, WorkPointProxies are always required.

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes