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.
Solved! Go to Solution.
Solved by BrandonBG. Go to Solution.
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
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 !
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.