Snippets Collections
/** Macros in FlexSim*/
/*By writing the root of a macro: the root is the basic part of the macro name and it carries its foundmental meaning*/

// list of macros in flexsim 

// 1. DATATYPE root
DATATYPE_NUMBER

// 2. STAT root
STAT_OUTPUT

//3. STATE root
STATE_BLOCKED

//4. photo eye PE root
PE_STATE_BLOCKED

// 5. 
/**Reference and Control the conveyor item from the script*/
Conveyor conveyor = Model.find("DP23").as(Conveyor.DecisionPoint).conveyor;
Object enteringItem = Model.find("DP23").as(Conveyor.DecisionPoint).activeItem;
Conveyor.Item conveyorItem = conveyor.itemData[enteringItem];
applicationcommand("showconsole", CONSOLE_OUTPUT);
clearconsole;

// conveyor item properites
print(conveyorItem.entrySpace);
print(conveyorItem.movingSpace);
print(conveyorItem.currentDistance);
print(conveyorItem.destination);
print(conveyorItem.position);
print(conveyorItem.totalDistance);

// conveyor item methods=
conveyorItem.turn();
conveyorItem.stop();
conveyorItem.resume();
Conveyor.DecisionPoint current = ownerobject(c);
Object item = param(1);
Conveyor conveyor = param(2);
Conveyor.Item conveyorItem = conveyor.itemData[item];
/**send Item*/

// 1. send item by percentage
if(bernoulli(30, 1, 0)){
	Conveyor.sendItem(item, current.outObjects[1]);
}


// 2. send item by item type (label)
Array dpArray = current.outObjects.toArray();
//int itemType = item.Type;
for (int index = 1; index <= dpArray.length; index++){
	if(item.Type == index){
		Conveyor.sendItem(item, current.outObjects[index]);
	}
}

// 3. same as previous but shorter

Conveyor.sendItem(item, current.outObjects[item.Type]);
// Model execution commands
resetmodel();
runspeed(10);
stoptime(3000);
fastforward();
go();
step();
skip();

// in case of debuging an error that takes place at a specific time:
stoptime(300); // change 300 to the exception time
runfunction(1); // will execute the model untill reacing first stoptime defined.


for(int i = 1; i <= 5; i++) { msg("for loop","Hi there " + i + " !", 1); }
star

Thu Jan 25 2024 14:32:42 GMT+0000 (Coordinated Universal Time)

#flexscript
star

Wed Jan 24 2024 16:54:56 GMT+0000 (Coordinated Universal Time)

#flexscript #dp #conveyor
star

Tue Jan 23 2024 14:34:57 GMT+0000 (Coordinated Universal Time)

#flexscript #dp #conveyor
star

Fri Jan 19 2024 19:15:19 GMT+0000 (Coordinated Universal Time)

#flexscript

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension