question

chao.g avatar image
1 Like"
chao.g asked Matthew Gillespie commented

Object location when rotated

I have one issue when placing the network nodes using code. In the attached model, I am trying to place NN156 into the right position, in the script console, I used your method to place that node, I am referencing the xloc of the rack, SecA_RM_Part_2[1] to placing the node, but it ended up in a very odd location, not sure if this is a bug or something I did wrong, It should be pretty straightforward, my idea is to use the location of those racks to place the network nodes and then connect them. Here is the model and screen shot of the issue I am having.

FlexSim 16.0.1
network nodeslocationrotationpositioncoordinates
chao.jpg (26.1 KiB)
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

Ben Wilson avatar image
1 Like"
Ben Wilson answered Matthew Gillespie commented

When you rotate an object, its position does not change. You can notice this in your model - drop a new object in your model and left-click it. You will see the position, rotation, and size in the status bar at the bottom or FlexSim. Now if you right-click the blue arrow and rotate the object, you can watch the rotation status change, but not the position or size. This is the effect that is working against you. You dropped a rack in your model at a certain position, then rotated it. The rack's position in the model did not change, though its own internal coordinates were rotated.

I can think of two solutions to get you going again. The first is to use the object's center location, rather than its 0,0, as your starting point. Get an object's center position via the following commands:

xcenter(object);// and ycenter() and zcenter()

This may work for you as long as all your objects are in the model itself, and not nested in visual tools or other container objects.

The 2nd method would be to convert from one coordinate system to another. This method will be more flexible in that it works for nested objects as well. Every object in FlexSim has its own coordinate system that its child objects inherit. For instance, if you have a processor in the model, you can click it and see its position in model coordinates in the status bar. If you have a box on that processor and you click the box to view its status bar info, you'll see that its position is in relation to the processor's universe, starting at the processor's 0,0. If that box was instead a pallet, with a box on the pallet, then the box's location is in relation to the pallet's coordinate system, and the pallet's coordinate system is in relation to the processor's, who's coordinate system is the model's - make sense?

Anyway, there is a set of commands to convert from one object's coordinate system to another:

double model_x_loc = vectorprojectx(objectProjectingFrom, 0, 0, 0, model()); //repeat for y and z -

See the command documentation for vectorprojectx for more details.

· 1
5 |100000

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

Matthew Gillespie avatar image Matthew Gillespie ♦♦ commented ·

Because of this confusion we added a new button to Quick Properties for version 7.7.

Clicking this button shows you what point on the object the position fields are using to calculate the position of the object. You can select any of these points and the fields in Quick Properties will update accordingly.

The Direct Spatials option at the bottom puts things back the way before 7.7 where the position is based of the top left corner of where the object would be before any rotations are applied.

Hovering over the different options will show you a red sphere indication where the position of the object is in that system. Hovering over the Direct Spatials option of a rotated object shows you that the position is not what you think it would be.

When you open Quick Properties the default is set to the center of the bottom plane of the object.

Note: Changing this option only updates Quick Properties. The status bar at the bottom and code that sets or gets a position are unchanged.

We also overloaded the setloc command to take 3 additional factor parameters. This way you can specify a point within the object where you want the position measured from. For example:

setloc(obj, 0, 0, 0, 0.5, 0.5, 0.5);

This sets the center of the object at the model origin.

We also added an updated Set Location pickoption that mirrors the update to Quick Properties:

1 Like 1 ·