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?

treenode  item = param(1);
treenode  current = ownerobject(c);
int opnum = param(2);
{ // ************* PickOption Start ************* //
/***popup:Change3DShape*/
/**Change 3D Shape*/
treenode involved = /** \nObject: *//***tag:object*//**/item/**/;
string shapename = /** \nShape: *//***tag:shapepath*//**/"fs3d\\FlowItem\\Frame.3ds"/**/;

double theindex = getshapeindex(shapename);

//Grab the current size of the object
double x = xsize(involved);
double y = ysize(involved);
double z = zsize(involved);

setname(shape(involved),"_shape");
setobjectshapeindex(involved,theindex);

//Update the object to the original size
applyshapefactors(involved);
setsize(involved, x, y, z);
/** \nNote: The getshapeindex command is slow if it is called frequently. 
It is better to define the shape index in a global variable that gets set 
during reset. You can then replace getshapeindex with the name of your global variable.
Index values for 3D shapes can be found through the Tools>Media Files menu,
but keep in mind that index values can change when new media is loaded.*/
} // ******* PickOption End ******* //
{ // ************* PickOption Start ************* //
/***popup:Change3DShape*/
/**Change 3D Shape*/
treenode involved = /** \nObject: *//***tag:object*//**/item/**/;
string shapename = /** \nShape: *//***tag:shapepath*//**/"fs3d\\FlowItem\\Tote.3ds"/**/;

double theindex = getshapeindex(shapename);

//Grab the current size of the object
double x = xsize(involved);
double y = ysize(involved);
double z = zsize(involved);

setname(shape(involved),"_shape");
setobjectshapeindex(involved,theindex);

//Update the object to the original size
applyshapefactors(involved);
setsize(involved, x, y, z);
/** \nNote: The getshapeindex command is slow if it is called frequently. 
It is better to define the shape index in a global variable that gets set 
during reset. You can then replace getshapeindex with the name of your global variable.
Index values for 3D shapes can be found through the Tools>Media Files menu,
but keep in mind that index values can change when new media is loaded.*/
} // ******* 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:

switch(opnum)
{
    case 1:
    { // ************* PickOption Start ************* //
    /***popup:Change3DShape*/
    /**Change 3D Shape*/
    treenode involved = /** \nObject: *//***tag:object*//**/item/**/;
    string shapename = /** \nShape: *//***tag:shapepath*//**/"fs3d\\General\\Box.3ds"/**/;

    double theindex = getshapeindex(shapename);

    //Grab the current size of the object
    double x = xsize(involved);
    double y = ysize(involved);
    double z = zsize(involved);

    setname(shape(involved),"_shape");
    setobjectshapeindex(involved,theindex);

    //Update the object to the original size
    applyshapefactors(involved);
    setsize(involved, x, y, z);
    /** \nNote: The getshapeindex command is slow if it is called frequently. 
    It is better to define the shape index in a global variable that gets set 
    during reset. You can then replace getshapeindex with the name of your global variable.
    Index values for 3D shapes can be found through the Tools>Media Files menu,
    but keep in mind that index values can change when new media is loaded.*/
    } // ******* PickOption End ******* //
    break;
    case 2:
    { // ************* PickOption Start ************* //
    /***popup:Change3DShape*/
    /**Change 3D Shape*/
    treenode involved = /** \nObject: *//***tag:object*//**/item/**/;
    string shapename = /** \nShape: *//***tag:shapepath*//**/"fs3d\\FlowItem\\Tote.3ds"/**/;

    double theindex = getshapeindex(shapename);

    //Grab the current size of the object
    double x = xsize(involved);
    double y = ysize(involved);
    double z = zsize(involved);

    setname(shape(involved),"_shape");
    setobjectshapeindex(involved,theindex);

    //Update the object to the original size
    applyshapefactors(involved);
    setsize(involved, x, y, z);
    /** \nNote: The getshapeindex command is slow if it is called frequently. 
    It is better to define the shape index in a global variable that gets set 
    during reset. You can then replace getshapeindex with the name of your global variable.
    Index values for 3D shapes can be found through the Tools>Media Files menu,
    but keep in mind that index values can change when new media is loaded.*/
    } // ******* PickOption End ******* //
    break;
}
5 |100000

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

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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