question

anon-user avatar image
0 Likes"
anon-user 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.

Joerg Vogel avatar image Joerg Vogel commented ·

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.