Switch to next representation

<?xml encoding=”UTF-8″>By Adam Nagy

I’m not aware of a way in the UI to switch to the next possible representation (e.g. positional representation) using a shortcut. However, you can assign a shortcut to a VBA macro which could do the switching.

Here is a code that switches to the next positional representation of the assembly:

Sub ActivateNextPositionalRepresentation()
Dim doc As AssemblyDocument
Set doc = ThisApplication.ActiveDocument
Dim rm As RepresentationsManager
Set rm = doc.ComponentDefinition.RepresentationsManager
Dim prs As PositionalRepresentations
Set prs = rm.PositionalRepresentations
Dim index As Integer
For index = 1 To prs.Count
If rm.ActivePositionalRepresentation Is prs(index) _
Then Exit For
Next
index = index Mod prs.Count + 1
Call prs(index).Activate
End Sub

Comments

One response to “Switch to next representation”

  1. I understand this toggles posrep in the main/top assembly, would you mind translating this code to adapt to first or second sub assemblies and specific to the string name of the posrep..is that possible?

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading