@JaneFan
Where it should be inserted so it would change different views to members?
member-1 -> view1
member-2 -> view2
Option Explicit
Private WithEvents oAssemblyEvents As AssemblyEvents
Public Sub init()
Set oAssemblyEvents = ThisApplication.AssemblyEvents
End Sub
Public Sub terminate()
Set oAssemblyEvents = Nothing
End Sub
Private Sub oAssemblyEvents_OnOccurrenceChange(ByVal DocumentObject As AssemblyDocument, ByVal Occurrence As ComponentOccurrence, ByVal BeforeOrAfter As EventTimingEnum, ByVal Context As NameValueMap, HandlingCode As HandlingCodeEnum)
' My Assembly only has one occurrence of the iAssembly
Dim oAssemblyOcc As ComponentOccurrence
Set oAssemblyOcc = DocumentObject.ComponentDefinition.Occurrences(1)
If BeforeOrAfter = kAfter Then
' Check to see if we have an iAssemblyFactory
If oAssemblyOcc.IsiAssemblyMember Then
' Choose the DVR based on the name of the iAssembly Member
Select Case oAssemblyOcc.Definition.iAssemblyMember.Row.MemberName
Case "member-1"
' Check to make sure we do not set the DVR if it is already what we want, to avoid an infinite loop
If StrComp(oAssemblyOcc.ActiveDesignViewRepresentation, "View1") <> 0 Then
oAssemblyOcc.SetDesignViewRepresentation "View1", , True
End If
Case "member-2"
If StrComp(oAssemblyOcc.ActiveDesignViewRepresentation, "View2") <> 0 Then
oAssemblyOcc.SetDesignViewRepresentation "View2", , True
End If
End Select
End If
End If
End Sub
_____________________________________________________________________________________
Inventor Professional 2019.3
Vault Workgroup 2019.1.1