Reference example: adding 2 leaders to a leader note

Reference example: adding 2 leaders to a leader note

Curtis_Waguespack
Consultant Consultant
48 Views
2 Replies
Message 1 of 3

Reference example: adding 2 leaders to a leader note

Curtis_Waguespack
Consultant
Consultant

Recently had trouble finding an example or good info in the API help, so here's a quick example of adding 2 leaders to a leader note ( works the same with weld symbols, etc), in case it helps someone in a future search.

EESignature

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

Curtis_Waguespack
Consultant
Consultant
Accepted solution

 


Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument

' a reference to the active sheet.
Dim oActiveSheet As Sheet
oActiveSheet = oDrawDoc.ActiveSheet

' a reference to the drawing curve segment.
' Please select a linear drwaing curve.
Dim oDrawingCurveSegment1 As DrawingCurveSegment
oDrawingCurveSegment1 = ThisApplication.CommandManager.Pick(kDrawingCurveSegmentFilter, "Select a linear curve")

' a reference to the drawing curve.
Dim oDrawingCurve1 As DrawingCurve
oDrawingCurve1 = oDrawingCurveSegment1.Parent

' Get the mid point of the selected curve
' assuming that the selection curve is linear
Dim oMidPoint1 As Point2d
oMidPoint1 = oDrawingCurve1.MidPoint

Dim oDrawingCurveSegment2 As DrawingCurveSegment
oDrawingCurveSegment2 = ThisApplication.CommandManager.Pick(kDrawingCurveSegmentFilter, "Select a linear curve for the 2nd leader")

' a reference to the drawing curve.
Dim oDrawingCurve2 As DrawingCurve
oDrawingCurve2 = oDrawingCurveSegment2.Parent

' Get the mid point of the selected curve
' assuming that the selection curve is linear
Dim oMidPoint2 As Point2d
oMidPoint2 = oDrawingCurve2.MidPoint

 'a reference To the TransientGeometry Object.
Dim oTG As TransientGeometry
oTG = ThisApplication.TransientGeometry

Dim oLeaderPoints As ObjectCollection
oLeaderPoints = ThisApplication.TransientObjects.CreateObjectCollection

' Create a few leader points.
oLeaderPoints.Add(oTG.CreatePoint2d(oMidPoint1.X + 5, oMidPoint1.Y + 10))
'oLeaderPoints.Add(oTG.CreatePoint2d(oMidPoint1.X + 10, oMidPoint1.Y + 10)) ' use this to add a second point to the leader 

' Create an intent and add to the leader points collection.
' This is the geometry that the symbol will attach to.
Dim oGeometryIntent1 As GeometryIntent
oGeometryIntent1 = oActiveSheet.CreateGeometryIntent(oDrawingCurve1)

Dim oGeometryIntent2 As GeometryIntent
oGeometryIntent2 = oActiveSheet.CreateGeometryIntent(oDrawingCurve2)

Call oLeaderPoints.Add(oGeometryIntent1)

Dim oLeaderNote As LeaderNote
oLeaderNote = oActiveSheet.DrawingNotes.LeaderNotes.Add(oLeaderPoints,"Hello World")

oLeaderPoints.Clear
Call oLeaderPoints.Add(oGeometryIntent2)
oLeaderNote.Leader.RootNode.AddLeader(oLeaderPoints) 

 

 

EESignature

0 Likes
Message 3 of 3

Tiffany_Hayden_
Collaborator
Collaborator

Awesome! 

@Curtis_Waguespack 

Tiffany Hayden
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature

0 Likes