question

Chao Gao avatar image
0 Likes"
Chao Gao asked Sunada C commented

Automatically create rack

I would like to automatically create a bunch of rack objects, specify the number of bay, number of level, size of bay, size of level using code, I couldn't find a command to control these settings.

I am looking for something like

(for int i = 1; i <=100; i++)

{

treenode rack_obj = createinstance(library().find("/fixedresources/Rack"),model());

// setrackbaynum

// setrackbaywidth

//setracklevelnum

//setracklevelheight

}

Thanks

FlexSim 17.0.3
programmatic control
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

Arun Kr avatar image
1 Like"
Arun Kr answered Sunada C commented

Hi @Chao Gao,

I modified Mathew's code in the attached link and you can try the given below code.

  1. int number = 5;
  2. int yGridSize = 10;
  3. double xSpacing = 3;
  4. double ySpacing = 3;
  5. int numBays = 5;
  6. int numLevels = 5;
  7. double bayWidth =5;
  8. double levelHeight = 5;
  9. for(int i = 1; i <= number; i++) {
  10. Object obj = createinstance(library().find("?Rack"), model());
  11. function_s(node("/?Rack", library()), "BasicRefreshTable", obj,numBays, numLevels, bayWidth,levelHeight);
  12. obj.name = "Rack" + numtostring(i);
  13. obj.location.x = floor((i - 1) / yGridSize) * xSpacing + 1;
  14. obj.location.y = ((i - 1) % yGridSize + 1) * ySpacing;
  15. }
· 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.