Hello everybody,
i'd created a rule for inserting a sketchedSymbol to my drawing. (find below)
Now my Question:
How can i place this symbol to the drawing with a leader by choosing a line or edge of any view?
Thanks in advance
Sub Main() ' Set a reference to the drawing document.' This assumes a drawing document is active. Dim oDrawDoc As DrawingDocument = ThisDrawing.Document ' Obtain a reference to the desired sketched symbol definition. Dim oSketchedSymbolDef As SketchedSymbolDefinition _ = oDrawDoc.SketchedSymbolDefinitions.Item("Motor") Dim oSheet As Sheet = oDrawDoc.ActiveSheet 'create insertion point, coordinates - in cm ! Dim oTG As TransientGeometry = ThisApplication.TransientGeometry Dim oInsertionPoint As Point2d = oTG.CreatePoint2d(1.75,1.4) ' Add an instance of the sketched symbol definition to the sheet.' Rotate angle = 0 degree,' scale = 1 when adding' no prompt text Dim oSketchedSymbol As SketchedSymbol = oSheet.SketchedSymbols.Add( oSketchedSymbolDef, oInsertionPoint, 0, 1, Nothing) End Sub
Here is a peicemeal portion of a sub I use to do that. You can also look here:
"C:\Program Files\Autodesk\Inventor 2016\Local Help\admapi_20_0.chm"
Try
oDLine = oCommandMgr.Pick(SelectionFilterEnum.kDrawingCurveSegmentFilter, "Select the LINE")
Catch
MsgBox("Issue getting CmdMgr")
End Try
oEndLine = oSketch.SketchLines.Item(x)
oSecLine1 = oSketch.SketchLines.Item(1)
oSecLine2 = oEndLine
oCP = oTG.CreatePoint2d(oSketch.Parent.Position.X, oSketch.Parent.Position.Y)
oSecSP = oTG.CreatePoint2d(oCP.X +oSecLine1.StartSketchPoint.Geometry.X*oView.Scale, oCP.Y + oSecLine1.StartSketchPoint.Geometry.Y*oView.Scale)
oSecEP = oTG.CreatePoint2d(oCP.X +oSecLine2.EndSketchPoint.Geometry.X*oView.Scale, oCP.Y + oSecLine2.EndSketchPoint.Geometry.Y*oView.Scale)
End If
'THIS PART IS KEY; however, this only places the symbol on top of the same place the leader is put. Adding another set of leader points will place the symbol somewhere else, but still the leader at the geometry intent
oLeaderPoints1 = oTO.CreateObjectCollection
oGeometryIntent1 = oDwgDoc.ActiveSheet.CreateGeometryIntent(oSecLine1, oSecSP)
oLeaderPoints1.Add(oGeometryIntent1)