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
FAQ Downloads Calendar Search Mark Forums Read

Q&A Using Flexsim and building models

Reply
 
Thread Tools Display Modes
  #1  
Old 06-14-2010
harry qin harry qin is offline
Flexsim User
 
Join Date: Apr 2010
Posts: 19
Downloads: 5
Uploads: 0
Thanks: 19
Thanked 0 Times in 0 Posts
Rep Power: 119
harry qin is on a distinguished road
Default Is there any method to add section to conveyor using flexscript command?

Hi, everyone.If i wanna add new sections to a conveyor,such as a straight one or a curved on,what kind of command can i use?
I try to use the setnodenum.but the section name is blank which you can see in the next pic.So i can't get the node path.
Generally,I wanna add new sections to conveyor using command instead of operating the layout tab in properties.Anyone can give me suggestion,thank you in advance.
Attached Thumbnails
Click image for larger version

Name:	未命名.jpg
Views:	156
Size:	35.6 KB
ID:	1017  
__________________
Harry Qin
Reply With Quote
  #2  
Old 06-14-2010
Jason Lightfoot Jason Lightfoot is offline
Flexsim Consultant
 
Join Date: Aug 2007
Location: Somerset, UK
Posts: 719
Downloads: 20
Uploads: 0
Thanks: 123
Thanked 953 Times in 446 Posts
Rep Power: 769
Jason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond repute
Default

Just create the following user commands:

addStraightSection (obj conveyor, num length [,num legs, num rise])

Code:
treenode conv=parnode(1);
treenode sections=getvarnode(conv,"sections");
int numsections=content(sections)+1;
settablesize(sections,numsections,CONVSEC_STARTANGLE);
settablenum(sections,numsections,CONVSEC_TYPE,CONVSECTYPE_STRAIGHT);
settablenum(sections,numsections,CONVSEC_LENGTH,parval(2));
settablenum(sections,numsections,CONVSEC_NROFLEGS,parval(3));
settablenum(sections,numsections,CONVSEC_RISE,parval(4));
setnodename(rank(sections,numsections),concat("section ",numtostring(numsections,0,0)));
addCurvedSection (obj conveyor, num angle, num radius [,num legs, num rise])

Code:
treenode conv=parnode(1);
treenode sections=getvarnode(conv,"sections");
int numsections=content(sections)+1;
settablesize(sections,numsections,CONVSEC_STARTANGLE);
settablenum(sections,numsections,CONVSEC_TYPE,CONVSECTYPE_CURVED);
settablenum(sections,numsections,CONVSEC_ANGLE,parval(2));
settablenum(sections,numsections,CONVSEC_RADIUS,parval(3));
settablenum(sections,numsections,CONVSEC_NROFLEGS,parval(4));
settablenum(sections,numsections,CONVSEC_RISE,parval(5));
setnodename(rank(sections,numsections),concat("section ",numtostring(numsections,0,0)));

Last edited by Jason Lightfoot; 06-14-2010 at 05:33 PM. Reason: Added the naming of the conveyor section
Reply With Quote
The Following 6 Users Say Thank You to Jason Lightfoot For This Useful Post:
arunkrmahadeva (11-07-2014), Bill Nordgren (06-14-2010), harry qin (06-15-2010), Johan Hagman (06-21-2010), Lars-Olof Leven (06-14-2010), Tom David (06-15-2010)
  #3  
Old 06-15-2010
harry qin harry qin is offline
Flexsim User
 
Join Date: Apr 2010
Posts: 19
Downloads: 5
Uploads: 0
Thanks: 19
Thanked 0 Times in 0 Posts
Rep Power: 119
harry qin is on a distinguished road
Default

Well done,Jason.Thanks.It's a good idea for me.

And now,If i wanna change the the section's type(from type 1 to type 2) of the conveyor using flexscript instead of user command ,supposing there is only one section in the conveyor,how can i get the node path.Or should i set the section's name(you know it is blank in the tree) before i change it's type?

Is my question clear?Thank all of you.
__________________
Harry Qin
Reply With Quote
  #4  
Old 06-15-2010
Jason Lightfoot Jason Lightfoot is offline
Flexsim Consultant
 
Join Date: Aug 2007
Location: Somerset, UK
Posts: 719
Downloads: 20
Uploads: 0
Thanks: 123
Thanked 953 Times in 446 Posts
Rep Power: 769
Jason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond repute
Default

