vba to change view

vba to change view

eyalad
Explorer Explorer
1,160 Views
2 Replies
Message 1 of 3

vba to change view

eyalad
Explorer
Explorer

Hello,

 

i'm trying to change the current view using vba.

with the user inreface i can just right click the view name (master,front,View1 ect.) and select activate.

 

thank you 

0 Likes
Accepted solutions (1)
1,161 Views
2 Replies
Replies (2)
Message 2 of 3

Sergio.D.Suárez
Mentor
Mentor
Accepted solution

Hi, with this VBA code you could change the design view representation, through the item number (the number highlighted in red)

 

Sub ChangeDVR()
    Dim oDoc As Document
    Set oDoc = ThisApplication.ActiveDocument
    Dim oDef As ComponentDefinition
    Set oDef = oDoc.ComponentDefinition
    oDef.RepresentationsManager.DesignViewRepresentations(2).Activate
End Sub

You could also use an ilogic rule as I will show you below

Dim oDoc As AssemblyDocument = ThisDoc.Document  
Dim oDef As AssemblyComponentDefinition = oDoc.ComponentDefinition 

Dim oList As New ArrayList

For Each oDVR As Inventor.DesignViewRepresentation In oDef.RepresentationsManager.DesignViewRepresentations
	oList.Add(oDVR.Name)
Next

Dim oDVRName As String = InputListBox("Select DesignViewRep", oList, oList(0), "Change DVR", "Available Selections")
On Error Resume Next
oDef.RepresentationsManager.DesignViewRepresentations(oDVRName).Activate

 I hope this helps with your problem. Cheers!


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

0 Likes
Message 3 of 3

eyalad
Explorer
Explorer

Thank you very much

0 Likes