Here we have provided a quick reference for commands that are used most often in FlexSim. For more detailed information on these commands, refer to the command index.
Topics
- Referencing Commands
- Object Attributes
- Object Spatial Attributes
- Object Statistics
- Object Labels
- Object Control
- Object Variables
- Tables
- TaskExecuter Control
- Prompts and Printouts
- Advanced Functions
Object Referencing
The following commands and access variables are used in referencing objects in FlexSim.
current and item
- current - the current variable is a reference to the current resource object. It is often an access variable in pick lists.
- item - the item variable is a reference to the involved item for a trigger or function. It is often an access variable in pick lists.
Referencing Commands
command(parameter list) | Explanation | Example |
---|---|---|
first(node) | This returns a reference to the first ranked object inside of the object passed | first(current) |
last(node) | This returns a reference to last ranked object inside of the object passed | last(current) |
rank(node, ranknum) | This returns a reference to the object at a given rank inside the object passed | rank(current, 3) |
inobject(object, portnum) | This returns a reference to the object connected to the input port number of the object passed | inobject(current, 1) |
outobject(object, portnum) | This returns a reference to the object connected to the output port number of the object passed | outobject(current, 1) |
centerobject(object, portnum) | This returns a reference to the object connected to the center port number of the object passed | centerobject(current, 1) |
next(node) | This returns a reference to the next ranked object of the object passed | next(item) |
prev(node) | This returns a reference to the previous ranked object of the object passed | prev(item) |
node(path, startnode) | This returns the object found at path in the tree beginning from startnode | node("/Floor1/Processor", model()) |
Object Attributes
command(parameter list) | Explanation |
---|---|
getname(object) | This returns the name of the object |
setname(object, name) | This sets the name of the object |
getitemtype(object) | This returns the itemtype value of the object |
setitemtype(object, num) | This sets the itemtype value of the object |
setcolor(object, red, green, blue) | This sets the color of the object |
colorred(object) colorgreen, blue, white, random... |
This sets the color of the object to red, blue, green, white, etc. |
setobjectshapeindex(object, indexnum) | This sets the 3D shape of the object |
setobjecttextureindex(object, indexnum) | This sets the 3D texture of the object |
Object Spatial Attributes
command(parameter list) | Explanation |
---|---|
xloc(object) yloc(object) zloc(object) |
These commands return the x, y, and z locations of the object |
setloc(object, xnum, ynum, znum) | This sets the x, y, and z location of the object |
xsize(object) ysize(object) zsize(object) |
These commands return the x, y, and z size of the object |
setsize(object, xnum, ynum, znum) | This sets the x, y, and z size of the object |
xrot(object) yrot(object) zrot(object) |
These commands return the x, y, and z rotation of the object |
setrot(object, xdeg, ydeg, zdeg) | This sets the x, y, and z rotation of the object |
Object Statistics
command(parameter list) | Explanation |
---|---|
content(object) | This returns the current content of the object |
getinput(object) | This returns the input statistic of the object |
getoutput(object) | This returns the output statistic of the object |
setstate(object, statenum) | This sets the current state of the object. |
getstatenum(object) | This returns the current state value of the object |
getstatestr(object) | This returns the current state of the object as a string |
getrank(object) | This returns the rank of the object |
setrank(object, ranknum) | This sets the rank of the object |
getentrytime(item) | This returns the time the flow item entered the object it is currently in |
getcreationtime(item) | This returns the time the flow item was created |
Object Labels
command(parameter list) | Explanation |
---|---|
getlabel(object, "labelname") getlabel(object, labelrank) |
This returns the value of the object's label |
setlabel(object, "labelname", value) setlabel(object, labelrank, value) |
This sets the value of the object's label |
label(object, "labelname") label(object, labelrank) |
This returns a reference to the label as a node. This command is often used if you have a label that is used as a table. |
assertlabel(object, "labelname", DATATYPE_NUMBER) assertlabel(object, "labelname", DATATYPE_STRING) |
This command creates a label called "labelname" if it doesn't currently exist on object, or returns a reference to the label if it already exists. |
Object Control
command(parameter list) | Explanation |
---|---|
closeinput(object) | This closes the input of the object |
openinput(object) | This re-opens the input of the object |
closeoutput(object) | This closes the output of the object |
openoutput(object) | This re-opens the output of the object |
sendmessage(toobject, fromobject, parameter1, parameter2, parameter3) |
This causes the message trigger of the object to fire |
senddelayedmessage(toobject, delaytime, fromobject, parameter1, parameter2, parameter3) |
This causes the message trigger of the object to fire after a certain delay time |
stopobject(object, downstate) | This tells the object to stop whatever its operation is and go into the given state |
resumeobject(object) | This allows the object to resume whatever its operation is |
stopoutput(object) | This closes the output of the object, and accumulates stopoutput requests |
resumeoutput(object) | This opens the output of the object once all stopoutput requests have been resumed |
stopinput(object) | This closes the input of the object, and accumulates stopinput requests |
resumeinput(object) | This opens the input of the object once all stopinput requests have been resumed |
insertcopy(originalobject, containerobject) | This inserts a new copy of the object into the container |
moveobject(object, containerobject) | This moves the object out of its current container into its new container |
Object Variables
command(parameter list) | Explanation |
---|---|
getvarnum(object, “variablename”) | This returns the number value of the variable with the given name |
setvarnum(object, “variablename”, value) | This sets the number value of the variable with the given name |
getvarstr(object, “variablename”) | This returns the string value of the variable with the given name |
setvarstr(object, “variablename”, string) | This sets the string value of the variable with the given name |
getvarnode(object, “variablename”) | This returns a reference to the variable with the given name as a node |
Other
Tables
command(parameter list) | Explanation |
---|---|
gettablenum("tablename", rownum, colnum) gettablenum(tablenode, rownum, colnum) gettablenum(tablerank, rownum, colnum) |
This returns the value in the specified row and column of the table |
settablenum("tablename", rownum, colnum, value) settablenum(tablenode, rownum, colnum, value) settablenum(tablerank, rownum, colnum, value) |
This sets the value in the specified row and column of the table |
gettablestr("tablename", rownum, colnum) gettablestr(tablenode, rownum, colnum) gettablestr(tablerank, rownum, colnum) |
This returns the string value in the specified row and column of the table |
settablestr("tablename", rownum, colnum, "value") settablestr(tablenode, rownum, colnum, "value") settablestr(tablerank, rownum, colnum, "value") |
This sets the string value in the specified row and column of the table |
settablesize("tablename", rows, columns) settablesize(tablenode, rows, columns) settablesize(tablerank, rows, columns) |
This sets the size of the table in rows and columns |
gettablerows("tablename") gettablerows(tablenode) gettablerows(tablerank) |
This returns the number of rows in the table |
gettablecols("tablename") gettablecols(tablenode) gettablecols(tablerank) |
This returns the number of columns in the table |
clearglobaltable("tablename") clearglobaltable(tablenode) clearglobaltable(tablerank) |
Sets all number values in the table to 0 |
TaskExecuter Control
For more information on controlling TaskExecuters, refer to the task sequence section.
Prompts and Printouts
command(parameter list) | Explanation |
---|---|
pt(text string) | Prints text to the output console |
pf(float value) | Prints a floating point value to the output console |
pd(discrete value) | Prints an integer value to the output console |
pr() | Creates a new line in the output console |
msg(“title”, “caption”) | Opens a simple Yes, No, Cancel dialog |
userinput(targetnode, “prompt”) | Opens a dialog box where you can set the value of a node in the model |
concat(string1, string2, etc.) | This returns the string concatenation of two or more strings |
Advanced Functions
Here are more advanced functions that you might use. We do not provide their parameter lists here. For more information, refer to the command summary.
Node commands - node(), nodeadddata(), getdatatype(), nodetopath(), nodeinsertinto(), nodeinsertafter(), getnodename(), setnodename(), getnodenum(), getnodestr(), setnodenum(), setnodestr(), inc()
Data changing commands - stringtonum(), numtostring(), tonode(), apchar()
Node table commands - setsize(), gettablenum(), gettablestr(), gettablerows(), gettablecols()
Model run commands - cmdcompile(), resetmodel(), go(), stop()
3D custom draw code commands - drawtomodelscale(), drawtoobjectscale(), drawsphere(), drawcube(), drawcylinder(), drawcolumn(), drawdisk(), drawobject(), drawtext(), drawrectangle(), drawline(), spacerotate(), spacetranslate(), spacescale()
Excel commands - excellaunch(), excelopen(), excelsetsheet(), excelreadnum(), excelreadstr(), excelwritenum(), excelwritestr(), excelimportnode(), excelimporttable(), excelclose(), excelquit()
ODBC commands - dbopen(), dbclose(), dbsqlquery(), dbchangetable(), dbgetmetrics(), dbgetfieldname(), dbgetnumrows(), dbgetnumcols(), dbgettablecell(), dbsettablecell()
Kinematics - initkinematics(), addkinematic(), getkinematics(), updatekinematics(), printkinematics()