Get the assosiative design view rep of an occurrence.

Get the assosiative design view rep of an occurrence.

NickSycamore
Participant Participant
87 Views
2 Replies
Message 1 of 3

Get the assosiative design view rep of an occurrence.

NickSycamore
Participant
Participant

Hi,

 

I have an ilogic rule that exports a step file for each document in the top level of an assembly. An issue I am having is the rule exports the document with the view rep it was last saved with instead of the view rep that's active in the top level export assembly. 

 

The ComponentOccurrence object has an "IsAssociativeToDesignViewRepresentation" boolean property but I can not figure out how to get the name of the view rep that is associated. 

 

Is there a way to get the name of the occurrence's view rep from the API?

 

Thanks

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

Andrii_Humeniuk
Advisor
Advisor
Accepted solution

Hi @NickSycamore .

In order to get the current DesignViewRepresentation for a ComponentOccurrence, you need to use the ActiveDesignViewRepresentation property, then compare the result with the active DesignViewRepresentation in the main assembly, and if the result is negative, try to set the desired view. Try using the part (line 8-13) from the example for your code.

Dim oInvApp As Inventor.Application = ThisApplication
Dim oADoc As AssemblyDocument = TryCast(oInvApp.ActiveDocument, AssemblyDocument)
If oADoc Is Nothing Then Exit Sub
Dim oOcc As ComponentOccurrence
oOcc = oInvApp.CommandManager.Pick(SelectionFilterEnum.kAssemblyOccurrenceFilter, "Select Component...")
If oOcc Is Nothing Then Exit Sub
If Not oOcc.DefinitionDocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then Exit Sub
Dim oADef As AssemblyComponentDefinition = oADoc.ComponentDefinition
Dim oDVR As DesignViewRepresentation = oADef.RepresentationsManager.ActiveDesignViewRepresentation
Dim sNameDVR As String = oDVR.Name
If Not sNameDVR = oOcc.ActiveDesignViewRepresentation Then
	Try : oOcc.SetDesignViewRepresentation(sNameDVR, , True) : Catch : End Try
End If

Andrii Humeniuk - CAD Coordinator, Autodesk Certified Instructor

LinkedIn | My free Inventor Addin | My Repositories

Did you find this reply helpful ? If so please use the Accept as Solution/Like.

EESignature

0 Likes
Message 3 of 3

NickSycamore
Participant
Participant

Thanks @Andrii_Humeniuk  That works great. That property isn't listed in the 2024 documentation but it still works for 2024.

0 Likes