Align objectA center to $object center, non pivots?

Become a member of the CGSociety

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

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 04 April 2012   #1
Align objectA center to $object center, non pivots?

I cant seem to find out how to align an object by the name of "A", to the selected object using maxscript unless both pivots are centered.

So how would I go about aligning an object with a specific name to the selected object regaurdless of pivots.

I know I could a.position = selection.position as long as both ojects have the pivots centered, but how can I achieve the same results without changing the pivots?
 
Old 04 April 2012   #2
Hi there,

See maxscript manual for more information, but there is a center property. Use it to calculate offset between pivot and this center property to place you object's center to other objects center.

Something like this (in it's simplest form)
sOffset = $sphere.center - $sphere.pos
$sphere.pos = $teapot.center
$sphere.pos -= sOffset

Here is a thread about node transform properties: Get Local transform in Maxscript
__________________
Scripting and Rigging Reel 2012 - Open for full-time position or freelance work
 
Old 04 April 2012   #3
I would figure out the difference from center to center and move the first object that distance. You need to calculate it from destination minus source, and move the source that distance.

dst = $
src = $'A'
objMove = dst.center-src.center
move src objMove

or
dst = $
 src = $'A'
 objMove = dst.center-src.center
src.pos += objMove


-Eric
__________________
"The Evil Monkey hiding in your closet."
 
Old 04 April 2012   #4

$source.center = $target.center
 
Old 04 April 2012   #5
Thanks All!!

Originally Posted by denisT:

$source.center = $target.center

This looked like the simplest way so I used this and it works perfect!

Kind of makes me feel dumb since its pretty much my title.

Is there any downfalls to this method? Does it work with most other versions of max?

Last edited by Opifex : 04 April 2012 at 10:27 PM.
 
Old 04 April 2012   #6
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
CGSociety
Society of Digital Artists
www.cgsociety.org

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

All times are GMT. The time now is 02:53 AM.


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