PDA

View Full Version : F2 Center Object... is there a Modeler command for this?



BlueApple
08-01-2008, 09:25 AM
Trying to center all layers in an object about Modeler's origin, and not sure how to script the equivalent of hitting F2. I see the move command, but I'm not sure if that's the right route.

Any advice?

BlueApple
08-01-2008, 10:58 AM
I've tried the below syntax, like an ape throwing its own waste at a wall:


current_object.CenterItem();
current_object.center();
current_object.Center();

evenflcw
08-01-2008, 12:44 PM
First of all, LScript isn't object oriented.

Either create your own function where you first have to decide what you consider to be the center of a mesh - this could be the center of the boundingbox, the average point position etc etc. Second determine the offset of this center to the origin. Move it by the offset (or rather in the opposite direction).

Or try to call the native or 3rd function or plugin via CommandInput(), cmdseq() or meshedit(). But I doubt it'll work since "Center Data" seems to be an internal command. But you could use the later two to call any other plugin/script. So if you got one that centers the way you like already.

BlueApple
08-01-2008, 01:40 PM
evenflcw,

Thanks for your guidance.


//Determine the center of the current object's bounding box.
objectCenter = center(boundingbox(current_object));

//Move the mesh to the origin.
move(-(objectCenter));

Works great. Take care.

evenflcw
08-01-2008, 02:34 PM
NP. Looks great.