How to set pos rep and view reps with iLogic

How to set pos rep and view reps with iLogic

karthur1
Mentor Mentor
938 Views
4 Replies
Message 1 of 5

How to set pos rep and view reps with iLogic

karthur1
Mentor
Mentor

In my assembly, I have several positional reps and view reps that need to be paired with each other.  For instance, when the positional rep "11th Bend" is active, I need to have "11th Bend" view rep also active.  I know how to set this up so I can use an iLogic form... only if I had a way to capture the current state of the view rep and positional rep.  I don't see a way to capture this, so the next step is the code that turns view view/pos reps on and off.  Done some searching and found the 

 

 

Here is the rule that I have, but it doesn't work. I get an error that says something like...."Member on found..."

 

'This rule determines which bend position and which part is visible

If Bend_Number = "11" Then
'make view rep named "11th Bend" active
'make the pos rep named "11th Bend" active

ThisApplication.ActiveDocument.ComponentDefinition.RepresentationsManager.PositionalRepresentations.Item("11th Bend").Activate

End If

 

 

Can someone tell me the line of code that will turn on/off the view reps and the positional reps?

 

Thanks

 

0 Likes
939 Views
4 Replies
Replies (4)
Message 2 of 5

MechMachineMan
Advisor
Advisor

 

That line should work just fine. I tested it, and it works good. 

 

Potential reasons it's failing:

- Typo in the call

- Pos rep name your are using in the call doesn't actually exist

- If the rule is being called by another rule, it could be trying to use the wrong document

- Maybe you are running it on a part document?

- The occasional error with ComponentDefinition not working properly, and needing to define AssemblyComponentDefinition explicitly.

 

ThisApplication.ActiveDocument.ComponentDefinition.RepresentationsManager.PositionalRepresentations("Left Side").Activate

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
Message 3 of 5

LukeDavenport
Collaborator
Collaborator

Hi,

I'd consider learning about the new 'capture current state' options in Inventor 2019 (if you have access to it) - it allows you to capture with one click any assembly configuration - component positions, colour overrides, visibility and more. It's a game changer - worth considering as a much simpler option.

 

Check out the first example in this video

 

https://www.youtube.com/watch?v=j17CwBbwpSw&t=

 

Hope it helps,

Luke

0 Likes
Message 4 of 5

karthur1
Mentor
Mentor

Came in this morning and after a fresh restart, code worked perfectly without any changes.... Go Figure.Smiley Embarassed

 

I ended up putting in another line to turn on/off the DesignViewResentations as well.  Works great now.

 

Thanks,

Kirk

 

If Bend_Number = "11" Then
'make view rep named "11th Bend" active
'make the pos rep named "11th Bend" active
ThisApplication.ActiveDocument.ComponentDefinition.RepresentationsManager.PositionalRepresentations.Item("11th Bend").Activate
ThisApplication.ActiveDocument.ComponentDefinition.RepresentationsManager.DesignViewRepresentations.Item("11th Bend").Activate
End If

0 Likes
Message 5 of 5

chandra.shekar.g
Autodesk Support
Autodesk Support

That's nice to hear that it is working.

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes