Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I've had a script for adding leader text to the center of a selected line in drawings for a while. I just fixed a bug where selecting a circle would cause the code to fail. I figured out that the MidPoint of a curve doesn't exist for circles, so if that is nothing, I'm using the CenterPoint instead.
Now for my actual question. I would like to have my leader attach to the outside of a selected circle instead of the center point. This is just because I'm curious and think it would look better that way. So if anyone can help out I'd appreciate it.
Example of where I would like to have the leader attached.
Public Sub InsertLeaderText(sText As String)
Dim oDrawDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oActiveSheet As Sheet = oDrawDoc.ActiveSheet
Dim oDrawingCurveSegment As DrawingCurveSegment
oDrawingCurveSegment = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingCurveSegmentFilter, "Select a line")
If (oDrawingCurveSegment Is Nothing) Then Exit Sub
Dim oDrawingCurve As DrawingCurve
oDrawingCurve = oDrawingCurveSegment.Parent
' Get the mid point of the selected curve assuming that the selected curve is linear
Dim oMidPoint As Point2d = oDrawingCurve.MidPoint
'New line to account for circles, set variable to center point
If (oMidPoint Is Nothing) Then oMidPoint = oDrawingCurve.CenterPoint
' Set a reference to the TransientGeometry object.
Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
Dim oLeaderPoints As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
' Create a leader point.
Call oLeaderPoints.Add(oTG.CreatePoint2d(oMidPoint.X + 2, oMidPoint.Y + 2))
' Create an intent and add to the leader points collection.
' This is the geometry that the leader text will attach to.
Dim oGeometryIntent As GeometryIntent = oActiveSheet.CreateGeometryIntent(oDrawingCurve, oMidPoint)
Call oLeaderPoints.Add(oGeometryIntent)
Dim oLeaderNote As LeaderNote = oActiveSheet.DrawingNotes.LeaderNotes.Add(oLeaderPoints, sText)
End Sub
I've h
Solved! Go to Solution.