Issue
"Is there an API to control Design View Representations? In the Model browser in assembly mode we see:
Representations
-->View
--> Private
--> default
--> view ...
Is there a way to get the current active view and other settings?
Solution
The Inventor API supports the manipulation to Design View Representations. Here is a code example:
VBA code
Public Sub test_VBA()
' get the current assembly
Dim doc As AssemblyDocument
Set doc = _
ThisApplication.ActiveDocument
' get AssemblyComponentDefinition
Dim AssemblyDef As AssemblyComponentDefinition
Set AssemblyDef = _
doc.ComponentDefinition
' get Manager of Representations
Dim dViewRepMgr As RepresentationsManager
Set dViewRepMgr = _
AssemblyDef.RepresentationsManager
' get active Representation view
Dim dViewRep As DesignViewRepresentation
Set dViewRep = _
dViewRepMgr.ActiveDesignViewRepresentationDebug.Print dViewRep.Name
' get the first Representation view
Set dViewRep = _
dViewRepMgr.DesignViewRepresentations.Item(1)
' activate the first view
dViewRep.Activate
' dump all Representations views
Dim dViewReps As DesignViewRepresentations
Set dViewReps = _
dViewRepMgr.DesignViewRepresentations
Debug.Print dViewReps.Count
For Each dViewRep In dViewReps
Debug.Print dViewRep.Name
Next dViewRep
End Sub
VB.NET code
Public Sub test_VBNet()
' assume we have had Inventor application
' _InvApplication
' get the current assembly
Dim doc As AssemblyDocument =
_InvApplication.ActiveDocument
' get AssemblyComponentDefinition
Dim AssemblyDef As AssemblyComponentDefinition =
doc.ComponentDefinition
' get Manager of Representations
Dim dViewRepMgr As RepresentationsManager =
AssemblyDef.RepresentationsManager
' get active Representation view
Dim dViewRep As DesignViewRepresentation =
dViewRepMgr.ActiveDesignViewRepresentation
Debug.Print(dViewRep.Name)
' get the first Representation view
dViewRep =
dViewRepMgr.DesignViewRepresentations.Item(1)
' activate the first view
dViewRep.Activate()
Dim dViewReps As DesignViewRepresentations =
dViewRepMgr.DesignViewRepresentations
Debug.Print(dViewReps.Count)
' dump all Representations views
For Each dViewRep In dViewReps
Debug.Print(dViewRep.Name)
Next dViewRep
End Sub