Creating Sketched Symbols

By Augusto Goncalves

Sketched symbols are more or less similar to blocks in AutoCAD and is available only in the drawing document. Following is a sample code which creates a symbol and inserts it in the active sheet.

Sub CreateSketchedSymbol()
 
  Dim oDwg As DrawingDocument = _
    m_inventorApplication.ActiveDocument
  Dim oTG As TransientGeometry = _
    m_inventorApplication.TransientGeometry
 
  Dim oSSD As SketchedSymbolDefinition = _
    oDwg.SketchedSymbolDefinitions.Add("mySymbol")
  Dim oRes As DrawingSketch = Nothing
 
  'Open the sketch in edit mode.
  oSSD.Edit(oRes)
  oRes.SketchCircles.AddByCenterRadius( _
    oTG.CreatePoint2d(5, 5), 2)
  oRes.SketchCircles.AddByCenterRadius( _
    oTG.CreatePoint2d(5, 5), 1)
  oRes.SketchLines.AddAsTwoPointRectangle( _
    oTG.CreatePoint2d(3, 3), oTG.CreatePoint2d(7, 7))
 
  'Quit the Edit mode.
  oSSD.ExitEdit(True)
 
  'Insert the sketched symbol on the active sheet.
  oDwg.ActiveSheet.SketchedSymbols.Add( _
    "mySymbol", oTG.CreatePoint2d(10, 10))
End Sub
Note another approach is also documented here: https://blog.autodesk.io/2024/04/23/ilogic-to-insert-an-image-into-drawing-sketch-by-sketched-symbols/

Comments

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading