Hi @eladm
See this link for an explanation from johnsonshiue of what is/is not possible with colors and Model States.
https://forums.autodesk.com/t5/inventor-forum/model-state-inventor-2022/m-p/10282584#M826399
@johnsonshiue Can you have a look at the model I've attached here? I have set up a rule to link the ModelStates and ViewReps... the rule runs when a ModelState is activated... but I can't see a way to have each view rep a different color.
Can you help us understand what is happening here? thanks
(Code for reference, in case in helps someone find this in the future)
Dim oDoc As PartDocument
oDoc = ThisApplication.ActiveDocument
Dim oDef As PartComponentDefinition
oDef = oDoc.ComponentDefinition
'define view rep
Dim oViewRep As DesignViewRepresentation
'define view rep collection
Dim oViewReps As DesignViewRepresentations
oViewReps = oDef.RepresentationsManager.DesignViewRepresentations
'define an arraylist to hold the list of view rep names
Dim NameList As New ArrayList()
'Look at the view reps
For Each oViewRep In oViewReps
'set the list of names to the array list
NameList.Add(oViewRep.Name)
Next
Dim oStates As ModelStates
oStates = oDef.ModelStates
Dim oTable As ModelStateTable
oTable = oStates.ModelStateTable
' Iterate All Rows of model states
i = 1
Dim oState As ModelState
For Each oState In oStates
'this activates the row to make it the current state
oModelStateName = oStates.Item(i).Name
If Not NameList.Contains(oModelStateName) Then
oViewRep = oViewReps.Add(oModelStateName)
Logger.Info("new model state: " & oModelStateName)
End If
i=i+1
Next 'model state
oModelStateName = oStates.ActiveModelState.Name
For Each oViewRep In oViewReps
If oViewRep.Name = oModelStateName
oViewReps.Item(oModelStateName).Activate
Logger.Info("View Rep: " & oViewRep.Name)
End If
Next 'view rep