ilogic sketched symbol with leader

ilogic sketched symbol with leader

Anonymous
Not applicable
1,221 Views
5 Replies
Message 1 of 6

ilogic sketched symbol with leader

Anonymous
Not applicable

I trying to insert a symbol with a leader but i have a error message after de step 6, anybody can help me

with this code?

 

the code

 

' Set a reference to the drawing document.
' This assumes a drawing document is active.
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument

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

' Set a reference to the drawing curve segment.
' This assumes that a drawing curve is selected.
Dim oDrawingCurveSegment As DrawingCurveSegment
oDrawingCurveSegment = oDrawDoc.SelectSet.Item(1)

' Set a reference to the drawing curve.
Dim oDrawingCurve As DrawingCurve
oDrawingCurve = oDrawingCurveSegment.Parent

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

' Set 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.
Call oLeaderPoints.Add(oTG.CreatePoint2d(oMidPoint.X, oMidPoint.Y))
Call oLeaderPoints.Add(oTG.CreatePoint2d(oMidPoint.X, oMidPoint.Y))

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

Call oLeaderPoints.Add(oGeometryIntent)

' Get the first symbol definition
Dim oSketchSymDef As SketchedSymbolDefinition
oSketchSymDef = oDrawDoc.SketchedSymbolDefinitions.Item("View_Label")

MessageBox.Show("6", "STEP")

' Create the symbol with a leader
Dim oSketchedSymbol As SketchedSymbol
oSketchedSymbol = oActiveSheet.SketchedSymbols.AddWithLeader(oSketchSymDef,oLeaderPoints)

 

the error message

 

leader error.PNG

 

Thanks for you help!

 

 

0 Likes
1,222 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable

ok i find the solution in api programming help and insert this code before her code

 

Dim doc = ThisApplication.ActiveDocument
Dim entity = ThisApplication.CommandManager.Pick(
SelectionFilterEnum.kDrawingCurveSegmentFilter,
"select line")

my problem now is the insertion point of the narrow leader, i want to insert the leader in the middle of the line, anybody know to make that???

0 Likes
Message 3 of 6

Anonymous
Not applicable

this is the complet code

 

Dim doc = ThisApplication.ActiveDocument
Dim entity = ThisApplication.CommandManager.Pick(
SelectionFilterEnum.kDrawingCurveSegmentFilter,
"select line")

' Set a reference to the drawing document.
' This assumes a drawing document is active.
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument

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

' Set a reference to the drawing curve segment.
' This assumes that a drwaing curve is selected.
Dim oDrawingCurveSegment As DrawingCurveSegment
oDrawingCurveSegment = entity

' Set a reference to the drawing curve.
Dim oDrawingCurve As DrawingCurve
oDrawingCurve = oDrawingCurveSegment.Parent

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

' Set 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.
Call oLeaderPoints.Add(oTG.CreatePoint2d(oMidPoint.X, oMidPoint.Y - 1.8))
Call oLeaderPoints.Add(oTG.CreatePoint2d(oMidPoint.X, oMidPoint.Y - 1.8 ))

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

Call oLeaderPoints.Add(oGeometryIntent)

' Get the first symbol definition
Dim oSketchSymDef As SketchedSymbolDefinition
oSketchSymDef = oDrawDoc.SketchedSymbolDefinitions.Item("test leader")

' Create the symbol with a leader
Dim oSketchedSymbol As SketchedSymbol
oSketchedSymbol = oActiveSheet.SketchedSymbols.AddWithLeader(oSketchSymDef, oLeaderPoints)

0 Likes
Message 4 of 6

Anonymous
Not applicable

I ADD oSketchedSymbol.LeaderVisible = False at the bottom of the rule

 

i have new problem with my rule if i add  a Prompted Entry text in my symbol my rule dont work

and show me this error message? if i delete this new entry, work again???

 

new error.JPG

 

 

0 Likes
Message 5 of 6

Vladimir.Ananyev
Alumni
Alumni

Could this link help you with format for prompted text?

http://forums.autodesk.com/t5/Inventor-Customization/Sample-Code-does-not-work/m-p/4542347/highlight...

If not then please post your test for propmped text that could be analyzed. 

cheers


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 6 of 6

Anonymous
Not applicable

Thanks for your help Vladimir 🙂

 

Maybe i find the solution one day 🙂

0 Likes