Distance checker

omer0
Not applicable
3 Views
1 Reply
Message 1 of 2

Distance checker

omer0
Not applicable

[ FlexSim 23.1.3 ]

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

0 Likes
Accepted solutions (1)
4 Views
1 Reply
Reply (1)
Message 2 of 2

natalie_white
Not applicable
Accepted solution

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;
0 Likes

Type a product name