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 03-10-2011
Chris Moon's Avatar
Chris Moon Chris Moon is offline
Flexsim User
 
Join Date: Feb 2011
Location: Atlanta
Posts: 14
Downloads: 18
Uploads: 0
Thanks: 8
Thanked 0 Times in 0 Posts
Rep Power: 112
Chris Moon is on a distinguished road
Exclamation Xsupermarket GUI Code Question

Hello.
I have a question about the code for number of registers on GUI.
Below is the code that applies on selection

//This code turns the registers on or off

treenode registerelector = c;
treenode objrank = get(itemcurrent(registerelector));
applylinks(ownerview(c), 1);

treenode MainQ = node("MAIN:/1/3/197");
treenode Register1 = node("MAIN:/1/3/288/8");
treenode Register2 = node("MAIN:/1/3/289/8");
treenode Register3 = node("MAIN:/1/3/290/8");
treenode Register4 = node("MAIN:/1/3/291/8");
treenode Register5 = node("MAIN:/1/3/292/8");

treenode Stand1 = node("MAIN:/1/3/288/7");
treenode Stand2 = node("MAIN:/1/3/289/7");
treenode Stand3 = node("MAIN:/1/3/290/7");
treenode Stand4 = node("MAIN:/1/3/291/7");
treenode Stand5 = node("MAIN:/1/3/292/7");

treenode Cachier1 = node("MAIN:/1/3/288/5");
treenode Cachier2 = node("MAIN:/1/3/289/5");
treenode Cachier3 = node("MAIN:/1/3/290/5");
treenode Cachier4 = node("MAIN:/1/3/291/5");
treenode Cachier5 = node("MAIN:/1/3/292/5");

treenode Bagger1 = node("MAIN:/1/3/288/6");
treenode Bagger2 = node("MAIN:/1/3/289/6");
treenode Bagger3 = node("MAIN:/1/3/290/6");
treenode Bagger4 = node("MAIN:/1/3/291/6");
treenode Bagger5 = node("MAIN:/1/3/292/6");

if (objrank == 1)

{
clearcontents(connectionscenter(MainQ));
mpt(getname(MainQ));mpr();
mpt(getname(Register1));mpr();
contextdragconnection(MainQ,Register1,"S");


Here, how can I know
treenode MainQ should be node("MAIN:/1/3/197") and
treenode Register1 should be node("MAIN:/1/3/288/8")?
How can I find this node("MAIN:/1/3/197") for appropriate object?

Also, in this code, can anyone explains that why we need
mpt(getname(MainQ));mpr();
mpt(getname(Register1));mpr();
these codes?

Thanks a lot.
  #2  
Old 03-11-2011
mark.gormley mark.gormley is offline
Flexsim User
 
Join Date: Oct 2008
Posts: 58
Downloads: 12
Uploads: 0
Thanks: 32
Thanked 63 Times in 29 Posts
Rep Power: 181
mark.gormley has a spectacular aura aboutmark.gormley has a spectacular aura about
Default

Hi Chris,

The easiest way to find the path of an object is to set it as SO():

Right Click > Edit > Designate This Node (SO)


Then open up a script window and use the command:

nodetopath(so(),0)

Providing you leave the semicolon off the end of the statement, the path to the object will appear in the String display on the script window. you could also print the path to the output console using:

pt(nodetopath(so(),0));

If you pass a 1 instead of a 0 as the second parameter then you will get the path displayed as names rather than numbers. Either of these can be passed into the node command.

As for the mpt() and mpr() commands, these work the same as pt() and pr(), but print to the system console rather than the output console.
The Following 4 Users Say Thank You to mark.gormley For This Useful Post:
Sebastian Hemmann (03-11-2011)
  #3  
Old 03-11-2011
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

Chris,

Just a quick intro to paths:

First, paths are a lot like paths in windows explorer but with a few minor differences. The main convenience difference is that paths can either use the name of a node or the number equal to the rank of a node. The biggest difference is the use of "/" and ">" instead of "\". In the tree you will notice that there are two ways to go into an object/node; one is the "+" sign next to the node and the other is the ">" that appears after you click on the node. These are important because they designate the symbol you use when you specify the path ("/" for the "+" method and ">" for the ">" method).

Second, you will notice that all of your paths start with "MAIN:/1/3" which is how you get to the model. It is the equivalent of "MAIN:/project/model". Typically I like to keep things a little easier for myself and use "model()" as the starting object so for example:

treenode Register1 = node("MAIN:/1/3/288/8");

would be:
treenode Register1 = node("/288/8", model());

I know you didn't write this yourself and that my way may very well be slower, but it is easier for me to read and understand because I don't do GUI's enough to keep fluent with the code.

Answers to your questions:
1. How can I find this node("MAIN:/1/3/197") for appropriate object?
-It is pointing to the 197th object in the model. placing the following code in a script window will get you the name:

getname(node("/197", model());
or
getname(rank(model(), 197));

2. What are the mpr(); mpt(); commands?
-They are used for debugging and act just like the pr(); pt(); pf(); and pd(); commands except that they print to the system console instead of the output console (pr for new line, pt for text, pf for a double, and pd for and integer). You can find more out by looking the commands up in the help.

Good Luck,
Brandon
__________________
thats not normal.
The Following 3 Users Say Thank You to Brandon Peterson For This Useful Post:
Sebastian Hemmann (03-14-2011)
  #4  
Old 03-14-2011
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: 773
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

You can also right click on the model tree view and select View->Show Node Ranks.
The Following 3 Users Say Thank You to Jason Lightfoot For This Useful Post:
Steven Hamoen (03-14-2011)


Thread Thread Starter Forum Replies Last Post
one question about custom draw code trigger LINWEIXU Q&A 5 08-03-2009 11:21 PM
On Model Open after set make all code C++ ?? ankus d Q&A 8 03-05-2009 10:06 PM
Is it possible that you can have only 100 local variables in your code? Tom David Gripes and Goodies 3 11-06-2008 01:42 PM
Code autocompletion is great! Would like more shortcuts. AlanZhang Gripes and Goodies 2 02-20-2008 10:04 PM
Model Startup Code Lolke Koopmans Q&A 4 12-14-2007 09:51 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.