<?xml encoding=”UTF-8″>By Adam Nagy
Each type of dimension might provide information in a different way. So the easiest way to get familiar with what’s available is if you select the entity in the UI and investigate it in VBA: Discover object model
Here is a VBA sample that will highlight all the points available in case of a TwoLineAngleDimConstraint by creating temporary SketchPoints.
Sub DeletePoints(c As ObjectCollection)
Dim o As Object
For Each o In c
o.Delete
Next
Call c.Clear
End Sub
Sub GetDimensionGeometry()
' The Sketch needs to be active and a
' two line angle dimension constraint needs
' to be selected in the UI
Dim d As TwoLineAngleDimConstraint
Set d = ThisApplication.ActiveDocument.SelectSet(1)
Dim sps As SketchPoints
Set sps = d.Parent.SketchPoints
Dim sp As SketchPoint
Dim c As ObjectCollection
Set c = ThisApplication.TransientObjects.CreateObjectCollection()
' Anchor points (<strong><span>A1..A5</span></strong>)
Dim pt As Point2d
For Each pt In d.AnchorPoints
Call c.Add(sps.Add(pt))
Next
MsgBox ("AnchorPoints")
Call DeletePoints(c)
' LineOne (<strong><span>L1S, L1E</span></strong>)
Call c.Add(sps.Add(d.LineOne.StartSketchPoint.Geometry))
Call c.Add(sps.Add(d.LineOne.EndSketchPoint.Geometry))
MsgBox ("LineOne")
Call DeletePoints(c)
' LineTwo (<strong><span>L2S, L2E</span></strong>)
Call c.Add(sps.Add(d.LineTwo.StartSketchPoint.Geometry))
Call c.Add(sps.Add(d.LineTwo.EndSketchPoint.Geometry))
MsgBox ("LineTwo")
Call DeletePoints(c)
' DimensionCenterPoint (<strong><span>DC</span></strong>)
Call c.Add(sps.Add(d.DimensionCenterPoint))
MsgBox ("DimensionCenterPoint")
Call DeletePoints(c)
' TextPoint (<span><strong>TP</strong></span>)
Call c.Add(sps.Add(d.TextPoint))
MsgBox ("TextPoint")
Call DeletePoints(c)
End Sub
These are all the points showing:
Once you got these points you could also measure the distance between them or do other calculations using the Inventor API.


Leave a Reply