Help: iLogic/VBA Code Get Body'/Feature' Name then Add the Leader Text in the Drawing

Help: iLogic/VBA Code Get Body'/Feature' Name then Add the Leader Text in the Drawing

ngdnam88
Advocate Advocate
564 Views
2 Replies
Message 1 of 3

Help: iLogic/VBA Code Get Body'/Feature' Name then Add the Leader Text in the Drawing

ngdnam88
Advocate
Advocate

Dears,

I'm trying find the iLogic/VBA Code that can get name of Body/Feature then create the Text Leader as the picture:
Screenshot 2022-08-09 200640.png

Is it possible?

I think the way to done this (but I didn't know how to code them):

+ Create the Leader Text with any Char.

+ Rule can filter select Body/Feature
+ Take name's of Body/Feature

+ Select the Leader Text and correct it with Body'/Feature' name

 

Thanks you very much!

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

Michael.Navara
Advisor
Advisor
Accepted solution

Here is a sample iLogic code, where you can start

Dim drw As DrawingDocument = ThisDoc.Document
Dim sheet As Sheet = drw.ActiveSheet

'Pick some linear edge
'For diferent edge type you need to modify the code for creating of connectionPoint
Dim pick = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingCurveSegmentFilter, "Pick drawing line")
Dim curveSegment As DrawingCurveSegment = pick
If curveSegment.GeometryType <> Curve2dTypeEnum.kLineSegmentCurve2d Then
    MsgBox("This is not a line segment")
    Return
End If

'Connection point to drawing curve segment
Dim curveGeometry As LineSegment2d = curveSegment.Geometry
Dim connectionPoint As GeometryIntent = sheet.CreateGeometryIntent(curveSegment.Parent, curveGeometry.MidPoint)

'Position of text
Dim textPoint As Point2d = curveGeometry.MidPoint
textPoint.X +=1
textPoint.Y +=1

'Create leader points for general note
Dim leaderPoints As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection()
leaderPoints.Add(textPoint)
leaderPoints.Add(connectionPoint)

'Get body name
Dim partEdge as Edge = curveSegment.Parent.ModelGeometry
Dim surfaceBody As SurfaceBody = partEdge.Parent
dim bodyName = surfaceBody.Name

'Create leader note
sheet.DrawingNotes.LeaderNotes.Add(leaderPoints, bodyName)

 

Message 3 of 3

ngdnam88
Advocate
Advocate

Thanks @Michael.Navara
It's working perfectly.

Can we change/apply the the Format Style before place the text leader? I wanna use an other one for this leader text.

ngnam1988_0-1660290719373.png

Thanks you very much!

 

0 Likes