Attach prompted text to a line in a drawing with a leader

Attach prompted text to a line in a drawing with a leader

hieut1392
Enthusiast Enthusiast
201 Views
3 Replies
Message 1 of 4

Attach prompted text to a line in a drawing with a leader

hieut1392
Enthusiast
Enthusiast

I want to attach prompted text to a line in a drawing with a leader, i need help.

 

1) Click on the line

2) Call out the prompted text

3) Fill in the information

4) Finish (pic 1)

hieut1392_0-1728903701799.png

 

My code has an error on the last line.

 

 

Option Explicit

Sub Test()

Dim oDrawDoc As DrawingDocument
Set oDrawDoc = ThisApplication.ActiveDocument

Dim oSheet As sheet
Set oSheet = oDrawDoc.ActiveSheet

Dim oSketchedSymbolDef As SketchedSymbolDefinition
Set oSketchedSymbolDef = oDrawDoc.SketchedSymbolDefinitions.Item("BALLOON")

Dim sPromptStrings(4) As String
sPromptStrings(0) = "aaaa"
sPromptStrings(1) = "bbbb"
sPromptStrings(2) = "cccc"
sPromptStrings(3) = "dddd"
sPromptStrings(4) = "eeee"

Dim oLine As Object
Set oLine = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAllEntitiesFilter, "Pick an edge:")

Dim oDrawingCurveSegment As DrawingCurveSegment
Set oDrawingCurveSegment = oLine

Dim oDrawingCurve As DrawingCurve
Set oDrawingCurve = oDrawingCurveSegment.Parent

Dim oMidPoint As Point2d
Set oMidPoint = oDrawingCurve.MidPoint

Dim oTG As TransientGeometry
Set oTG = ThisApplication.TransientGeometry

Dim oLeaderPoints As ObjectCollection
Set oLeaderPoints = ThisApplication.TransientObjects.CreateObjectCollection

Call oLeaderPoints.Add(oTG.CreatePoint2d(oMidPoint.x, oMidPoint.y))

Dim oGeometryIntent As GeometryIntent
Set oGeometryIntent = oSheet.CreateGeometryIntent(oDrawingCurve)

Call oLeaderPoints.Add(oGeometryIntent)

Dim oSketchedSymbol As SketchedSymbol
Set oSketchedSymbol = oSheet.SketchedSymbols.Add(oSketchedSymbolDef, oLeaderPoints, 0, 1, sPromptStrings)

End Sub

 


Also, suppose my sketch symbol is placed in the NewFolder, is there a way to call it out? (picture 2)

hieut1392_1-1728904045928.png

 

 

0 Likes
202 Views
3 Replies
Replies (3)
Message 2 of 4

Michael.Navara
Advisor
Advisor

If you want to add sketched symbol with leader, use 

oSheet.SketchedSymbols.AddWithLeader(...) at line 47

0 Likes
Message 3 of 4

hieut1392
Enthusiast
Enthusiast

still error. I think the problem is in oLeaderPoint.

0 Likes
Message 4 of 4

jnowel
Advocate
Advocate

try commenting out this line

Call oLeaderPoints.Add(oTG.CreatePoint2d(oMidPoint.x, oMidPoint.y))

 

and have the set Geometry Intent be something like this

Set oGeometryIntent = oSheet.CreateGeometryIntent(oDrawingCurve, oMidPoint)

 
the next step could be (depending on your use case) is to reposition the created SketchedSymbol

0 Likes