Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Insert sketchedsymbol to drawing with leader using iLogic

1 REPLY 1
Reply
Message 1 of 2
MK-CAD-Admin
475 Views, 1 Reply

Insert sketchedsymbol to drawing with leader using iLogic

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

 

1 REPLY 1
Message 2 of 2

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)


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums