Bodies don't have any height or width of their own, they have fixtures.
Fixtures have vertices (for polygon/line/loop) or a radius (for circles).
It's the location of the vertices (or the radius of the circle) that define what we might commonly think of as the 'width' etc of a fixture. Note that bodies can have multiple fixtures so the overall 'width' or 'height' of a body would be the total of all its fixtures.
I think what's needed in this case is to manually position the vertices of a fixture. You can do this by selecting the vertices (in vertex edit mode) and entering a value for either the body coordinate or world coordinate. This is a bit tedious. If creating a new shape, you can start by doing 'Add a square fixture' which will give a 1x1 square, and then scale (restricted to X or Y axis if necessary) to make it 2x3 or whatever you need. This is all very well if the result you want is a nice factor to scale by, but not so easy if you want to set the sizes to more arbitrary values.
You could try this script which might make things easier. You need to select the fixture you'll be dealing with before running it. It will query you for the width and height, and then set the vertices as appropriate. It assumes the fixture is already set to be a polygon type.
Code: Select all
fixture f = sf()[0];
float width = queryNumericValue("Width:",1);
float height = queryNumericValue("Height:",1);
float w = width / 2;
float h = height / 2;
vec2[] verts;
verts.insertLast( mv(-w,-h) );
verts.insertLast( mv( w,-h) );
verts.insertLast( mv( w, h) );
verts.insertLast( mv(-w, h) );
f.setVertices( verts );