ScriptSpot

Forum topic · General Scripting

group pivot to min.z

By ce89 · 2012-03-25

Description

I am trying to set the pivot of a currently selected group to min.z.
I can do this for an ungrouped object but I am struggling to find a way to do it if the current selection is a group.

I have looked through Maxscript help but as a novice I am totally lost. It seems groups are a bit more tricky to understand.

I need something along the lines of...(I know this is very wrong but gives you an idea)

if selection == group do (
group.pivot = [group.min.z]
)

Many thanks in advance

Comments (3)

jos · 2012-04-01

I have grouped 2 boxes,
select my group and type in the listener


$ --returns $selection
$.count -- returns 3 (but I grouped 2 boxes)
$[1] --returns $Box:Box002 @ [24.961517,-20.875172,0.000000]
$[2] --returns $Dummy:Group001 @ [-3.771587,-0.020809,-3.866821]
$[3] -- returns $Box:Box001 @ [-43.539669,16.427025,0.000000]
$[2].pivot --returns [-3.77159,-0.0208092,-3.86682]
-- i cant set the pivot of the group like this
$[2].pivot = [0,0,0]
-- if you wanne set all the pivots of all selected objects
-- you can just run through all the objects and set the pivot
-- here I set the pivot of all object incl group to its lower center

for obj in selection do
(
	obj.pivot = [obj.center.x,obj.center.y,obj.min.z]
)

ce89 · 2012-04-02

Thanks Jos,

That explanation really helped!

ce89 · 2012-03-31

No ideas guys :(

Like I say I'm very new to maxscript and cant get my head around working with groups.