Are you using ETO? You mention iLogic and VB, but this is an ETO forum. Given the context of your post I took a look at this from an VB (Inventor API) perspective.
What you are trying to do is possible, using the Inventor API. You need to listen for the AssemblyEvents.OccurrenceChange event. Your event handler code could then check to see what changed, and set the DVR accordingly, using SetDesignViewRepresentation. You would need to be sure to put a check in the event handler code to make sure you do not set the DVR if it is already what you want, because SetDesignViewRepresentation also triggers the OccurrenceChange event.
Here is a quick and dirty example. Take it for what it is worth. The Event Handler code would need to be in its own class module:
Class module: myEventListener
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 "Assembly1-01"
' 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, "purple") <> 0 Then
oAssemblyOcc.SetDesignViewRepresentation "purple", , True
End If
Case "Assembly1-02"
If StrComp(oAssemblyOcc.ActiveDesignViewRepresentation, "gold") <> 0 Then
oAssemblyOcc.SetDesignViewRepresentation "gold", , True
End If
Case "Assembly1-03"
If StrComp(oAssemblyOcc.ActiveDesignViewRepresentation, "Default") <> 0 Then
oAssemblyOcc.SetDesignViewRepresentation "Default", , True
End If
End Select
End If
End If
End Sub
This code belongs in the ApplicationProject module, and it starts and stops my event listener:
Option Explicit
Dim oEventListener As myEventListener
Sub Listen()
Set oEventListener = New myEventListener
oEventListener.init
End Sub
Sub StopListening()
oEventListener.terminate
Set oEventListener = Nothing
End Sub
I also added the model files that I was testing with. You should be able to:
1. Open Assembly2.iam
2. Hit Alt-F11 to open the VBA IDE
3. Add a new class module to the ApplicationProject named myEventListener, and paste in the code.
4. Paste in the ApplicationProject module code
5. Put your cursor inside the Listen() routine and hit F5
6. Back in Inventor, expand the sub assembly, right click the Table, and change the PartNumber value.
You should see the color of one of the blocks change. This is controlled by the DVR in the sub assembly.
Regards,
-Casey