ATTENTION

This 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

Go Back   FlexSim Community Forum > FlexSim Software > Tips and Tricks
Downloads

Tips and Tricks Share helpful modeling ideas

  #1  
Old 06-04-2008
Sung Kim Sung Kim is offline
Flexsim User
 
Join Date: Jan 2008
Location: York, PA
Posts: 85
Downloads: 70
Uploads: 0
Thanks: 70
Thanked 9 Times in 6 Posts
Rep Power: 160
Sung Kim is on a distinguished road
Default Copy Labels

Hi everyone!

I would like to copy all labels from a container (pallet) to individual items during model run. I tried following code, but it might not the correct way. Could anyone help me? By the way, the individual items don't have labels defined yet. In other words, I would like to dynamically defined the labels same as the container and assing the value from a container at the same time.

containerplt --> pallet object --> several labels are defined and have values.
rank(containerplt, i) --> individual item --> No labels are defined yet
PltSize --> number of items on a pallet


for(i = 1; i<=PltSize; i++){
copylabels(rank(containerplt, i), containerplt);
}

Thanks in advance.

I use v 4.3.

Last edited by Sung Kim; 06-04-2008 at 08:38 AM.
  #2  
Old 06-04-2008
Brandon Peterson's Avatar
Brandon Peterson Brandon Peterson is offline
The Flexsim Consultant
 
Join Date: Jul 2007
Location: Salt Lake City, Utah
Posts: 382
Downloads: 29
Uploads: 6
Thanks: 192
Thanked 516 Times in 235 Posts
Rep Power: 490
Brandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant future
Default

Sung,

The copylabels command copies the labels from the specified object to all of the selected objects in the model. You might want to go to the help menu and look up a command in the command documentation before you try to implement it. The code that you tried to use could have had very bad consequences in your model.

Try the following code in your model to copy all of the labels from one object to another:

treenode fromobj = (YOU DEFINE);
treenode toobj = (YOU DEFINE);
int index;
for(index = 1; index <= content(labels(fromobj)); index++)
createcopy(label(fromobj, index), labels(toobj), 1);

This code assumes that you will be able to define the object you want to copy labels from and the object that you want to copy the labels to. The third parameter in the createcopy command will make sure that the new node has the same name as the one it was copied from.

Good Luck,
Brandon
__________________
thats not normal.

Last edited by Brandon Peterson; 06-04-2008 at 08:32 AM.
The Following User Says Thank You to Brandon Peterson For This Useful Post:
Brenton King (06-11-2008)
  #3  
Old 06-04-2008
Steven Hamoen's Avatar
Steven Hamoen Steven Hamoen is offline
Talumis, Flexsim Distributor, The Netherlands
 
Join Date: Aug 2007
Location: Soest, NL
Posts: 854
Downloads: 43
Uploads: 0
Thanks: 391
Thanked 661 Times in 379 Posts
Rep Power: 684
Steven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond repute
Default

Sung,

If the labels on the items have to be exactly the same as the one from the container, you can also copy the label node with all it's content;

treenode fromobj = (YOU DEFINE);
treenode toobj = (YOU DEFINE);

createcopy( labels(fromobj), labels(toobj), 1, 0, 0, 1);

Where labels is an attribute that points directly to the label node of an object.

Steven
The Following 2 Users Say Thank You to Steven Hamoen For This Useful Post:
Sung Kim (06-04-2008)
  #4  
Old 06-04-2008
Sung Kim Sung Kim is offline
Flexsim User
 
Join Date: Jan 2008
Location: York, PA
Posts: 85
Downloads: 70
Uploads: 0
Thanks: 70
Thanked 9 Times in 6 Posts
Rep Power: 160
Sung Kim is on a distinguished road
Default Thank you

Hello, Brandon. Thank you for a quick response!

Your code works wonderfully on my model. I added one outer for loop to take care of multiple flowitems on a pallet. It works well too.

Thank you also, Steven, for your suggestion!

Sung



All times are GMT -6.
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.
Copyright 1993-2018 FlexSim Software Products, Inc.