First to clarify something -- What do you mean by Assembly Group? Do you just mean Assembly? If so, assemblies are by definition a "group" of components, so there's no need to tack on an additional term -- it just causes confusion 🙂
Now, when you say "If view=Open"/"If view=Closed", I'm assuming by "view" you mean the View Rep of your top assembly, i.e. 900001_iLogic.iam? In other words, you are trying to drive the View Rep of your subassembly (400431.iam) based on the view rep of the parent assembly (900001_iLogic.iam)?
If so, the following code will do that:
Dim oDoc As AssemblyDocument = ThisDoc.Document
Dim oDef As ComponentDefinition = oDoc.ComponentDefinition
Dim oCompOcc As Inventor.ComponentOccurrence
oCurrentView = oDef.RepresentationsManager.ActiveDesignViewRepresentation.Name
For Each oCompOcc in oDef.Occurrences
oName = oCompOcc.Name
oName = Left(oName,InStr(oName,":")-1)
If oName = "400431" Then
If Not oCompOcc.ActiveDesignViewRepresentation = oCurrentView Then
Try
oCompOcc.SetDesignViewRepresentation(oCurrentView,, True)
Catch
FoundError = True
Continue For
End Try
End If
End If
Next
If FoundError = True Then
MessageBox.Show("One or more occurrences could not be set to the appropriate View Representation")
End If
Unfortunately, there's no way to set the rule to trigger when you change View Reps. What you could do, is modify the code to iterate through each of your parent assembly's View Reps and run the above code, which would essentially apply the appropriate sub-view-rep for each master View Rep. You could then set that up to run each time you save your assembly. I can add in that functionality if you want, or you can just manually run the above code for each of your master View Reps, and remember to do so any time you add a new occurrence of your subassembly.