To rename based on the section rank replace <index> with the number you want - 1 in the case of one section.

Code:
setnodename(rank(sections,<index>), "newsectionname");
so similarly it's:

Code:
settablenum(sections,<index>,CONVSEC_TYPE,CONVSECTYPE_STRAIGHT);
or

Code:
settablenum(sections,<index>,CONVSEC_TYPE,CONVSECTYPE_CURVED);
to change a given section's type.

And if you know the section name is unique (e.g. Section5 ) you can find the index with:

Code:
int sectionindex=getrank(node("/Section5",sections));
Reply With Quote
The Following 2 Users Say Thank You to Jason Lightfoot For This Useful Post:
harry qin (06-19-2010), Lars-Olof Leven (06-15-2010)
  #5  
Old 06-19-2010
harry qin harry qin is offline
Flexsim User
 
Join Date: Apr 2010
Posts: 19
Downloads: 5
Uploads: 0
Thanks: 19
Thanked 0 Times in 0 Posts
Rep Power: 119
harry qin is on a distinguished road
Default

Hi,Jason, acturally i am not so clearly what's your method in the second post.Here is my goal.
For example,i have a conveyor named "Conveyor2" in my mode which has one straight section.Now I want to change it into curved.If the section's name is "section1",then i will use the command in script as follows:
Code:
setnodenum(node("/Conveyor2>variables/sections/section1/type",model()),2);
.It will change the section's type into curved.But the section's name isn't anything.It is blank.Then how can I get the node path?Or is there any other mothed to achieve my goal? I don't know how to use the index.I also can't use the user command method.
BTW,is this a bug in 4.52 ? Because i know the section's name is exist in flexsim 3.0.The first section's name will be "section1" in 3.0 vision.
__________________
Harry Qin
Reply With Quote
  #6  
Old 06-19-2010
Tom David's Avatar
Tom David Tom David is offline
Flexsim User
 
Join Date: Aug 2007
Location: Schwaebisch Gmuend, Germany
Posts: 430
Downloads: 157
Uploads: 47
Thanks: 486
Thanked 450 Times in 233 Posts
Rep Power: 516
Tom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant futureTom David has a brilliant future
Default


You can reference to a node by name or by rank in the same statement.
Let’s say you want to reference to a node by name (section1)
setnodenum(node("/Conveyor2>variables/sections/section1/type",model()),2);

Now reference to the same node by rank (1)
setnodenum(node("/Conveyor2>variables/sections/1/type",model()),2);

There is a command called nodetopath(). Make a node so() and then write into the script:
nodetopath(so()); which returns the reference to the node by ranks.
Nodetopath(so(),1); which returns the reference to the node by names.


By the way, reference to a node by rank is faster than by name, but it might be less understandable ...

I hope this makes everything a bit more clear. If not, feel free to ask again.
__________________
tom the (A)tom: "We have solved our problems ... now we have to fight the solutions."
Reply With Quote
The Following User Says Thank You to Tom David For This Useful Post:
harry qin (06-19-2010)
  #7  
Old 06-19-2010
harry qin harry qin is offline
Flexsim User
 
Join Date: Apr 2010
Posts: 19
Downloads: 5
Uploads: 0
Thanks: 19
Thanked 0 Times in 0 Posts
Rep Power: 119
harry qin is on a distinguished road
Default

Thanks Tom.Yeah,it makes me clear.Acturally, I have used the "rank(1)",but I thought it doesn't work because it shows "no node".Now I found it has changed the nodenum in the tree following your advice.
And thank Jason.Your advice is what I want in the next step.
__________________
Harry Qin

Last edited by harry qin; 06-20-2010 at 01:52 AM.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Section 3 Models Malcolm Beaverstock Flexsim Student Forum 0 01-06-2010 09:23 PM
New Models in the download section Brenton King Marketing and Sales Information 1 09-23-2009 07:25 PM
improve Connections method qin tian Gripes and Goodies 7 03-26-2008 09:42 AM
Is there any simple solution to support batch mean method in flexsim? qin tian Q&A 1 02-29-2008 01:19 PM


All times are GMT -6. The time now is 03:26 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.
Copyright 1993-2018 FlexSim Software Products, Inc.