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: 

iLogic and sketch symbol library

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
Anonymous
3198 Views, 6 Replies

iLogic and sketch symbol library

I have a code that looks for a yes or no iproperty from the idw model and place a sketch symbol in the idw depending on the yes or no.

 

I am currently using these line of code to get the sketch symbol

SyntaxEditor Code Snippet

    'create insertion point, coordinates - are cm 
    Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
    Dim oInsertionPoint As Point2d
    
    'define the insert point for the symbol
    oInsertionPoint = oTG.CreatePoint2d(23.9,4.5) ' X = 25 cm , Y = 4.5 cm
    'define symbol Definition to use
    oSymDef= oDrawDoc.SketchedSymbolDefinitions.Item(sSymbol_01)
    
    'capture the current active sheet 
    Dim oCurrentNumber  As Sheet
    oCurrentNumber  = oDrawDoc.ActiveSheet

        'insert the new symbol
        'Nothing is used when teh symbol has no prompted entry
        oSym = oCurrentNumber.SketchedSymbols.Add(oSymDef,oInsertionPoint,0,1,Nothing)    

But it doesn't look for the skecth symbol in the libraries, only in the local one.

 

Is there a way (ilogic code) to insert a sketch symbol from the library?

I know that there's code to get the sketch symbol from a template but I really wish I could just use the one in the library.

6 REPLIES 6
Message 2 of 7
Anonymous
in reply to: Anonymous

UP!

Message 3 of 7
BrandonBG
in reply to: Anonymous

Dim oSketchSymLib As SketchedSymbolDefinitionLibrary
oSketchSymLib = oDrawing.SketchedSymbolDefinitions.SketchedSymbolDefinitionLibraries.Item("Library")

Dim oSSDEf As SketchedSymbolDefinition
oSSDef = oDrawing.SketchedSymbolDefinitions.AddFromLibrary(oSketchSymLib, "The Name Of The Sketched Symbol", True)

You need to add the library sketched symbol to the local symbols before you can place it.

 

Brandon

Message 4 of 7
Anonymous
in reply to: Anonymous

Thanks I just added it to my to my code and it worked!
Message 5 of 7
JorisSteurs1246
in reply to: Anonymous

I have been putting these pieces of iLogic together, but can't get it to work.

 

Is it possible to post the complete working code here?

 

Thank you.

Tags (2)
Message 6 of 7
bradeneuropeArthur
in reply to: Anonymous

Please provide us your complete code.

Regards,

Arthur Knoors

Autodesk Affiliations:

Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!


! For administrative reasons, please mark a "Solution as solved" when the issue is solved !

Message 7 of 7

Hi

 

This is the rule!

 

Regards

 

'Sub Main() 
'Set a reference to the drawing document.
'This assumes the drawing document is active.
Dim oDrawDoc As DrawingDocument = ThisDrawing.Document
Dim oSketchSymLib As SketchedSymbolDefinitionLibrary _
    = oDrawDoc.SketchedSymbolDefinitions.SketchedSymbolDefinitionLibraries.Item("Library")

Dim oSSDEf As SketchedSymbolDefinition _
    = oDrawDoc.SketchedSymbolDefinitions.AddFromLibrary(oSketchSymLib, "The Name Of The Sketched Symbol", True)

'Dim oDrawDoc As DrawingDocument = ThisDrawing.Document
Dim oSketchedSymbolDef As SketchedSymbolDefinition _
       = oDrawDoc.SketchedSymbolDefinitions.Item("The Name Of The Sketched Symbol")
	   

Dim oSheet As Sheet = oDrawDoc.ActiveSheet
 
'CREATE INSERTION POINT, coordinates in cm!
Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
Dim oInsertionPoint As Point2d = oTG.CreatePoint2d(24.9, 19.1)
 
'Add an instance of the sketched symbol definition to the sheet.
'Angle of rotation = 0 radians,
'scale = 1 when adding
'no text message
Dim oSketchedSymbol As SketchedSymbol _
       = oSheet.SketchedSymbols.Add( _
             oSketchedSymbolDef, _
             oInsertionPoint, _
             0, 1, Nothing)
'End Sub

 

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

Post to forums  

Autodesk Design & Make Report