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 Controlled Sketch Symbol

10 REPLIES 10
SOLVED
Reply
Message 1 of 11
jpchaisson
3256 Views, 10 Replies

iLogic Controlled Sketch Symbol

How do i target a specific sketch symbol within a view and control it with iLogic?

 

 

10 REPLIES 10
Message 2 of 11
jdkriek
in reply to: jpchaisson

This should give you an idea how to

http://forums.autodesk.com/t5/Autodesk-Inventor/ilogic-and-sketched-symbols/m-p/2947782#M396823

Look for the post from MjDeck

Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


Message 3 of 11
jpchaisson
in reply to: jdkriek

Let explain in detail.....

 

See Attached Image ....

 

 

Message 4 of 11
jdkriek
in reply to: jpchaisson

This was pretty fun to figure out.

 

1. Put the code in an iLogic Rule

2. This assumes the skeched symbol is named "Label" - change it to whatever you need

3. You need to add a custom iProperty named "SYMNAME" to the sketched symbol.

3. Select a view and run the iLogic rule 😉

 

Result? It will insert the skeched symbol with the view label from the selected view.

 

I do hope this is what you need OR at least you can modify it to suit your needs.

 

Dim oApp As Application: oApp = ThisApplication
Dim oDoc As DrawingDocument: oDoc = oApp.ActiveDocument
Dim oSheet As Sheet: oSheet = oDoc.ActiveSheet

'This uses a sketch symbol with the name "label"
Dim oSymDef As SketchedSymbolDefinition: oSymDef = oDoc.SketchedSymbolDefinitions.Item("Label")

'This is the selected view
Dim oView As DrawingView: oView = oDoc.SelectSet.Item(1)

'This takes the label of the selected view and adds it to Custom iProperty
Dim SymLabel As String: SymLabel = oView.Label.Text
iProperties.Value("Custom", "SYMNAME") = SymLabel

'This is the position for the sketched symbol under the selected view
Dim oPosition As Point2d: oPosition = oView.Center
oPosition.y = oPosition.y - (oView.Height / 2 + 0.5)

'This inserts the sketched symbol
Dim oSymbol As SketchedSymbol: oSymbol = oSheet.SketchedSymbols.Add(oSymDef, oPosition,,,)
Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


Message 5 of 11
jpchaisson
in reply to: jdkriek

once again thanks for your hard work. i understand each line of your code, i do have one question, if you are referencing the view label to the custom ipropery how is the sketch symbol reading it?

 

i think the method im looking for is " SetPromptedResultText" just not sure how to use it.

 

other than that your code is awesome.

 

Thanks, Jeremy

Message 6 of 11
jdkriek
in reply to: jpchaisson

The sketched symbol should have a text box with the custom iProperty <SYMNAME> inserted into it.

Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


Message 7 of 11
jpchaisson
in reply to: jpchaisson

I Prefer not to do it that way Because i would need to Create a new sketch Symbol and iproperty for each view also im getting errors on your code I think its the last line. How do I do this with Prompted text?
Message 8 of 11
jdkriek
in reply to: jpchaisson

You'll get errors if you run the rule and don't select a view - there's no error handling in there, it's easy to add, but it was late.

Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


Message 9 of 11
jdkriek
in reply to: jpchaisson

I'll tweak this to run with prompted entries later tonight if I have time - but one question. So you are looking to populate the prompted entry with the view label? So you would just hit enter when it pops up?
Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


Message 10 of 11
jpchaisson
in reply to: jdkriek

Well we all know Creating your own View Label becomes dumb theres no association to the View Label.

 

so if i have a View i wanna be able to insert my Sketch Symbol like i always do...

 

i want my code to link the View Label and the Scale to the sketch symbol.

 

i should be able to use the same code over and over for each view and only have to modify witch View .item(?) to

witch Symbol .item(?) im trying to link together. i am going to Private Message you my Cell #

Message 11 of 11
jdkriek
in reply to: jpchaisson

Ok, slight tweak and now it's working with the prompted entry

 

Dim oApp As Application: oApp = ThisApplication
Dim oDoc As DrawingDocument: oDoc = oApp.ActiveDocument
Dim oSheet As Sheet: oSheet = oDoc.ActiveSheet

'This uses a sketch symbol with the name "label"
Dim oSymDef As SketchedSymbolDefinition: oSymDef = oDoc.SketchedSymbolDefinitions.Item("label")

'This is the selected view
Dim oView As DrawingView: oView = oDoc.SelectSet.Item(1)

'This takes the label items of the selected view 
'And adds it To an array that will link To the prompted entry
Dim sPromptStrings(1) As String
sPromptStrings(0) = oView.Name
sPromptStrings(1) = oView.Scale

'This is the position for the sketched symbol under the selected view
Dim oPosition As Point2d: oPosition = oView.Center
oPosition.y = oPosition.y - (oView.Height / 2 + 0.5)

'This inserts the sketched symbol and fills in the prompted entry
Dim oSymbol As SketchedSymbol: oSymbol = oSheet.SketchedSymbols.Add(oSymDef, oPosition, , ,sPromptStrings)

 

Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


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

Post to forums  

Autodesk Design & Make Report