Is there a macro to input the center of an object?

Hi all,

Sometimes if I’m modeling an object I want to just quickly input the center using the command line (such as during a Rotate3D) Does anyone know how to do this?

-Paul

Gumball is aligned to the center of a boundingbox (world or cplane)

preselect the object then run

_boundingbox _world _enter
_selNone
_sellast
_VolumeCentroid
_delete

if you need some other definition for “center” - please give more info or an example

kind regards - tom

Hi Tom, thanks for your reply.

A quick example would be:

I have this box and I want to rotate it in 3D, and I want the rotation axis to go from the center point to one of the top edges of the box. I could make a center point with AreaCentroid and draw the line from there but I’m wondering if there’s a faster way to just automatically input the centerpoint of the object using a command or macro.

Have you considered using the Gumball?

1 Like

Definitely, I’m aware that the gumball offers a good, easy way to do this, but I also think that for the purpose of writing macros there is some additional utility in being able to auto-input the object’s center.

The gumball would not work with a Rotate3D in this vector, for example

This previous topic might give some additional clarity

So…it sounds like Tom’s solution would solve your problem, right?

Too bad gumball isn’t working well for you. In the case you ask about (I’m assuming you want to rotate around the red line), I have a key set to GumballRelocate, and so I can create that axis with a button press and two mouse clicks. The other way I use Gumball is with this macro (written by Pascal) that puts a point at the gumball location, which I can then use for other things:
! _SetRedrawOff _CPlane _Gumball _Point 0 _CPlane _Undo _SetRedrawOn

Hi -

That’s not something you can do with a macro - you’d need a script for that.

Somewhat faster would be to create an alias for between, e.g. “b”. You run Rotate3D, hit b, and select opposing corners of the box. That will give your start point for the axis.
-wim

1 Like

Thanks Wim! The between macro does exactly what I want, and is more versatile

There is a way to make it work with a script, as a more versatile tool that you can use while being “in command” (like drawing a polyline, rotating an object etc.).

Please try this script:
MarkObjectCenter.rvb (1.5 KB)
(save on your HD, then drag-and-drop into Rhino vport to install. The alias MarkObjectCenter will become available)
You can put that alias on a button or assign a keyboard shortcut to it.

The way it works is if you are not in command, you just pick an object and it will add a point at the center (without losing current selection).
But if you are in the middle of drawing something and need to pick a point, you can run this, it will prompt you to pick an object for center, then automatically use the center point as your current command input).

As a bonus, if you hold SHIFT when picking the object, bottom-center will be used instead.

I tested it just a bit, seems to work OK here. The limitation for now would be not working with grips selection.

hth,

–jarek

1 Like

Thanks Jarek! This is exactly what I was looking for. Tried to do it myself on ChatGPT but AI is not quite there yet, apparently (hah) - much appreciated

That’s pretty convoluted way of scripting it…(to make it work in-command) I am sure ChatGPT will learn all my tricks at some point though, by reading this forum ; )