Object

Inherits from treenode

Description

A class that represents objects in the model.

An Object is a treenode that has object data. Objects have all the functionality of a treenode and also provide functionality for accessing object data and manipulating 3D objects.

Properties

animations Accesses an object's animations.
attrs Accesses object attribute nodes.
centerObjects Accesses objects connected through center port connections.
color Get and set the Color of the object.
flags Get and set flags of the object.
inObjects Accesses objects connected through input ports connections.
input Access methods on the object's input ports connections.
location Get and set the position of the object.
outObjects Accesses objects connected through output ports connections.
output Access methods on the object's output ports connections.
resetPosition Accesses an object's reset position.
rotation Get and set the rotation of the object.
size Get and set the size of the object.
stats Allows access to an object's statistics.
stopCount Gets the number of stops for the object.

Methods

applyProperties Commits property change(s) to template instances and overrides.
getLocation Gets the object's location.
getProperty Gets the value of an object's property.
getVariable Deprecated. Use getProperty(). Gets the value of an object's variable.
message Send a message to the object.
resume Return the object to its state prior to stop().
setLocation Sets the object's location.
setProperty Sets the value of an object's property.
setRotation Sets the object's rotation.
setSize Sets the object's size.
setState Sets the object's state.
setVariable Deprecated. Use setProperty(). Sets the value of an object's variable.
stop Stops the object, sets its state, and waits for resume().

Details

Do no remove, this fixes the anchor on doc.flexsim.com

Object.animations

readonly animations

Description

Accesses an object's animations.

Gives access to the animations of an object as Animation interfaces.

// Start the "Walk" animation on Operator1
Object obj = Model.find("Operator1");
obj.animations["Walk"].start();
			
Do no remove, this fixes the anchor on doc.flexsim.com

Object.attrs

readonly attrs

Description

Accesses object attribute nodes.


Object obj = Model.find("Processor1");
obj.attrs.spatialx.value = 5;
      		
Do no remove, this fixes the anchor on doc.flexsim.com

Object.centerObjects

readonly centerObjects

Description

Accesses objects connected through center port connections.

Accessing the Number of Center Port Connections

You can access the number of center port connections on the object with the following code.

obj.centerObjects.length

Accessing Objects by Rank

You can access an individual object connected through a center port connection by rank with the following code.


obj.centerObjects[1] // first object
obj.centerObjects[obj.centerObjects.length] // last object
obj.centerObjects[i] // i-th object
		      	

Getting an Array of Objects

You can get an Array of all objects connected through a center port connection with the following code.

Array centerObjects = obj.centerObjects.toArray();
Do no remove, this fixes the anchor on doc.flexsim.com

Object.color

readonly Color color

Description

Get and set the Color of the object.


Object obj = Model.find("Processor1");
obj.color = Color.red;
      		
Do no remove, this fixes the anchor on doc.flexsim.com

Object.flags

readonly flags

Description

Get and set flags of the object.

isProtected

Get or set the "Protected" flag of the object.

Protecting an object keeps it from being moved, rotated, or resized with the mouse, but not from being double-clicked to access the Parameters window for the object. View windows have an attribute named viewignoreobjects which can be used to ignore ALL the objects in their view which means the objects can not be manipulated in any way with the mouse including double-clicking. Protected objects will have a gray highlight in the treeview to indicate their protected status.

current.flags.isProtected = 1;

isSelected

Get or set the "Selected" flag of the object.

Selecting an object puts a red box around it in both the 3D and tree view. Dragging one selected object in the 3D view will drag all other selected objects by the same amount. The Edit Selected Objects tool allows you to quickly modify all selected objects in your model.

if(current.flags.isSelected) return 1;

showConnections

Get or set the "Show Connections" flag of the object.

Hiding the connections will turn off the display of ports and their connections both to and from the object. Note that view windows have an attribute named hideallconnectors that controls the display of connectors for ALL objects in their view.

obj.flags.showConnections = 0;

showContent

Get or set the "Show Contents" flag of the object.

Hiding the contents of an object will stop the display of objects (e.g. flowitems) contained within it.

current.flags.showContent = 0;

showName

Get or set the "Show Name" flag of the object.

A value of 1 will hide the object's name and stats from being displayed on the screen, a value of 0 will show the object's name and possibly stats depending on the viewhidealllabels attribute of the view window. The viewhidealllabels attribute of the view window has the following possible values which will apply to the label display of all objects in the window: 0=show name and stats, 1=hide name and stats, 2=show just names.

obj.flags.showName = 1;

showShape

Get or set the "Show Shape" flag of the object.

Hiding the object's shape will stop its 3D shape from drawing. Note that view windows also have an attribute called hidealldrawcontent that controls the display of 3D shapes for ALL objects in their view.

current.flags.showShape = 0;
Do no remove, this fixes the anchor on doc.flexsim.com

Object.inObjects

readonly inObjects

Description

Accesses objects connected through input ports connections.

Same as the centerObjects property, but for input port connections.

Do no remove, this fixes the anchor on doc.flexsim.com

Object.input

readonly input

Description

Access methods on the object's input ports connections.

close

Blocks the input of the object. Only the input ports themselves, or the input in general needs to be closed to block entry. When port connections are displayed with sufficient size in the view window, you will see a small red bar drawn across all the input ports (squares) for the object, signifying the input ports are blocked. Individual ports may still be open and drawn in green, but entry to the object is still blocked because of the red bar. Compare with stop().

current.input.close();

open

Unblocks the input of the object after it has been previously blocked with the close() method. It is necessary that both the input ports themselves, and the input in general, are open before entry will be allowed. It is advised that modelers never use this method in any field other than the OnMessage field which has been triggered with the senddelayedmessage() command, because commands which open ports often spawn several other activities that shouldn't be performed during transitional events. Compare with resume().

current.input.open();

resume

Opens the input of the object just like open() does, but because it keeps track of previous stop() calls on the object, it will only open input after all stops have been resumed. Refer to open() for additional information.

current.input.resume();

stop

Closes the input of the object just like close() does, but it also keeps track of consecutive stop() calls on the object, and will only open input after all stops have been resumed. Refer to close() for additional information.

current.input.stop();
Do no remove, this fixes the anchor on doc.flexsim.com

Object.location

readonly Vec3 location

Description

Get and set the position of the object.


Object obj = Model.find("Processor1");
obj.location = Vec3(0,0,0);
      		
Do no remove, this fixes the anchor on doc.flexsim.com

Object.outObjects

readonly outObjects

Description

Accesses objects connected through output ports connections.

Same as the centerObjects property, but for output port connections.

Do no remove, this fixes the anchor on doc.flexsim.com

Object.output

readonly output

Description

Access methods on the object's output ports connections.

Same as the input property, but for output port connections.

Do no remove, this fixes the anchor on doc.flexsim.com

Object.resetPosition

readonly resetPosition

Description

Accesses an object's reset position.

Allows you to access the reset position of an object. The property can be read directly to determine if an object's reset position has been set or not.

This property provides the following properties and methods:

location - returns an object's reset position location

rotation - returns an object's reset position rotation

size - returns an object's reset position size

container - returns an object's reset position container

set() - sets an object's reset position to its current location, rotation, size, and container.

clear() - clears an object's reset position.


				Object obj = Model.find("Processor1");
				if (obj.resetPosition) //Checks to see if its reset positon has been set
					return obj.resetPosition.location;// gets the location value of the reset position
				else{
					obj.resetPosition.set();// set the reset postion on the object
					return obj.resetPosition.location; // gets the location value of the reset position
				}
			
Do no remove, this fixes the anchor on doc.flexsim.com

Object.rotation

readonly Vec3 rotation

Description

Get and set the rotation of the object.


Object obj = Model.find("Processor1");
obj.rotation = Vec3(0,0,0);
      		
Do no remove, this fixes the anchor on doc.flexsim.com

Object.size

readonly Vec3 size

Description

Get and set the size of the object.


Object obj = Model.find("Processor1");
int xSize = obj.size.x;
      		
Do no remove, this fixes the anchor on doc.flexsim.com

Object.stats

readonly stats

Description

Allows access to an object's statistics.

Allows you to access the statistics of an object as TrackedVariable objects. This property provides the following properties and methods:

input - returns the input tracked variable

output - returns the output tracked variable

content - returns the content tracked variable

staytime - returns the staytime tracked variable

totalTravelDistance - returns the total travel distance of a Task Executer

