iLogic Controlled Sketch Symbol

iLogic Controlled Sketch Symbol

jpchaisson
Advocate Advocate
3,860 Views
10 Replies
Message 1 of 11

iLogic Controlled Sketch Symbol

jpchaisson
Advocate
Advocate

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

 

 

0 Likes
Accepted solutions (1)
3,861 Views
10 Replies
Replies (10)
Message 2 of 11

jdkriek
Advisor
Advisor

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.


0 Likes
Message 3 of 11

jpchaisson
Advocate
Advocate

Let explain in detail.....

 

See Attached Image ....

 

 

0 Likes
Message 4 of 11

jdkriek
Advisor
Advisor

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
Advocate
Advocate

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

0 Likes
Message 6 of 11

jdkriek
Advisor
Advisor

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.


0 Likes
Message 7 of 11

jpchaisson
Advocate
Advocate
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?
0 Likes
Message 8 of 11

jdkriek
Advisor
Advisor

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.


0 Likes
Message 9 of 11

jdkriek
Advisor
Advisor
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.


0 Likes
Message 10 of 11

jpchaisson
Advocate
Advocate

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 #

0 Likes
Message 11 of 11

jdkriek
Advisor
Advisor
Accepted solution

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.