Insert sketch symbol using ilogic rule

Insert sketch symbol using ilogic rule

Anonymous
Not applicable
5,867 Views
15 Replies
Message 1 of 16

Insert sketch symbol using ilogic rule

Anonymous
Not applicable

Hello,

 

I would like to insert sketch symbol with the name "TAG" into the active drawing using a rule. User will then pick location. This sketch symbol has no prompted entries. 

 

In the other case i would like to insert a sketch symbol with name "REF" into the active drawing but this sketch symbol will have prompted entries. Also with user to pick location.

 

 

 

 

0 Likes
Accepted solutions (1)
5,868 Views
15 Replies
Replies (15)
Message 2 of 16

Sergio.D.Suárez
Mentor
Mentor

Hi, Here I share a drawing file in Inventor 2018, in which I have two sketch symbols. The first sketch symbol has four requested entries, the second sketch symbol has no requested entries. There are four ilogic rules, two for each sketch symbol.
One of the rules will place the sketch symbol in a position determined by coordinates.
The second rule will place the sketch symbol with the mouse.
Note that the sketch symbol with 4 entries has the sproptstring defined in (3) that is because it counts from zero.

I hope this helps. regards


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

Message 3 of 16

Anonymous
Not applicable

Thank you for this, this could work. Is there a way to have the sketch symbol preview so the user has an idea of where it will be placed? The preview would work the same as inserting a sketch symbol through double clicking thorugh the  the tree.

Message 4 of 16

Anonymous
Not applicable

Adding to the above, ideally it would be great have the ability to snap to existing geometry using the insertion insertion point grip.

 

Thanks again.

0 Likes
Message 5 of 16

Anonymous
Not applicable

Hello, I was also wondering if it is possible to control/toggle the symbol library options within the code.

Main goal is I have some sketch symbols that would require a leader and others that don't.

 

Symbol library options:

Symbol Clipping

Static 

Leader 

Visible options

 

 

0 Likes
Message 6 of 16

Andrew_Burnett
Enthusiast
Enthusiast

Has anyone found a way to get the inserting symbol snap to a grip on an existing symbol?  I am wanting to use this for some notes that we place on the drawing and stack them on top of the title block.

Thank you in advance.

Message 7 of 16

jigneshah25
Participant
Participant

Thanks for the Sample Code. Can we control the sketch selection via excel linked parameter. For example if I want to replace certain sketch based on selection made in Excel sheet linked with Inventor Model.

 

0 Likes
Message 8 of 16

Anonymous
Not applicable

Hi everyone, is it technically possible to create a rule that would insert symbols from a library that is located on a server?

0 Likes
Message 9 of 16

Anonymous
Not applicable
Hi - The only way to add a sketch symbol that is not located in the actual drawing is by using the sketch symbol library. Is it possible to add from the server, yes but that would mean you need to path to the sketch symbol library to that location in the server. Would this server location be static or would it vary based on drawing? If I understand a bit more your parameters and end goal I believe I can assist.
0 Likes
Message 10 of 16

Curtis_Waguespack
Consultant
Consultant

Hi @Anonymous ,

 

If your Tools > application options > Files > Symbol Library path is specifying the server path, then you could use something like this.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

'this is the name of the symbol library file,
'the path to this location is specified under 
'Tools tab > Application Options button > Files tab 
oSymbolDrawingName = "Sketched Symbols"

'This is the name of the symbol to place
oSymbolName = "Test101"

'check file type 
If ThisDoc.Document.DocumentType <> kDrawingDocumentObject Then
Return
End If

'define the drawing document
Dim oDrawDoc As DrawingDocument 
oDrawDoc = ThisApplication.ActiveDocument


Dim oSketchSymLib As SketchedSymbolDefinitionLibrary
oSketchSymLib = oDrawDoc.SketchedSymbolDefinitions.SketchedSymbolDefinitionLibraries.Item(oSymbolDrawingName)
Dim oSymDef As SketchedSymbolDefinition

'place the symbol in the Drawing Resources folder
oSymDef = oDrawDoc.SketchedSymbolDefinitions.AddFromLibrary(oSketchSymLib, oSymbolName, True)


Dim oPosition As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(10, 15)

'[use this if the symbol has no prompted entry
Dim oSymbol As SketchedSymbol
oSymbol = oDrawDoc.ActiveSheet.SketchedSymbols.Add(oSymDef, oPosition, 0, 1, )
']

''or
''[ use this if the symbol has prompted entry
'Dim sPromptStrings(2) As String 'string array with 2 items, for two prompts
'sPromptStrings(0) = "Hello"
'sPromptStrings(1) = "World"


'Dim oSymbol As SketchedSymbol
'oSymbol = oDrawDoc.ActiveSheet.SketchedSymbols.Add(oSymDef, oPosition, 0, 1, sPromptStrings)

 

EESignature

Message 11 of 16

Anonymous
Not applicable

Hi, thank you. It works great. And I have one more question. Our library contains more items. It is possible for a dialogue to appear at the beginning and to be able to choose what I need.
Thanks

0 Likes
Message 12 of 16

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Hi @Anonymous 

 

Give this a try.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

'this is the name of the symbol library file,
'the path to this location is specified under 
'Tools tab > Application Options button > Files tab 
oSymbolDrawingName = "Sketched Symbols"


'check file type 
If ThisDoc.Document.DocumentType <> kDrawingDocumentObject Then
Return
End If

'define the drawing document
Dim oDrawDoc As DrawingDocument 
oDrawDoc = ThisApplication.ActiveDocument

Dim oSketchSymLib As SketchedSymbolDefinitionLibrary
oSketchSymLib = oDrawDoc.SketchedSymbolDefinitions.SketchedSymbolDefinitionLibraries.Item(oSymbolDrawingName)

Dim oSymbolList As New ArrayList

For Each oSymbolDef In oSketchSymLib.SketchedSymbolDefinitions
	oSymbolList.Add(oSymbolDef.name)
Next

oName = InputListBox("Pick a Symbol",oSymbolList, oSymbolList(0), "iLogic", "List of Symbols")

If oName = "" Then
	Return 'exit rule
End If

Dim oSymDef As SketchedSymbolDefinition

'place the symbol in the Drawing Resources folder
oSymDef = oDrawDoc.SketchedSymbolDefinitions.AddFromLibrary(oSketchSymLib, oName, True)


Dim oPosition As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(10, 15)

'[use this if the symbol has no prompted entry
Dim oSymbol As SketchedSymbol
oSymbol = oDrawDoc.ActiveSheet.SketchedSymbols.Add(oSymDef, oPosition, 0, 1, )
']

 

EESignature

Message 13 of 16

Anonymous
Not applicable

That's great. Thanks. You helped me a lot.

0 Likes
Message 14 of 16

creggo
Enthusiast
Enthusiast

Works great, just wondering if there's a way to force on the static option? 

Creggo_0-1661179184533.png

 

 

0 Likes
Message 15 of 16

A.Acheson
Mentor
Mentor

Here is the syntax for below from API help

oSymbol.Static = True

 

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 16 of 16

ArunJNXXNQ
Explorer
Explorer

Hi, i am looking for the exact case, where a preview would be ideal. Do you have a code that works for this?

0 Likes