XM Magdalena 3D print, GGeorgy (3D)
LC #42 Pipers Alley

View Full Version : Querying the Center of an Object

02-24-2009, 01:58 AM
Hi there im currently doing an assignment where i need to find out the center of an object , anybody know the mel command to do this ?

02-24-2009, 04:14 AM
on the shape of the object.

The bounding box area of an object does not always produce a center.
( which I believe is how Maya xform -cp works )
The center of a pentagon fer instance will be wrong if you xform -q -ws -rp
Even after "centering pivot".

As far as I know there isnt a mel command that will "truley" get center for every case.

( for the pentagon tho.. I believe u can git radius from any two "base's mid points" connected to their opposite "corner points" the intersection of jes two such division's would be a true pentagon center )


The Manipulators represent false bounding approximation.

if u continue around the shape till finished then delete the base mid points' connecting edges
leaving center to corner points' edges:


we can now clearly see by the equidistant tris, the error of the manipulator position
( making a cylinder with 5 sides will produce caps with the same result... truely centered intersection of tri tips )

Not sure if this is what yer assignment requires, but I would recommend custom logic for finding center in real world scenarios ( i.e., yer glorious maya coding future )

02-24-2009, 09:18 AM
//select -r [yourmesh]
vector $obj_c = `getAttr .c`;
print $obj_c

02-26-2009, 01:21 AM
Hey guys thanks for the replies =D it all helps hey im totally new to the whole MEL scene so gettin my head around it slowly ;P , busy writing a basic lighting script so reason for asking was to find out the center of an object so i can snap the say " Spotlights " center of interest to the exact center of an object so they would be aimed at whatever object upon creation

But yeah ill keep grinding it :P

03-03-2009, 03:37 PM
//select -r [yourmesh]
vector $obj_c = `getAttr .c`;
print $obj_c

`getAttr .c` what's c is stand for? who can tell me?

03-03-2009, 05:13 PM
getAttr .c 是 getAttr .center的缩写

CGTalk Moderation
03-03-2009, 05:13 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.