Change Object Color using process flow

Change Object Color using process flow

shanice_c
Not applicable
345 Views
5 Replies
Message 1 of 6

Change Object Color using process flow

shanice_c
Not applicable

[ FlexSim 20.0.10 ]

Hi, how to not let all token flowing together, I have put several processors into a Group, and I've used match value to match token and 3D object. I'm using process flow Change Visual activity to change Processor color when on entry event, I want it to change back to its original color in on exit event. Thank you.

ChangeColor.fsm

0 Likes
Accepted solutions (1)
346 Views
5 Replies
Replies (5)
Message 2 of 6

Matthew_Gillespie
Autodesk
Autodesk
Accepted solution

You are using an Object process flow that is attached to all the processors so you don't need to acquire a processor from the group or listen to events on the whole group or even match anything in the wait for event activities. Since you're using an Object flow a new instance of the flow is created for each processor attached and so you'll end up with one token per processor and you can simply refer to the attached processor using current. So I removed all the unnecessary activities and replaced all the references to token.EQ with current.

Secondly, your model has an issue where if you reset the model while the object has its color changed then the object will permanently be the new color. To avoid this I added the originalColor label to the processor and added an OnReset trigger to the processors to restore the object's color from the originalColor label.

changecolor_working.fsm



Matthew Gillespie
FlexSim Software Developer

0 Likes
Message 3 of 6

shanice_c
Not applicable

Hi,@Matthew Gillespie May I ask how do you get originalColor value in the label for the first time?

1633229763591.png

I set label first in order to get that value.1633229891205.png

But in your attached model, I couldn't find how to get the rbga. I'm not sure if it's redundant to do this?

0 Likes
Message 4 of 6

joerg_vogel_HsH
Mentor
Mentor

Try just current.color to get an array of values.

If this doesn’t work for you may get access by method getProperty.
Please look into the tree. If the structure seems to be a container with subnodes, you can make them to an array by method.

flexscript-class-treenode.png
Naturally current is replaced by a reference to the color container node.

0 Likes
Message 5 of 6

Matthew_Gillespie
Autodesk
Autodesk

@Fiona C

I opened the script window and ran some code like this to store the object's color on a label:

Object processor = Model.find("Processor1");
processor.originalColor = processor.color.as(Array);

You don't want to set the label in On Reset. If you do that you're going to override the object's original color with its current color, which defeats the purpose of storing off the object's original color in the first place.

Think about this situation:

  1. You run the model until the processor changes to lime green.
  2. You reset the model. (The processor is still lime green)
  3. In On Reset you take processor's current color (lime green) and store that on the processor's originalColor label.

The originalColor label is now lime green and the processor will never change to any other color.



Matthew Gillespie
FlexSim Software Developer

Message 6 of 6

shanice_c
Not applicable
@Matthew Gillespie Thanks for your detailed explanation. I could understand how this works.
0 Likes