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.

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

Sunada C avatar image Sunada C commented ·

@Arun KR : How do we change the depth of the bay and also rotate it by 90 degree after doing this?.

0 Likes 0 ·