Querying the Center of an Object

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

Thread Tools Search this Thread Display Modes
Old 02 February 2009   #1
Question Querying the Center of an Object

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 ?
Old 02 February 2009   #2
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 )

Last edited by claydough : 02 February 2009 at 05:16 AM.
Old 02 February 2009   #3
//select -r [yourmesh]
vector $obj_c = `getAttr .c`;
print $obj_c
.쳱 v+f-e=p(2)
-----------will be done
Old 02 February 2009   #4
Thanks for the Replies

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
Old 03 March 2009   #5

Originally Posted by Dontnoun:
//select -r [yourmesh]
vector $obj_c = `getAttr .c`;
print $obj_c

`getAttr .c` what's c is stand for? who can tell me?
Old 03 March 2009   #6
getAttr .c 是 getAttr .center的缩写
.쳱 v+f-e=p(2)
-----------will be done
Old 03 March 2009   #7
Thread automatically closed

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.
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
Thread Closed share thread

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Society of Digital Artists

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump

All times are GMT. The time now is 07:37 AM.

Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.