question

Joe K2 avatar image
0 Likes"
Joe K2 asked Joe K2 commented

import floworks product table from spreadsheet

Hi, I have 40+ product recipes I would like to import to a FloWorks product table. Could I import recipes from a spreadsheet?

I assume I will have to use custom code with the spreadsheet import tool. I am not sure how to create the nodes for the FloWorks product table.

I have two simplifying assumptions:

  • Every recipe uses the same three ingredients in different proportions (imagine each recipe is a "blend")
  • Mixing steps do not change between recipes

Would this be easier as a spreadsheet import to a global table instead of a product table?

Thanks for all the help!

FlexSim 22.2.2
FloWorks
5 |100000

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

1 Answer

Patrick Zweekhorst avatar image
1 Like"
Patrick Zweekhorst answered Joe K2 commented

Hi @Joe K2 ,

You can use some code for this. This can be a user command that you call at some point, or you can add this code in your Excel import. I would first make sure that your first product is set up correctly. With the correct number of ingredients and steps. When you have done that, you can make copies of this node and change the values that need to be changed. To do that I would use something like the script below:


treenode productsNode = Model.find("Tools/GlobalNodes/FloWorks/Products");
treenode product1Node = productsNode.subnodes[1];
while( productsNode.subnodes.length > 1 )
{
    productsNode.subnodes[2].destroy();
}


int nrProducts = 40;
for( int i = 2; i <= nrProducts; i++ )
{
    treenode newProductNode = createcopy( product1Node, productsNode );
    newProductNode.name = "Product" + i;
    treenode ingredientsNode = newProductNode.find("/Recipe/1/Ingredients");
    
    treenode ingredient1 = ingredientsNode.subnodes[1];
    ingredient1.subnodes[ "Product" ].value = 1; //Product number value
    ingredient1.subnodes[ "Amount" ].value = 100; 
    
    treenode ingredient2 = ingredientsNode.subnodes[2];
    ingredient2.subnodes[ "Product" ].value = 1; //Product number value
    ingredient2.subnodes[ "Amount" ].value = 100; 
    
    treenode ingredient3 = ingredientsNode.subnodes[3];
    ingredient3.subnodes[ "Product" ].value = 1; //Product number value
    ingredient3.subnodes[ "Amount" ].value = 100; 
}

Does this help you further?

· 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.

Joe K2 avatar image Joe K2 commented ·
Thanks @Patrick Zweekhorst! This is very helpful
0 Likes 0 ·