Notifications
Clear all

[Closed] Selection.center – weighted?

I’m using selection.center in a script and noticed that it seem to be weighted. Is that so?
If I have three objects selected and two of them are closer together the center is closer to the two.
What I need is a way to get the unweighted center of a selection something like:
(maxpos-minpos)/2.
Does anyone knows if there is a way to do that without calculating it manually?

5 Replies

Hi Pixero,

I dont think the $.center is weighted.

Just did some testing and found no weighting at all, also the mxsref dosent suggest any weighting:

(

[left]<objectset>.center : Point3, read-only[/left]

[left]Returns center of bounding box of all objects in set.[/left]

)

it only operates on the boundingbox of the selection.

Here is a picture of the problem.

Create three objects with one between the others slightly closer to one of them.
Select the two outer objects. Now select the middle one. The “center” is moved.
This shouldnt affect the center since its between the others. Or am I totally wrong here…?

Selection.center returns the center of the bounding box.
The UI Selection Gizmo uses the AVERAGE of the 3 positions (A+B+C)/3.
So they are rather different…

If you would create a point using
Point pos:$.center
the resulting Point helper would not be aligned to the rotation gizmo shown when selecting all 3 but to the center of the bounding box of the outer 2 objects.

Selection.center returns the center of the bounding box.
The UI Selection Gizmo uses the AVERAGE of the 3 positions (A+B+C)/3.
So they are rather different…

So if you rotated or moved a selection of objects in the viewport they would end up a different place than if I did it with selection.center in a script?

Does that mean its impossible to have a numeric input transformation that works on a selection of objects, update (getting its default values from) and work together with transformations in the viewport and behave the same way? If so, thats a major drawback.
Are there any other way of doing what I want? I don’t think it would be a good idea to use the average.

I’m a longtime Maya user considering a switch to Max for my new job as arch viz and I’m trying to find a workflow in Max that resembles working with the Maya channelbox for precise transforms/rotations/scale. (That means Translate, rotate and scale in one window and not three like in Max.) I thought I’d write a Max channelbox as a way of learning Maxscript. It seems it wasnt so easy. :shrug:

All the transformation scripts I’ve found have a default value of 0 but I want it to be the current position/rotation/scale. I also want it to work with a selection of objects/vertices/edges or even different object types like lights and so on. It should also update if the selection changes or if you transform manually in the viewport. Possibly also work in world space and local space.
Does anyone know if there is such a script out there somewhere?

Maybe if there is any interest, I could post my first steps in Maxscript and we could see if we can come up with something useful.

1 Reply
(@bobo)
Joined: 11 months ago

Posts: 0

Yes, the viewports do not use the same method you are using, so it is logical to get different results. The average of the centers is what the Max transforms use when in “Use Selection Center” mode. The center of the commong bounding box is what you are using.
If you don’t think it is a good idea, it is your opinion. If you think that both are good ideas, you can implement them both as options in your tool…