question

Andr%C3%A9 Bongers avatar image
0 Likes"
Andr%C3%A9 Bongers asked Regan Blackett edited

Multiprocessor onprocessfinish trigger per each prcoess

Hi all,

I have a Multiprocessor that shoudl execute five processes. After each Process the 3DShape of the Item should change. So I set four "Change 3DShape" Trigger on Processfinish. But only after finishing the first Process the Shape gets changed to the last of the four shapes I set. After the second, thirs, fourth and fith process nothing changes.

I think I have to tell each trigger after which process step they should be executed but unfortunatly I don't know how. Could you giev me some advice?

This is the Basic Code I got for the first two shape changes. Can you tell me how to modify each change so that it gets related to the Process?

  1. treenode item = param(1);
  2. treenode current = ownerobject(c);
  3. int opnum = param(2);
  4. { // ************* PickOption Start ************* //
  5. /***popup:Change3DShape*/
  6. /**Change 3D Shape*/
  7. treenode involved = /** \nObject: *//***tag:object*//**/item/**/;
  8. string shapename = /** \nShape: *//***tag:shapepath*//**/"fs3d\\FlowItem\\Frame.3ds"/**/;
  9.  
  10. double theindex = getshapeindex(shapename);
  11.  
  12. //Grab the current size of the object
  13. double x = xsize(involved);
  14. double y = ysize(involved);
  15. double z = zsize(involved);
  16.  
  17. setname(shape(involved),"_shape");
  18. setobjectshapeindex(involved,theindex);
  19.  
  20. //Update the object to the original size
  21. applyshapefactors(involved);
  22. setsize(involved, x, y, z);
  23. /** \nNote: The getshapeindex command is slow if it is called frequently.
  24. It is better to define the shape index in a global variable that gets set
  25. during reset. You can then replace getshapeindex with the name of your global variable.
  26. Index values for 3D shapes can be found through the Tools>Media Files menu,
  27. but keep in mind that index values can change when new media is loaded.*/
  28. } // ******* PickOption End ******* //
  29. { // ************* PickOption Start ************* //
  30. /***popup:Change3DShape*/
  31. /**Change 3D Shape*/
  32. treenode involved = /** \nObject: *//***tag:object*//**/item/**/;
  33. string shapename = /** \nShape: *//***tag:shapepath*//**/"fs3d\\FlowItem\\Tote.3ds"/**/;
  34.  
  35. double theindex = getshapeindex(shapename);
  36.  
  37. //Grab the current size of the object
  38. double x = xsize(involved);
  39. double y = ysize(involved);
  40. double z = zsize(involved);
  41.  
  42. setname(shape(involved),"_shape");
  43. setobjectshapeindex(involved,theindex);
  44.  
  45. //Update the object to the original size
  46. applyshapefactors(involved);
  47. setsize(involved, x, y, z);
  48. /** \nNote: The getshapeindex command is slow if it is called frequently.
  49. It is better to define the shape index in a global variable that gets set
  50. during reset. You can then replace getshapeindex with the name of your global variable.
  51. Index values for 3D shapes can be found through the Tools>Media Files menu,
  52. but keep in mind that index values can change when new media is loaded.*/
  53. } // ******* PickOption End ******* //
Thanks ans best regards!
FlexSim 16.2.0
multiprocessor
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

Regan Blackett avatar image
1 Like"
Regan Blackett answered Regan Blackett edited

The 'opnum' variable declared at the top the the code window tells you which process just finished, it's a number from 1 to 'n' where 'n' is the total number of processes on the Multiprocessor. So what you would need to do is have a switch() or if() statement in the code that says if opnum is some value change shape accordingly.

Like this:

  1. switch(opnum)
  2. {
  3. case 1:
  4. { // ************* PickOption Start ************* //
  5. /***popup:Change3DShape*/
  6. /**Change 3D Shape*/
  7. treenode involved = /** \nObject: *//***tag:object*//**/item/**/;
  8. string shapename = /** \nShape: *//***tag:shapepath*//**/"fs3d\\General\\Box.3ds"/**/;
  9.  
  10. double theindex = getshapeindex(shapename);
  11.  
  12. //Grab the current size of the object
  13. double x = xsize(involved);
  14. double y = ysize(involved);
  15. double z = zsize(involved);
  16.  
  17. setname(shape(involved),"_shape");
  18. setobjectshapeindex(involved,theindex);
  19.  
  20. //Update the object to the original size
  21. applyshapefactors(involved);
  22. setsize(involved, x, y, z);
  23. /** \nNote: The getshapeindex command is slow if it is called frequently.
  24. It is better to define the shape index in a global variable that gets set
  25. during reset. You can then replace getshapeindex with the name of your global variable.
  26. Index values for 3D shapes can be found through the Tools>Media Files menu,
  27. but keep in mind that index values can change when new media is loaded.*/
  28. } // ******* PickOption End ******* //
  29. break;
  30. case 2:
  31. { // ************* PickOption Start ************* //
  32. /***popup:Change3DShape*/
  33. /**Change 3D Shape*/
  34. treenode involved = /** \nObject: *//***tag:object*//**/item/**/;
  35. string shapename = /** \nShape: *//***tag:shapepath*//**/"fs3d\\FlowItem\\Tote.3ds"/**/;
  36.  
  37. double theindex = getshapeindex(shapename);
  38.  
  39. //Grab the current size of the object
  40. double x = xsize(involved);
  41. double y = ysize(involved);
  42. double z = zsize(involved);
  43.  
  44. setname(shape(involved),"_shape");
  45. setobjectshapeindex(involved,theindex);
  46.  
  47. //Update the object to the original size
  48. applyshapefactors(involved);
  49. setsize(involved, x, y, z);
  50. /** \nNote: The getshapeindex command is slow if it is called frequently.
  51. It is better to define the shape index in a global variable that gets set
  52. during reset. You can then replace getshapeindex with the name of your global variable.
  53. Index values for 3D shapes can be found through the Tools>Media Files menu,
  54. but keep in mind that index values can change when new media is loaded.*/
  55. } // ******* PickOption End ******* //
  56. break;
  57. }
5 |100000

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