PDA

View Full Version : Align objectA center to $object center, non pivots?


Opifex
04-04-2012, 09:00 AM
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?

Transmuter
04-04-2012, 10:02 AM
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 (http://forums.cgsociety.org/showthread.php?t=525388)

PiXeL_MoNKeY
04-04-2012, 12:52 PM
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

denisT
04-04-2012, 02:08 PM
$source.center = $target.center

Opifex
04-04-2012, 08:04 PM
Thanks All!!


$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. :shrug:

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

CGTalk Moderation
04-04-2012, 08:04 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.