ATTENTIONThis FlexSim Community Forum is read-only. Please post any new questions, ideas, or discussions to our new community (we call it Answers) at https://answers.flexsim.com/. Our new Question & Answer site brings a modern, mobile-friendly interface and more focus on getting answers quickly. There are a few differences between how our new Q&A community works vs. a classic, threaded-conversation-style forum like the one below, so be sure to read our Answers Best Practices. |
flexsim.com |
#1
|
|||
|
|||
change 3D shape of a packed flow item
Hi all,
Since I'm not similar with programing, I think it should be a very simple question. I would like to change the 3D shape of one of the packed flowitem (e.g. a packed flowitem with 2 boxes in a pallet, I would like to change the 3D shape of the boxes) after a process, if I use the code in picklist, only the shape of the pallet is changed, I would like to know how to change the shape of the boxes only. Thanks. Regards, Kelvin |
#2
|
||||
|
||||
Kelvin,
The reason that the pallet shape is changed is that when you reference 'item' from the code in the processor it is referencing the pallet. To reference the items on the pallet you have to use a command such as: first(item); //which references the first ranking item on the pallet. or last(item); //which references the last ranking item on the pallet. or rank(item,1); //which references the first ranking item on the pallet. or rank(item,5); //which references the fifth ranking item on the pallet. and so on..... For your situation you would need to use a for loop to change the shape of all the flowitems in the pallet. A simple version of the code would be the following: for(int i = 1; i <= content(item); i++) { setobjectshapeindex(rank(item,i),6); setsize(rank(item,i)); } As you can see the for loop will run until 'i' is equal to the content of item, and every time the code loops 'i' will be incremented by one. Another thing to note is that we have used the variable 'i' in the rank command. I have modified the picklist you used to use this idea. If you copy and paste the following code into your OnProcessFinish tab, you'll be able to change the shape index on all the flowitems located in a pallet: treenodeitem = parnode(1); treenode current = ownerobject(c); { //************* PickOption Start *************\\ /**Change 3D Shape*/ /** \nObject: */ for(int i = 1; i <= content(item); i++) { treenode involved = /**/rank(item,i)/**/; /** \nShape Index Number: */ double theindex = /**/6/**/; setname(shape(involved),"_shape"); setobjectshapeindex(involved,theindex); /** \n\nIndex 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, so it is better to define the index with a global variable that gets set during reset using the getshapeindex() command.*/ /**\n\n*/ } //******* PickOption End *******\\ { //************* PickOption Start *************\\ /**Set Location, Rotation, or Size*/ /** \nCommand: */ /**/setsize/**list:setloc~setrot~setsize*/( /** \nObject: *//**/rank(item,i)/**/, /** \nx: *//**/2/**/, /** \ny: *//**/2/**/, /** \nz: *//**/2/**/ ); /**\n\n*/ } } //******* PickOption End *******\\ This code should do what you are requesting. Let me know if it works for you. Paul Last edited by Paul Toone; 02-21-2008 at 10:01 AM. |
The Following User Says Thank You to Paul Toone For This Useful Post: | ||
arunkrmahadeva (01-25-2014) |
Thread | Thread Starter | Forum | Replies | Last Post |
Getting an imported shape into the yellow selection box | Brenton King | Tips and Tricks | 23 | 07-24-2009 08:44 PM |
Flow items with states | AlanZhang | Q&A | 16 | 11-30-2007 10:32 AM |
Adjusting 3d shape of a crane | Maurits Brandt | Tips and Tricks | 3 | 09-14-2007 12:25 AM |