iAssembly to control representations in members

iAssembly to control representations in members

mikko.m
Advocate Advocate
543 Views
3 Replies
Message 1 of 4

iAssembly to control representations in members

mikko.m
Advocate
Advocate

I found this VB-code. How to edit this code so it would work in top-level iAssembly? I got the test model Casey provided to work but there the iAssembly is in sub-level.

_____________________________________________________________________________________
Inventor Professional 2019.3
Vault Workgroup 2019.1.1
0 Likes
544 Views
3 Replies
Replies (3)
Message 2 of 4

JaneFan
Autodesk
Autodesk

Hello @mikko.m

 

Please activate the design view of top level assembly in this way: 

Dim doc As AssemblyDocument
Set doc = ThisApplication.ActiveDocument
Call doc.ComponentDefinition.RepresentationsManager.DesignViewRepresentations.Item("View1").Activate




Jane Fan
Inventor/Fusion QA Engineer
0 Likes
Message 3 of 4

mikko.m
Advocate
Advocate

@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
0 Likes
Message 4 of 4

mikko.m
Advocate
Advocate

Could this be done with iLogic?

_____________________________________________________________________________________
Inventor Professional 2019.3
Vault Workgroup 2019.1.1
0 Likes