Model state + View in part

Model state + View in part

eladm
Collaborator Collaborator
5,014 Views
11 Replies
Message 1 of 12

Model state + View in part

eladm
Collaborator
Collaborator

Hi Inventor users

Before 2022 version at part file we were able to create a different color in each view representation.

At 2022 I can't create different color with each model state

for example at model state 1 - view 1 is red

model state 2 - view 2 blue color

I can't assign each model state different color

File without model state  behave normal

any suggestion?

regards

0 Likes
Accepted solutions (3)
5,015 Views
11 Replies
Replies (11)
Message 2 of 12

Waguespack_Curtis
Contributor
Contributor

--

0 Likes
Message 3 of 12

Curtis_Waguespack
Consultant
Consultant

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

 

 

 
Message 4 of 12

johnsonshiue
Community Manager
Community Manager

Hi Curtis,

 

I took a quick look. I am getting an error complaining about changing document type when activating a Design View Rep. This does not make sense. It sounds like an API bug to me. Let me work with the project team and understand the issue better.

Many thanks!



Johnson Shiue ([email protected])
Software Test Engineer
Message 5 of 12

MjDeck
Autodesk
Autodesk

@johnsonshiue , there is at least one API defect. But you can work around it by adding the line:

Exit For

right after the line

Logger.Info("View Rep: " & oViewRep.Name)

near the end of the rule. That will exit the For loop after activating the view rep. There's no need to look at the other view reps after that.

@Curtis_Waguespack , to make the part change color, you can right-click on the solid body and assign a color in Properties). That is associated with the view rep. (If there were more than one solid body, you might have to assign the same color to all).


Mike Deck
Software Developer
Autodesk, Inc.

Message 6 of 12

JaneFan
Autodesk
Autodesk
Accepted solution

Apperance is controled by view representation by default, so that model state doesn't capture it automaticaly to avoide conflict. Actually there is a way to add appearance in model state table manually if you want, here is how to do it: 

Add a column in model state table and set title name to: Appearance<style></style>

And then set different color for each model state in table and save the table. Then it would work as you expect. Here is what the table looks like: 

msTable.PNG




Jane Fan
Inventor/Fusion QA Engineer
Message 7 of 12

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Hi @eladm 

 

So just to clarify, or for those in the future that might find this, JaneFan's solution works well. But it wasn't clear to me where we were supposed to setup that column at first.  Here are the steps to get this to work.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

 

Right click on the Model States folder node in the browser, and choose Edit via Spreadsheet

Curtis_W_0-1621344475804.png

 

Type Appearance<style></style> into the cell at B1 (or just copy and paste it from here)

 

I'd just set them all to Default to start with, just because it's easy and avoids spelling errors and needing to know the exact names of all the colors

 

then close/save the spread sheet

 

Curtis_W_5-1621345389373.png

 

Now you can set each model state color/appearance as expected from the Appearance pull down menu.

 

Curtis_W_6-1621345616601.png

 

 

 

 

 

Message 8 of 12

Curtis_Waguespack
Consultant
Consultant
Accepted solution
0 Likes
Message 9 of 12

eladm
Collaborator
Collaborator

Hi

It works

Yo must write default ? 

It doesn't work if I wrote the name of the view insetad.

Thx

0 Likes
Message 10 of 12

matthias.duve257HN
Participant
Participant

Hi, as this is not the way it´s "supposed" to work, are there any issues known with this workaround? Do I have to fear any loss of data if I implement this for a wider range of parts? Or better to say, has anyone experienced problems with this? Thanks a lot everyone 😎

0 Likes
Message 11 of 12

clutsa
Collaborator
Collaborator

@JaneFan wrote:

Apperance is controled by view representation by default, so that model state doesn't capture it automaticaly to avoide conflict. Actually there is a way to add appearance in model state table manually if you want, here is how to do it: 

Add a column in model state table and set title name to: Appearance<style></style>

And then set different color for each model state in table and save the table. Then it would work as you expect. Here is what the table looks like: 

msTable.PNG


@JaneFan 

Very cool workaround! I have two solid bodies in my part, is there a way to have an appearance column for each body? I tried "Solid1:Appearance<style></style>" but that didn't appear to do anything.

If I've helped you, please help me by supporting this idea.
Mass Override for Each Model State

Custom Glyph Icon for iMates

0 Likes
Message 12 of 12

johnsonshiue
Community Manager
Community Manager

Hi! Unfortunately no. The Appearance column in iPart/Model State table applies to the entire part, not one body.

I think you will need to use @Curtis_Waguespack's iLogic rule.

Many thanks!



Johnson Shiue ([email protected])
Software Test Engineer
0 Likes