question

Matthew Gillespie avatar image
0 Likes"
Matthew Gillespie asked Cliff King answered

HC Resource Groups - How to stack members on top of each other

I have a gurney Transport Group that has a lot of members and the gurneys are arranged in a huge line such that staff are walking really far to get some of the gurneys. I would prefer to have all the gurneys in one spot (occupying the same space).

FlexSim HC 5.1.0
flexsim hcresource groupresource offsets
5 |100000

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

Matthew Gillespie avatar image
0 Likes"
Matthew Gillespie answered Matthew Gillespie commented

The following code will set the offsets of all the group members such that they're all on top of each other, just change the name of the group to match the group you want to adjust:

  1. treenode group = Gurneys;
  2.  
  3. for(int j = 1; j <= nrop(group); j++)
  4. {
  5. treenode member = outobject(group, j);
  6. setvarnum(member, "XOffset", -(xsize(member) + 0.1) * (j - 1));
  7. setvarnum(member, "YOffset", 0);
  8. set(spatialsx(group), xsize(member) + 0.1);
  9. setvarnum(group, "FloorLength", xsize(member) + 0.1);
  10. }
  11. reset();

gurneys.gif (252.2 KiB)
· 4
5 |100000

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

Patrick Cloutier avatar image Patrick Cloutier commented ·

In that same spirit, is there an option to layout the gurneys kinda like we do with the waiting room layout?

Thanks,

0 Likes 0 ·
Matthew Gillespie avatar image Matthew Gillespie ♦♦ Patrick Cloutier commented ·

You can drag the individual gurneys to where you want them and that sets their offset x and y values from the group object.

1 Like 1 ·
Patrick Cloutier avatar image Patrick Cloutier Matthew Gillespie ♦♦ commented ·

Yes that works great. I feel pretty stupid. Thanks.

0 Likes 0 ·
Show more comments
Cliff King avatar image
0 Likes"
Cliff King answered

I just realized my script needed some rework in order to work for staff, equipment and transport groups, so here's the updated script:

  1. // Specify the name of resource group for which you want to arrange its members
  2. treenode group = Gurneys;
  3. // Specify the grid pattern for resource placement (number of rows and columns in grid)
  4. int numRows = 6; // the number of resources along the group's x-axis (i.e. rows)
  5. int numCols = 4; // the number of resources along the group's y-axis (i.e. columns)
  6. // Specify the spacing around each resource member
  7. double paddingX = 0.2; // spacing in the x direction
  8. double paddingY = 0.2; // spacing in the y direction
  9.  
  10.  
  11. int objType = 1;
  12. if(getobjecttype(group) == OBJECT_StaffGroup)
  13. objType = 2;
  14.  
  15.  
  16. // Compare the number of grid spots with the total number of members in the group,
  17. // and display any errors or warning accordingly.
  18. int totSpots = numRows * numCols;
  19. int totMembers = nrop(group);
  20. if(totSpots > totMembers)
  21. {
  22. msg("Error", "The numRows * numCols is greater than the total number of members in the group", 1);
  23. return 0;
  24. }
  25. else if(totSpots < totMembers)
  26. {
  27. msg("Warning", "The numRows * numCols is less than the total number of members in the group. Extra members will be placed in the first/last spot.", 1);
  28. }
  29.  
  30.  
  31.  
  32.  
  33. // Set up local variables for the grid placement code below
  34. treenode curMember = outobject(group,1);
  35. double sizeX = xsize(curMember); // the xsize of the first member in group will be the assumed xsize of all members
  36. double sizeY = ysize(curMember); // the ysize of the first member in group will be the assumed ysize of all members
  37. double groupX = ((sizeX + paddingX) * numRows) - paddingX;
  38. double groupY = ((sizeY + paddingY) * numCols) - paddingY;
  39. double curX = 0;
  40. double curY = 0;
  41.  
  42.  
  43.  
  44.  
  45. // Set the size of the group object and its floor based on assumed x,y size of members and the desired grid pattern
  46. set(spatialsx(group), groupX);
  47. set(spatialsy(group), groupY);
  48. setvarnum(group, "FloorLength", groupX + 2*paddingX);
  49. setvarnum(group, "FloorWidth", groupY + 2*paddingY);
  50. setvarnum(group, "FloorX", -paddingX);
  51. setvarnum(group, "FloorY", paddingY);
  52. int totCount = 1;
  53.  
  54.  
  55.  
  56.  
  57. // Nested for-loop for setting the appropriate X,Y offsets of each member
  58. for(int col = 1; col <= numCols; col++)
  59. {
  60. for(int row = 1; row <= numRows; row++)
  61. {
  62. if(objType == 1)
  63. {
  64. curX = (row-1) * (sizeX + paddingX);
  65. curY = (col-1) * (sizeY + paddingY) - 0.5*groupY + 0.5*sizeY;
  66. setvarnum(curMember, "XOffset", curX - (sizeX + 0.1) * (totCount - 1) - 0.1);
  67. setvarnum(curMember, "YOffset", curY);
  68. }
  69. else
  70. {
  71. curX = (row-1) * (sizeX + paddingX);
  72. curY = (col-1) * (-sizeY - paddingY);
  73. setvarnum(curMember, "XOffset", curX - 0.05);
  74. setvarnum(curMember, "YOffset", curY + sizeY * (totCount - 1) + 0.05);
  75. }
  76. totCount++;
  77. curMember = outobject(group,totCount);
  78. }
  79. }
  80.  
  81.  
  82.  
  83.  
  84. // A while-loop for setting the X,Y offset of any additional members to that of the last member in the grid
  85. while(objectexists(curMember))
  86. {
  87. if(objType == 1)
  88. {
  89. setvarnum(curMember, "XOffset", curX - (sizeX + 0.1) * (totCount - 1) - 0.1);
  90. setvarnum(curMember, "YOffset", curY);
  91. }
  92. else
  93. {
  94. setvarnum(curMember, "XOffset", curX - 0.05);
  95. setvarnum(curMember, "YOffset", curY + sizeY * (totCount - 1) + 0.05);
  96. }
  97.  
  98.  
  99. totCount++;
  100. curMember = outobject(group,totCount);
  101. }
  102.  
  103.  
  104.  
  105.  
  106. // Reset the model in order to update the locations of the members based on the previously defined X,Y offsets
  107. reset();
