How can I most easily multiply the values of two global tables in a new table?
1/ when dimensions of both tables are the same.
2/ when a table has many rows but only 1 has to be multiplied with another table with 1 row.
Thanks in advance!
How can I most easily multiply the values of two global tables in a new table?
1/ when dimensions of both tables are the same.
2/ when a table has many rows but only 1 has to be multiplied with another table with 1 row.
Thanks in advance!
Here is a script you can run:
treenode table1 = reftable("GlobalTable1"); treenode table2 = reftable("GlobalTable2"); treenode table3 = reftable("GlobalTable3"); for(int i = 1; i <= gettablerows(table1); i++){ for(int j = 1; j <= gettablecols(table1); j++){ int value = gettablenum(table1, i, j) * gettablenum(table2, i, j); settablenum(table3, i, j, value); } }
If you only want to do the first row change i <= gettablerows(table1) to i <= 1.
If you upgrade to 17.0 you can use dot syntax:
Table table1 = reftable("GlobalTable1"); Table table2 = reftable("GlobalTable2"); Table table3 = reftable("GlobalTable3"); for(int i = 1; i <= table1.numRows; i++){ for(int j = 1; j <= table1.numCols; j++){ table3[i][j] = table1[i][j] * table2[i][j]; } }
Is it possible to run the script automatically everytime I run the model?
You could put the code in an OnReset or OnRunStart trigger (Toolbox >Add > Modelling Logic > Model Trigger)
7 People are following this question.
FlexSim can help you understand and improve any system or process. Transform your existing data into accurate predictions.
FlexSim is a fully 3D simulation software environment. FlexSim can be used to simulate any process in any industry.
FlexSim®, FlexSim Healthcare™, Problem Solved.®, the FlexSim logo, the FlexSim X-mark, and the FlexSim Healthcare logo with stylized Caduceus mark are trademarks of FlexSim Software Products, Inc. All rights reserved.
Privacy | Do not sell or share my personal information | Cookie preferences | Report noncompliance | Terms of use | Legal | © Autodesk Inc. All rights reserved