How do i target a specific sketch symbol within a view and control it with iLogic?
Solved! Go to Solution.
Solved by jdkriek. Go to Solution.
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
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,,,)
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
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 #
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)