question

omer0 avatar image
0 Likes"
omer0 asked Natalie White answered

Distance checker

Hello How can I check for the distance between multiple processors in general?

FlexSim 23.1.3
traveldistancedistancetotravel
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

·
Natalie White avatar image
0 Likes"
Natalie White answered

Hi @omer0,

You can do this by using the Vec3 class, which you can read about here: https://docs.flexsim.com/en/23.1/Reference/CodingInFlexSim/FlexScriptAPIReference/Data/Vec3.html

Here is some code that you can copy into your script window. When you run this script, it will give you the distance between Processor1 and Processor2.

Object obj1 = Model.find("Processor1");
Object obj2 = Model.find("Processor2");

Vec3 centres=Vec3(0.5,0.5,0.5); // set up centre factors for the axes
Vec3 locDiff=obj1.getLocation(centres).project(obj1.up,model())-obj2.getLocation(centres).project(obj2.up,model());   // projecting onto the model in case they are in different containers/coordinate systems
double distance=locDiff.magnitude;
return distance;
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.