Change Design View Representation of Sub-Assembly in Assembly

Change Design View Representation of Sub-Assembly in Assembly

insomnix
Advocate Advocate
921 Views
2 Replies
Message 1 of 3

Change Design View Representation of Sub-Assembly in Assembly

insomnix
Advocate
Advocate

In the main assembly, there are some sub-assemblies with a design view rep. I would like to change the design view using iLogic. The below code will find my part, but instead of changing the design view, it errors. The "tan" view does exist in the sub assembly, so I'm not sure why it would error.

 

	Dim oDoc As AssemblyDocument = ThisDoc.Document
	Dim oCompDef As Inventor.ComponentDefinition = oDoc.ComponentDefinition
	Dim oCompOcc As Inventor.ComponentOccurrence

	For Each oCompOcc In oCompDef.Occurrences
		If oCompOcc.Name = "std drwr:1" Then
			Try
				oCompOcc.RepresentationsManager.DesignViewRepresentations.Item("tan").Activate
			Catch
				MessageBox.Show("This viewrep does not exist", "Error")
			End Try
		End If
	Next

It would also be nice to change the view without having to cycle trough every part in the main assembly. I haven't found a way to get a part by name and perform functions on that part unless it was in the limited list on the Component Functions Reference page. 

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

YuhanZhang
Autodesk
Autodesk
Accepted solution

Try if below updated code works or not:

 

Dim oDoc As AssemblyDocument = ThisDoc.Document
    Dim oCompDef As Inventor.ComponentDefinition = oDoc.ComponentDefinition
    Dim oCompOcc As Inventor.ComponentOccurrence

    For Each oCompOcc In oCompDef.Occurrences
        If oCompOcc.Name = "std drwr:1" Then
            Try
                oCompOcc.SetDesignViewRepresentation("tan",,True)
            Catch
                MessageBox.Show("This viewrep does not exist", "Error")
            End Try
        End If
    Next


If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes
Message 3 of 3

insomnix
Advocate
Advocate

Thank you, worked great.

0 Likes