Back to Browse

Auto-Build Racks in FlexSim

258 views
May 30, 2025
10:32

In this video, I demonstrate how to automatically build warehouse racks in FlexSim using FlexScript, a C++-based scripting language built into the software. This approach allows you to quickly generate complex rack layouts without manually placing each object, saving time and improving modeling accuracy. Check out the code below to follow along or adapt it for your own simulation needs! For more content like this, check out my blog: thescengineer.com **NOTE: Left angled brackets ("less than") are not allowed in YouTube descriptions, I replaced them with $. Be sure to replace all after copying. /* In this example data, every row is an unique slot location (Aisle + Bay + Level) The example code builds a single rack for each Aisle + Bay combination */ //loop through each slot for (int i = 1; i $= rackTable.numRows; i++){ string aisle = rackTable[i]["aisle"]; //int startBay = rackTable[i]["start_bay"]; //int bayStride = rackTable[i]["bay_stride"]; string bay = rackTable[i]["bay"]; string level = rackTable[i]["level"]; int startLevel = rackTable[i]["start_level"]; int levelStride = rackTable[i]["level_stride"]; //int startSlot = rackTable[i]["start_slot"]; //int slotStride = rackTable[i]["slot_stride"]; //if the rack already exists, check for slot if (objectexists(Model.find(concat(aisle,bay)))){ Object currRack = Model.find(concat(aisle,bay)); /* int bayNum = stringtonum(bay); if (currRack.getProperty("NumBays") $ (((bayNum - startBay) / bayStride) + 1)){ currRack.setProperty("NumBays", bayNum / bayStride); } */ int levelNum = stringtonum(level); startLevel = currRack.getProperty("StartLevel"); levelStride = currRack.getProperty("LevelStride"); //check if the number of levels is less than current level if (currRack.getProperty("NumLevels") $ (((levelNum - startLevel) / levelStride) + 1)){ currRack.setProperty("NumLevels", levelNum / levelStride); } } //else, create the rack else{ Object newRack = createinstance(node("MAIN:/project/library/warehousing/Rack"), model()); newRack.setLocation(rackTable[i]["x"]/12,rackTable[i]["y"]/12,0); newRack.setProperty("NumBays", 1); newRack.setProperty("NumLevels", max(stringtonum(level) / levelStride,2)); //to visually view newRack.setProperty("StartLevel", levelStride); newRack.setProperty("LevelStride", levelStride); newRack.setProperty("SlotsPerBay", 1); newRack.setProperty("BaySize", rackTable[i]["slot_width"]/12); // Width, model is in feet newRack.setProperty("LevelSize", rackTable[i]["slot_height"]/12); // Height, model is in feet newRack.setProperty("SlotSize", [rackTable[i]["slot_width"]/12, rackTable[i]["slot_depth"]/12]); // Depth, model is in feet if (rackTable[i]["facing_direction"] == "South"){ newRack.setRotation(0,0,0); } else if (rackTable[i]["facing_direction"] == "East"){ newRack.setRotation(0,0,90); } else if (rackTable[i]["facing_direction"] == "North"){ newRack.setRotation(0,0,180); } else { newRack.setRotation(0,0,270); } setname(newRack,concat(aisle,bay)); } } reset(); //newRack.setProperty("AddressScheme",...); //newRack.setProperty("Dimensions",...); //newRack.setProperty("SlotAssignmentStrategy",...); //newRack.setProperty("Visualization",...); //newRack.setProperty("SlotStackingAxis1",...); //newRack.setProperty("SlotStackingAxis2",...); //newRack.setProperty("SlotStackingAxis3",...); //newRack.setProperty("MarkOutbound",...); //newRack.setProperty("StartBay",...); //newRack.setProperty("BayStride",...); //newRack.setProperty("BayProgression",...); //newRack.setProperty("LevelProgression",...); //newRack.setProperty("StorableSlots",...); //newRack.setProperty("SlotPaddingLeft",...); //newRack.setProperty("SlotPaddingBottom",...); //newRack.setProperty("SlotPaddingRight",...); //newRack.setProperty("SlotPaddingBack",...); //newRack.setProperty("SlotPaddingTop",...); //newRack.setProperty("StartSlot",...); //newRack.setProperty("SlotStride",...); //newRack.setProperty("SlotProgression",...); //newRack.setProperty("ZoneID",...); //newRack.setProperty("AisleID",...); //newRack.setProperty("MinimumDwellTime",...); //newRack.setProperty("ExtendColumns",...); //newRack.setProperty("ShelfTilt",...); //newRack.setProperty("PickPlaceYOffset",...); //newRack.setProperty("FlowSpeed",...); ""

Download

0 formats

No download links available.

Auto-Build Racks in FlexSim | NatokHD