Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
BrandonBG
in reply to: Anonymous

To update my earlier post, here's the iLogic code that I got to work. It's clunky, and relies on the leader not being visible as it's coincident with visible geometry.

 

Please note this code applies to a drawing view only -- not a 3D annotation.

 

Try adding () to the end of:

Dim oText As String = oLeader.Definition.Text.FormattedText()

 

Here's the code for 2D drawings:

 

 

Sub Main()

Dim oDrawing as DrawingDocument
oDrawing = ThisDrawing.Document

Dim oSheet As Sheet
oSheet = oDrawing.ActiveSheet

Dim oNotes As DrawingNotes
oNotes = oSheet.DrawingNotes

Dim oEdgeSegment As DrawingCurveSegment
oEdgeSegment = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingCurveSegmentFilter, "Select cabinet edge to attach dimension." & Chr(13) & " ESC to end.")

Dim oEdge As DrawingCurve 
oEdge = oEdgeSegment.Parent

Dim oMinPoint As Point2d oMinPoint = oEdge.Evaluator2D.RangeBox.MinPoint Dim oMaxPoint As Point2d oMaxPoint = oEdge.Evaluator2D.RangeBox.MaxPoint Dim oTG As TransientGeometry oTG = ThisApplication.TransientGeometry Dim oLeaderPoints As ObjectCollection oLeaderPoints = ThisApplication.TransientObjects.CreateObjectCollection If oMinPoint.X <> oMaxPoint.X Then oLeaderPoints.Add(oTG.CreatePoint2d(oMinPoint.X+.75, oMinPoint.Y+.125)) 'horizontal edge Else oLeaderPoints.Add(oTG.CreatePoint2d(oMinPoint.X+.125, oMinPoint.Y+.125)) 'vertical edge End if Dim oGeometryIntent As GeometryIntent oGeometryIntent = oSheet.CreateGeometryIntent(oEdge) oLeaderPoints.Add(oGeometryIntent) Dim sParameterName As String sParameterName = "CABDEPTH" Dim oPartParameters As Parameters oPartParameters = oEdge.ModelGeometry.ContainingOccurrence.Definition.Parameters For i = 1 to oPartParameters.Count() If oPartParameters.Item(i).Name() = sParameterName Then oPartParameters.Item(i).CustomPropertyFormat.Precision() = 85518 'Sixteenths Fractional Precision' Else End If Next i Dim sIPropertySetName As String sIPropertySetName = "User Defined Properties" Dim sIPropertySet As String sIPropertySet = "{D5CDD505-2E9C-101B-9397-08002B2CF9AE}" 'Inventor User Defined Properties' Dim sFormattedText As String sFormattedText = "<Property Document='model' PropertySet='" & sIPropertySetName & "' Property='" & sParameterName & "' FormatID='" & sIPropertySet & "'></Property> D" Dim oLeaderNote As LeaderNote oLeaderNote = oSheet.DrawingNotes.LeaderNotes.Add(oLeaderPoints, "") oLeaderNote.FormattedText = sFormattedText oLeaderNote.Leader.ArrowheadType() = 71948 'No arrowhead End Sub