state(Variant& profile = nullvar) - returns a state tracked variable. If no profile argument is given, or if it is 0, then the default state profile is returned. Other state profiles can be returned by providing the profile number or name.


// Get the input of a processor
Object obj = Model.find("Processor1");
double input = obj.stats.input.value;

// Get the state of a multiprocessor,
// using the multiprocessor state profile
Object obj =  Model.find("MultiProcessor1");
int curState = obj.stats.state(1).value;	
			
Do no remove, this fixes the anchor on doc.flexsim.com

Object.stopCount

readonly int stopCount

Description

Gets the number of stops for the object.

This number increases with calls to the stop method, and decreases with calls to the resume method.

int numStops = current.stopCount;
Do no remove, this fixes the anchor on doc.flexsim.com

Object.applyProperties()

void applyProperties( string propertyName = "" )

Parameters

propertyName Optional. The name of a specific property that has changed. A list of valid properties for each object can be found on that object's help page. For example, Fixed Resource Properties.

Returns

void

Description

Commits property change(s) to template instances and overrides.

This method will only have an effect if an object is a template instance or has template instances. It should be called after you have directly changed an object's properties and want that change to be applied to template instances and overrides.

The method call affects the named property you pass in, or, if you pass nothing in, it applies to all of the object's properties. It will do the following for the respective properties:

  1. Add Override(s) - If the object is a template instance, it will check if the property value of the object is different than the value of the object's template. If so, it will assert that property as an override.
  2. Apply to Inheriting Instances - If the object has template instances, it will set the same property value on all template instances that do not override that property.

Note that you do NOT need to call this method when you set an object's property using setProperty(). That method will automatically call applyProperties(). You only need to use this method if you have changed an object's properties through some other mechanism.

queue.size.x = 5;
queue.applyProperties("Size");

The example above demonstrates a time when you would need to call applyProperties(). You have changed an object's size using Object.size, instead of by calling setProperty(). Thus, you must call applyProperties() to apply that new property value to inheriting template instances and overrides.

Do no remove, this fixes the anchor on doc.flexsim.com

Object.getLocation()

Vec3 getLocation( double xFactor , double yFactor , double zFactor )
Vec3 getLocation( Vec3 factors )

Parameters

xFactor The x value of the point on the object where the location will be measured from. Measured as a percent of the object's size (0-1).
yFactor The y value of the point on the object where the location will be measured from. Measured as a percent of the object's size (0-1).
zFactor The z value of the point on the object where the location will be measured from. Measured as a percent of the object's size (0-1).
factors A vector representing the point on the object where the location will be measured from. Measured as a percent of the object's size (0-1).

Returns

Vec3 A vector holding the object's location.

Description

Gets the object's location.

This code gets the object's location measured at its center.

Vec3 centerLoc = obj.getLocation(0.5,0.5,0.5);
Vec3 centerLoc = obj.getLocation(Vec3(0.5,0.5,0.5));
Do no remove, this fixes the anchor on doc.flexsim.com

Object.getProperty()

Variant getProperty( string propertyName )

Parameters

propertyName The name of the property. A list of valid properties for each object can be found on that object's help page. For example, Fixed Resource Properties.

Returns

Variant

Description

Gets the value of an object's property.

This gets the value of the object's MaxContent property.

int maxContent = queue.getProperty("MaxContent");
Do no remove, this fixes the anchor on doc.flexsim.com

Object.getVariable()

Variant getVariable( string variableName )

Parameters

variableName The name of the variable

Returns

Variant The value of the specified variable.

Description

Deprecated. Use getProperty(). Gets the value of an object's variable.

This gets the value of the object's maxspeed variable.

double speed = obj.getVariable("maxspeed");
Do no remove, this fixes the anchor on doc.flexsim.com

Object.message()

Variant message( double delay = 0 , treenode fromObject = 0 , Variant msgparam1 = nullvar , Variant msgparam2 = nullvar , Variant msgparam3 = nullvar )

Parameters