5 |100000

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

Cliff King avatar image
0 Likes"
Cliff King answered

I modified Matthew's script to arrange the resource members of a group into any x,y grid pattern you may want. Here's an example of automatically arranging the 24 gurneys of a group into a 6 X 4 grid pattern with a gap of 0.2 meters around each of the gurneys.

Here's the script:

  1. // Specify the name of resource group for which you want to arrange its members
  2. treenode group = Gurneys;
  3. // Specify the grid pattern for resource placement (number of rows and columns in grid)
  4. int numRows = 6; // the number of resources along the group's x-axis (i.e. rows)
  5. int numCols = 4; // the number of resources along the group's y-axis (i.e. columns)
  6. // Specify the spacing around each resource member
  7. double paddingX = 0.2; // spacing in the x direction
  8. double paddingY = 0.2; // spacing in the y direction
  9.  
  10.  
  11. // Compare the number of grid spots with the total number of members in the group,
  12. // and display any errors or warning accordingly.
  13. int totSpots = numRows * numCols;
  14. int totMembers = nrop(group);
  15. if(totSpots > totMembers)
  16. {
  17. msg("Error", "The numRows * numCols is greater than the total number of members in the group", 1);
  18. return 0;
  19. }
  20. else if(totSpots < totMembers)
  21. {
  22. msg("Warning", "The numRows * numCols is less than the total number of members in the group. Extra members will be placed in first spot.", 1);
  23. }
  24.  
  25.  
  26. // Set up local variables for the grid placement code below
  27. treenode curMember = outobject(group,1);
  28. double sizeX = xsize(curMember); // the xsize of the first member in group will be the assumed xsize of all members
  29. double sizeY = ysize(curMember); // the ysize of the first member in group will be the assumed ysize of all members
  30. double groupX = ((sizeX + paddingX) * numRows) - paddingX;
  31. double groupY = ((sizeY + paddingY) * numCols) - paddingY;
  32. double curX = 0;
  33. double curY = 0;
  34.  
  35.  
  36. // Set the size of the group object and its floor based on assumed x,y size of members and the desired grid pattern
  37. set(spatialsx(group), groupX);
  38. set(spatialsy(group), groupY);
  39. setvarnum(group, "FloorLength", groupX + 2*paddingX);
  40. setvarnum(group, "FloorWidth", groupY + 2*paddingY);
  41. setvarnum(group, "FloorX", -paddingX);
  42. setvarnum(group, "FloorY", paddingY);
  43. int totCount = 1;
  44.  
  45.  
  46. // Nested for-loop for setting the appropriate X,Y offsets of each member
  47. for(int col = 1; col <= numCols; col++)
  48. {
  49. for(int row = 1; row <= numRows; row++)
  50. {
  51. curX = (row-1) * (sizeX + paddingX);
  52. curY = (col-1) * (sizeY + paddingY) - 0.5*groupY + 0.5*sizeY;
  53. setvarnum(curMember, "XOffset", curX - (sizeX + 0.1) * (totCount - 1) - 0.1);
  54. setvarnum(curMember, "YOffset", curY);
  55. totCount++;
  56. curMember = outobject(group,totCount);
  57. }
  58. }
  59.  
  60.  
  61. // A while-loop for setting the X,Y offset of any additional members to that of the last member in the grid
  62. while(objectexists(curMember))
  63. {
  64. setvarnum(curMember, "XOffset", curX - (sizeX + 0.1) * (totCount - 1) - 0.1);
  65. setvarnum(curMember, "YOffset", curY);
  66. totCount++;
  67. curMember = outobject(group,totCount);
  68. }
  69.  
  70.  
  71. // Reset the model in order to update the locations of the members based on the previously defined X,Y offsets
  72. reset();

5 |100000

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