Page 1 of 1

Separate position x and y coordinates in IDE

Posted: Tue Jun 23, 2015 1:32 pm
by totebo
I often want to set bodies to a common x or y coordinate.

As an example, I would like to change the x position of five bodies to 0, and retain their current y position.

This is how it is achieved currently:

1. Select one of the five bodies
2. Select the "Position" textfield property
3. Select what's left of the comma and change it to the correct value
4. Goto 1 for the remaining four bodies

Separating x and y positions would reduce the workflow to:

1. Select all five bodies
2. Enter 0 in the x position textbox and press enter

This would also be useful for vertices.

Cheers,

Niclas

Re: Separate position x and y coordinates in IDE

Posted: Tue Jun 23, 2015 2:44 pm
by iforce2d
Here is a script to do that:

Code: Select all

float x = queryNumericValue("Enter value to align with");

body[] bs = sb();
for (uint i = 0; i < bs.length; i++) {
	body b = bs[i];
	b.setPos( x, b.pos.y );
}
This is doing it for the x coordinate, but I think you can see how to make a similar script to change the y coordinate.

Re: Separate position x and y coordinates in IDE

Posted: Tue Jun 23, 2015 2:46 pm
by iforce2d
For vertices, perhaps you could try:

1. hit C,C to enter a cursor position manually
2. in the action menu choose "Vertex" -> "Align X to cursor"

Re: Separate position x and y coordinates in IDE

Posted: Mon Jul 06, 2015 8:14 pm
by totebo
Excellent! First time I use a Script and it works a charm.

Niclas