delay Optional. Specifies the amount of time to delay before firing the message. If -1, the message will be sent synchronously. If 0 or greater, an event will be created in the defined delay time, and the message will be fired after that delay time.
fromObject Optional. The object that is sending the message. This can be accessed from the message trigger.
msgparam1 Optional. Defines the first parameter of the message. This can be accessed from the message trigger as msgparam1.
msgparam2 Optional. Defines the second parameter of the message. This can be accessed from the message trigger as msgparam2.
msgparam3 Optional. Defines the third parameter of the message. This can be accessed from the message trigger as msgparam3.

Returns

Variant If the message is sent synchronously (delay = -1), it will return whatever is returned by the object's message trigger. If the message is sent asynchronously (delay >= 0), the call will return a reference to the event node that was created in the event list.

Description

Send a message to the object.

In the example below, a message is sent to current, with a 0 second delay, and with item as the fromObject of the message.

current.message(0, item);
Do no remove, this fixes the anchor on doc.flexsim.com

Object.resume()

void resume( int id , int stateProfile )

Parameters

id Optional. For matching stop requests with resume requests.
stateProfile Optional. The state profile on which to record the state.

Returns

void

Description

Return the object to its state prior to stop().

Tells the object that it may resume whatever it was doing before stop() was called on it. Refer to stop() for more information.

current.resume(1);
Do no remove, this fixes the anchor on doc.flexsim.com

Object.setLocation()

Object setLocation( double x , double y , double z )
Object setLocation( double x , double y , double z , double xFactor , double yFactor , double zFactor )
Object setLocation( Vec3 location , Vec3 factors )

Parameters

x The desired x position.
y The desired y position.
z The desired z position.
xFactor The x value of the point on the object where the location will be measured from. Measured as a percent of the object's size (0-1).
yFactor The y value of the point on the object where the location will be measured from. Measured as a percent of the object's size (0-1).
zFactor The z value of the point on the object where the location will be measured from. Measured as a percent of the object's size (0-1).
location A vector holding the desired position.
factors A vector representing the point on the object where the location will be measured from. Measured as a percent of the object's size (0-1).

Returns

Object The translated object.

Description

Sets the object's location.

This code sets the object's center to the position (0,0,0).

obj.setLocation(0,0,0,0.5,0.5,0.5);
obj.setLocation(Vec3(0,0,0), Vec3(0.5,0.5,0.5));
Do no remove, this fixes the anchor on doc.flexsim.com

Object.setProperty()

void setProperty( string propertyName , Variant value )

Parameters

propertyName The name of the property. A list of valid properties for each object can be found on that object's help page. For example, Fixed Resource Properties.
value The desired property value.

Returns

void

Description

Sets the value of an object's property.

If this method is called as part of the model processing an event the object will store the original value of the property and then that value will be restored when the model is reset.

After setting the property value, the method will call applyProperties() for the relevant property, applying the change to template instances and overrides.

queue.setProperty("MaxContent", 5);
Do no remove, this fixes the anchor on doc.flexsim.com

Object.setRotation()

Object setRotation( double rx , double ry , double rz )
Object setRotation( Vec3 rotation )

Parameters

rx The desired rotation about the x axis.
ry The desired rotation about the y axis.
rz The desired rotation about the z axis.
rotation A vector of the desired rotation values.

Returns

Object The rotated object.

Description

Sets the object's rotation.

obj.setRotation(0,0,0);
obj.setRotation(Vec3(0,0,0));
Do no remove, this fixes the anchor on doc.flexsim.com

Object.setSize()

Object setSize( double x , double y , double z )

Parameters

x The desired x size.
y The desired y size.
z The desired z size.

Returns

Object The sized object.

Description

Sets the object's size.

obj.setSize(1,1,1);
Do no remove, this fixes the anchor on doc.flexsim.com

Object.setState()

void setState( int state , int stateProfile )

Parameters

state The desired state.
stateProfile The desired state profile.

Returns

void

Description

Sets the object's state.

Sets the state of the object to a state number. The statistics regarding state will be automatically updated when this is called. There are 50 predefined states. The predefined values for state and their associated macros are:

1 - STATE_IDLE
2 - STATE_PROCESSING
3 - STATE_BUSY
4 - STATE_BLOCKED
5 - STATE_GENERATING
6 - STATE_EMPTY
7 - STATE_COLLECTING
8 - STATE_RELEASING
9 - STATE_WAITING_FOR_OPERATOR
10 - STATE_WAITING_FOR_TRANSPORT
11 - STATE_BREAKDOWN
12 - STATE_SCHEDULED_DOWN
13 - STATE_CONVEYING
14 - STATE_TRAVEL_EMPTY
15 - STATE_TRAVEL_LOADED
16 - STATE_OFFSET_TRAVEL_EMPTY
17 - STATE_OFFSET_TRAVEL_LOADED
18 - STATE_LOADING
19 - STATE_UNLOADING
20 - STATE_DOWN
21 - STATE_SETUP
22 - STATE_UTILIZE
23 - STATE_FULL
24 - STATE_NOT_EMPTY
25 - STATE_FILLING
26 - STATE_STARVED
27 - STATE_MIXING
28 - STATE_FLOWING
29 - STATE_ALLOCATED_IDLE
30 - STATE_OFF_SHIFT
31 - STATE_CHANGE_OVER
32 - STATE_REPAIR
33 - STATE_MAINTENANCE
34 - STATE_LUNCH
35 - STATE_ON_BREAK
36 - STATE_SUSPEND
37 - STATE_AVAILABLE
38 - STATE_PREPROCESSING
39 - STATE_POSTPROCESSING
40 - STATE_INSPECTING
41 - STATE_OPERATING
42 - STATE_STANDBY
43 - STATE_PURGING
44 - STATE_CLEANING
45 - STATE_ACCELERATING
46 - STATE_MAXSPEED
47 - STATE_DECELERATING
48 - STATE_STOPPED
49 - STATE_WAITING
50 - STATE_ACCUMULATING


if (current.subnodes.length <= 1)
	current.setState(STATE_EMPTY);
			

This sets the state of the object referenced by current to "empty" if the content of current is less than or equal to 1.

Do no remove, this fixes the anchor on doc.flexsim.com

Object.setVariable()

void setVariable( string variableName , Variant value )

Parameters

variableName The name of the variable.
value The desired variable value.

Returns

void

Description

Deprecated. Use setProperty(). Sets the value of an object's variable.

If this method is called as part of the model processing an event the object will store the original value of the variable and then that value will be restored when the model is reset.

obj.setVariable("maxspeed", 5);
Do no remove, this fixes the anchor on doc.flexsim.com

Object.stop()

void stop( int state , int id , int priority , int stateProfile )

Parameters

state The state the object will go into.
id Optional. For matching stop requests with resume requests.
priority Optional. For breaking ties between stop() calls.
stateProfile Optional. The state profile on which to record the state.

Returns

void

Description

Stops the object, sets its state, and waits for resume().

Tells the object to stop whatever it is doing, go into the state specified (in the state profile if specified), and waits for resume() to be called. Stop() calls are accumulated, meaning if stop()) is called twice on the same object, the object will not resume its operations until resume()) has been called twice as well. Stopping an object depends on the type of object that is being stopped.

For FixedResources, generally events are delayed indefinitely, input and output is stopped, and all operations going into and out of the object are stopped. This means that TaskExecuters trying to load/unload to or from the object will have to wait until the object has been resumed.

For TaskExecuters, events are not delayed, but rather a preempting task sequence with priority of 100,000 is created for the TaskExecuter, with one TE_STOP task in it.

Be aware that, if there are several stop requests for the same object, the state for each stop request is not remembered. If an object is requested to stop by entity A with state 12, and then is later requested to stop by entity B for state 14, it will go into state 14 and forget state 12. Even if entity B resumes the object before entity A, the object will remain in state 14 until all stop requests have resumed.

The id and priority parameters are optional and were added to fix the problem in the previous paragraph. If you specify these parameters, then it will store a record of the stop request, instead of just incrementing a value for the number of stops requested. The id is like a key for that stop request. The priority allows the object to prioritize its stop requests. For example, if you have a stop request for the scheduled down state, and another for the breakdown state at the same time, technically the object should be in two states at once, but since a FlexSim object can only be in one state at a time, the priority value breaks the tie and goes into the state of the highest priority stop request.

The id value should match an id value that is added to a resume() call later on. This is for matching stop requests with their appropriate resume requests. For example, if you stop an object for scheduled maintenance with and id of 1, once the scheduled maintenance is finished, you will need to resume the object with the same id of 1.

current.stop(STATE_CLEANING, 1);