Leader point to midpoint of curve

Leader point to midpoint of curve

NachoShaw
Advisor Advisor
503 Views
1 Reply
Message 1 of 2

Leader point to midpoint of curve

NachoShaw
Advisor
Advisor

Hey

 

I am using this code from the API help file

Dim oDrawDoc As DrawingDocument = Invapp.ActiveDocument
Dim oActiveSheet As Sheet = oDrawDoc.ActiveSheet
Dim oDrawingCurveSegment As DrawingCurveSegment = oDrawDoc.SelectSet.Item(1)
Dim oDrawingCurve As DrawingCurve = oDrawingCurveSegment.Parent
Dim oMidPoint As Point2d = oDrawingCurve.MidPoint
Dim oTG As TransientGeometry = Invapp.TransientGeometry
Dim oLeaderPoints As ObjectCollection = Invapp.TransientObjects.CreateObjectCollection

oLeaderPoints.Add(oTG.CreatePoint2d(oMidPoint.X + 1.5, oMidPoint.Y))

 

but when the leader is added, the arrow is not positioned on oMidpoint.X, its positioned on the curve end. The 2nd position of oMidpoint.Y is correct...

save.jpg

 

Am i missing something? Is there any better Balloon code?

 

 

Thanks

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


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.


0 Likes
504 Views
1 Reply
Reply (1)
Message 2 of 2

Michael.Navara
Advisor
Advisor

You must specify correct geometryIntent object

 

'Get active drawing
Dim drw As DrawingDocument = ThisDoc.Document
'Get active sheet
Dim sh As Sheet = drw.ActiveSheet


'Get selected drawing curve
Dim curveSegment As DrawingCurveSegment = drw.SelectSet(1)

'Create balloon position point
Dim pt As Point2d = curveSegment.Parent.MidPoint.Copy
pt.TranslateBy(ThisApplication.TransientGeometry.CreateVector2d(1,0))

'Create geometry intent
Dim geomIntent As GeometryIntent 

'!!!!!!!
'You need to specify PointIntentEnum.kMidPointIntent
geomIntent = sh.CreateGeometryIntent(curveSegment.Parent, PointIntentEnum.kMidPointIntent)
'!!!!!!!

'Create leader points
Dim leaderPoints As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
leaderPoints.Add(pt)
leaderPoints.Add(geomIntent)

'Create Balloon
sh.Balloons.Add(leaderPoints)