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 |
|
Downloads |
Q&A Using Flexsim and building models |
#1
|
|||
|
|||
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.
__________________
Harry Qin |
#2
|
|||
|
|||
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))); 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 |
The Following 6 Users Say Thank You to Jason Lightfoot For This Useful Post: | ||
Tom David (06-15-2010) |
#3
|
|||
|
|||
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 |
#4
|
|||
|
|||
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"); Code:
settablenum(sections,<index>,CONVSEC_TYPE,CONVSECTYPE_STRAIGHT); Code:
settablenum(sections,<index>,CONVSEC_TYPE,CONVSECTYPE_CURVED); 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)); |
The Following 2 Users Say Thank You to Jason Lightfoot For This Useful Post: | ||
Lars-Olof Leven (06-15-2010) |
#5
|
|||
|
|||
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); 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 |
#6
|
||||
|
||||
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." |
The Following User Says Thank You to Tom David For This Useful Post: | ||
harry qin (06-19-2010) |
#7
|
|||
|
|||
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. |
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 |