I have taken clone of Table1 in bundle datatype as Table2..
Now i want to change Table2 to Number datatype
I have taken clone of Table1 in bundle datatype as Table2..
Now i want to change Table2 to Number datatype
Hi @PVA, was one of Jason Lightfoot's or Carter Walch's answers helpful? If so, please click the "Accept" button at the bottom of the one that best answers your question. Or if you still have questions, add a comment and we'll continue the conversation.
If we haven't heard back from you within 3 business days we'll auto-accept an answer, but you can always comment back to reopen your question.
Hi @PVA ,
You can convert the table it to a treenode and then use the 'dataType' property of the treenode class.
See Jason's answer above for an updated solution.
treenode DataNode = Table("GlobalTable2").as(treenode); print(DataNode.dataType); // tests to see current data type DataNode.dataType = DATATYPE_NUMBER ; // set data type to Number print(DataNode.dataType); // test to confirm new datatype
The datatype macros can be found here
Note: changing the datatype to certain datatypes may change your table. To reset it, simply run the code to set back to the original datatype.
This post may also be helpful in testing the datatype of table nodes
Hi Carter,
Thank you for your answer. But it hasn't completely solved my problem. I'm trying to duplicate a bundle table and convert the datatype from bundle to integer. I'm attaching the model FYR.
Thank you.tabledatatypes.fsm
I'm assuming you want to change the individual table cells from arrays to numbers? (A bundle is a different data structure for the entire table)
For that you can either use Table.setSize() and overwrite the previous values. But this will also remove any row and column headers.
Alternatively you can loop through all cells and change their data type individually.
Table table2 = Table("GlobalTable2");
// This also resets headers table2.setSize(table2.numRows, table2.numCols, DATATYPE_NUMBER, 1); // Loop through cells instead for(int row = 1; row <= table2.numRows; row++) { for(int col = 1; col <= table2.numCols; col++) { table2.cell(row, col).dataType = DATATYPE_NUMBER; } }
You can't change a table (a structure of related data values stored as a bundle or nested treenodes) to a single number and retain the data.
When you have bundle data in a treenode table's cell, you can simply overwrite the cell data with a new variant:
Table("GlobalTable2").cell(2,1).value=6
If anyone finding this post wishes to toggle between treenode-based and bundle table types here's some updated code showing an example data node that is a cell within a global table (first line - this was the case in the orginal poster's model)
treenode data=Table("GlobalTable2").cell(4,1); //Global table data or other data node int isGlobalTable=classobject(data.up)==library().find("?GlobalTable"); treenode newData; if(getdatatype(data) != DATATYPE_BUNDLE) { newData = nodeinsertafter(data); nodeadddata(newData, DATATYPE_BUNDLE); } else if (isGlobalTable) //Copy from the library so we get our TableHeader node newData = createcopy(library().find("?GlobalTable>variables/data"), data.up); else { //just a node somewhere newData = nodeinsertafter(data); newData.value="<Treenode Table>"; // so a user can see the node contains table structure } data.as(Table).cloneTo(newData.as(Table)); createcopy(newData,data,1,0,0,1); // this preserves any pointers to the table that already existed in the model destroyobject(newData);
15 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