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 > Q&A
Downloads

Q&A Using Flexsim and building models

  #1  
Old 02-08-2010
Frank Janssen Frank Janssen is offline
Flexsim User
 
Join Date: Sep 2009
Location: Utrecht
Posts: 5
Downloads: 3
Uploads: 0
Thanks: 4
Thanked 1 Time in 1 Post
Rep Power: 0
Frank Janssen is on a distinguished road
Default adding a node to a group

I'm trying generate a number of BasicFR's whit conveyors with the GUI.

After copping all the containers I want some items in one groep, so they can easily be selected.

I'm using this code to create a new group an ad a new node in the group. Al I need to do is put the right info in the node. When I get my test running i can use the code while generate(ing) the conveyors.

// Create a new group
treenode Groups = node("/Tools/Groups",model());
nodeinsertinto(Groups);
setname(last(Groups),"Invisible");

// create a new node
treenode GroupWhithInvisible = last(Groups);
nodeinsertinto(GroupWhithInvisible);
nodeadddata(last(GroupWhithInvisible),DATATYPE_NUM BER);

//putting the right info in
setnodenum(last(GroupWhithInvisible),tonum(current ));


If I use the code as above than it results in the number 426970840
If I ad the item to a group with the standard group function it results in 426163248

Wat is the right way to do this?

thanks
  #2  
Old 02-08-2010
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

Frank,

Groups are not made with the tonum() command because the values from the tonum command may not be valid after a compile or a reload. Instead they use couplings which are what the port connections use. Couplings create a number value that will remain valid until it is deleted and they will also be a little easier for you to use.

When you use couplings you need to remember:
1. The createcoupling() command will create a node in each container specified when you call the command.
2. When you destroy one of the coupling nodes it will automatically destroy the other coupling node.

To create your own group you will need to:
1. Make sure that there is a Groups node in the Tools node in the model. Usually this is not created in a model until the first group is created.
2. Make sure that there is a Groups node in each object that you want to be in a group. To insert the correct node and set the name of the node for the object myobject try: nodeinstertafter(node("/myobject>LAST", model())); setname(node("/myobject>LAST", model(), "Groups");
3. The create coupling command in your code would look like: createcoupling(Groups, node("/myobject>Groups", model());

I hope this helps,
Brandon
__________________
thats not normal.
The Following 2 Users Say Thank You to Brandon Peterson For This Useful Post:
Tom David (02-08-2010)
  #3  
Old 02-08-2010
Frank Janssen Frank Janssen is offline
Flexsim User
 
Join Date: Sep 2009
Location: Utrecht
Posts: 5
Downloads: 3
Uploads: 0
Thanks: 4
Thanked 1 Time in 1 Post
Rep Power: 0
Frank Janssen is on a distinguished road
Default

Thanks Brandon.

It finally works. createcoupling was the magic function.

This is what the code looks like:


treenode Focus = node("@>objectfocus+",c);

//Group in the model
treenode Groups = node("/Tools/Groups",model());
nodeinsertinto(Groups);
setname(last(Groups),"GENEREER");
treenode GroupWhithInvisible = last(Groups);

int AantalItems = gettablerows(Focus);

for ( int a = 2; a<= AantalItems; a++)
{
// Group in the Item
treenode Current = rank(Focus,a);
treenode GroupItem = node(">Groups",Current);
nodeinsertinto(GroupItem);
setname(last(GroupItem),"GROUP");
treenode GroupOfItem = last(GroupItem);
createcoupling(GroupWhithInvisible,GroupOfItem);
}
The Following User Says Thank You to Frank Janssen For This Useful Post:
Tom David (02-08-2010)


Thread Thread Starter Forum Replies Last Post
New LinkedIn Group Bill Nordgren Product Announcements 0 01-21-2010 11:50 AM
copy node juan alberto Q&A 1 01-19-2010 05:48 AM
Developer's manual / Adding new object classes Doug Beaton Q&A 7 02-25-2009 05:05 PM
adding a button on the tool bar Pablo Concha Q&A 4 09-13-2007 10:46 AM
Adding member eith Flexscript Lars-Olof Leven Q&A 2 08-22-2007 08:00 AM


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.