AnswerHub Upload Issue
Our AnswerHub community currently has a bug that prevents you from attaching your model or other files to your questions. AnswerHub is aware of this issue and they are working on a fix. Until we receive their patch, you can upload your models and other files to FlexSim's file share site. Include the file name in your question so that we know which upload to reference.

question

Brijesh Kumar avatar image
0 Likes"
Brijesh Kumar asked Arun Kr answered

How to add colors in color pallet using code?

Hi FlexSim Support Team,

How to add colors in color pallet using code?

FlexSim 22.0.0
flexscriptby code
· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

You can find out how FlexSim does it manually. You explore the structure of adding colors to a pallet in the view structure. Here is question dealing with a similar request.

https://answers.flexsim.com/questions/44310/where-to-find-quick-propertie-functions-in-the-tre.html

1 Like 1 ·

1 Answer

·
Arun Kr avatar image
1 Like"
Arun Kr answered

Hi Brijesh,

Here's a model in which the code inside it looks into a global table for adding a new color into the color palette. The function_s commands were taken from the add color button execution codes. You can refer to those commands to further customize the script as per your requirements.

Table GT = Table("GlobalTable1");
treenode ColorPallet = Model.find("Tools/ColorPalettes/ColorPalette2")
for(int k=1;k<=GT.numRows;k++)
{

function_s(ColorPallet, "addNewColor");
treenode colorNode = function_s(ColorPallet, "getColorNode", k);
colorNode.value = GT[k][1];
treenode RValueNode = colorNode.subnodes[1];
RValueNode.value = GT[k][2];

treenode GValueNode = colorNode.subnodes[2];
GValueNode.value = GT[k][3];

treenode BValueNode = colorNode.subnodes[3];
BValueNode.value = GT[k][4];
}

Regards,

Arun KRColorPaletteCode.fsm


5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.