Is there a shortcut for "move to origin"


#1

A lot of the times I need to move an object to the origin. That is from the center of the bounding box of the selected object to world origin. Right now I am doing this as follows:

  1. turning on grid snaps
  2. dragging the gumball
  3. snapping to origin

I was hoping there is a shortcut (command) that would do that in one step. Is there?


(Menno Deij - van Rijswijk) #2

You will need to define which part of the object needs to be on the origin. Maybe this small macro can help you:

_Move _Pause _Pause w0,0,0 _Enter

Basically, it starts the Move command, then Pause to let you select the object, then Pause to let you select the point on the object that needs to move to the origin. Then it give the origin in world coordinates (w0,0,0) and ends the command with Enter.

This small macro can be pasted into the commandline of Rhino, or you can attach it to a button (Tools -> Toolbar Layout), or a shortcut key (Tools -> Options -> Keyboard).


#3

Here is a quick script that will move an object or a selection of objects from their bounding box center to the world origin.

–Mitch

"""Moves selected objects from their bounding box center to the world origin
Script by Mitch Heynick 29.01.2015"""

import rhinoscriptsyntax as rs

def MoveObjsBBCtrToW0():
    objs=rs.GetObjects("Select objects to center at world 0",preselect=True)
    if not objs: return
    rs.EnableRedraw(False)
    origin=rs.coerce3dpoint([0,0,0])
    for obj in objs:
        bb=rs.BoundingBox(obj)
        if bb:
            ctr=(bb[0]+bb[6])/2
            rs.MoveObject(obj,origin-ctr)
MoveObjsBBCtrToW0()

#4

Hi Mitch,
this script is what I’m looking for to move objects to a certain quote. But is it possible to modify this script to move objects from their bounding box lower corner?

thank you


#5

Sure… The following moves from the lower left hand corner to the origin.

"""Moves selected objects from their bounding box lower left corner to the world origin
Script by Mitch Heynick 15.10.17"""

import rhinoscriptsyntax as rs

def MoveObjsBBLLCToW0():
    objs=rs.GetObjects("Select objects to center at world 0",preselect=True)
    if not objs: return
    rs.EnableRedraw(False)
    origin=rs.coerce3dpoint([0,0,0])
    for obj in objs:
        bb=rs.BoundingBox(obj)
        if bb:
            rs.MoveObject(obj,origin-bb[0])
MoveObjsBBLLCToW0()

#6

Fantastic!!!
Last question…if I wanted to move the object only in z axes?

thank you very very much


#7

Sure - below is my “Align bottom to world 0” script. This one is a bit more sophisticated as it has a command line option to move objects individually (default) to align with 0, or as a group together so that object relationships are preserved. The command line option is only available if you do not pre-select objects.

Edit - fixed bug, revised script below

AlignBottomToWorldZero.py (2.3 KB)

–Mitch


#8

Hi Mitch and thanks a lot for the time you spent to help me.

I tried this script but it seems to have something wrong. Please, take a look to the image below.

bye

script


#9

Hmm, odd, looks like a line got left out in the script in my library, must have fixed it somewhere else and forgot to update the copy in my library. I’ve fixed the link above, just re-download.

–Mitch


#10

Hi numan,
For moving an object into origin, I normally use Move and then press “0” and confirm. It’s the same with Align - Vertical - “0” - confirm.


#11

@ Hi Mitch,
you are a genius! Thank you very much! I have been looking for such a script for 1 year.

@ Hi Jonish,
yes, before Mitch script I used Allign Vertical but if you are in Perspective view it doesn’t lower to to z=0.
Moreover, this Mitch script allows me to create some buttons with preset heights.

bye


#12

Hi Mitch,
when I use the scripts, my windows flash 2 or 3 times and some functions crash (for example Aero Peek of windows, the drivers of the printer) and some software stops to work. It’s like a conflict between these scripts and my graphic card.
I use win 7 pro 64 bit and Graphic card Gigabyte GTX 1060.
Any idea…

bye


#13

Wow, never heard of that before… I use these scripts all the time on Windows 7, 8 and 10 with various graphics cards, no problem. The only thing the script does that has anything to do with screen graphics is that it cuts the screen refresh while the geometry is being created/transformed/added to the document, then does a refresh at the end - which is also standard operating procedure for most native Rhino commands.

So, I don’t know what to tell you on this one… Is your graphics driver up to date? Are you experiencing any similar problems with any of the native Rhino functions?

–Mitch


#14

Hi Mitch,
no, I never had this kind of problem. Now I’m trying these scripts on my laptop (wind 10 and a crappy graphic card) and everything is fine. :slight_smile:

I’ll check for driver update of my gtx1060 and I will let you know

Thanks a lot for your tips

bye


#16

Hi Helvetosaur, and happy new year!

Hi can’t solve the “flash” problem of the script…I think that the issue comes from my graphic card but even with the new driver the problem is still here. Do you know if there is a translator of Python to Rhinoscript? Maybe a script in Rhinoscript could solve it?

Bye


(Miled Rizk) #17

Generally, i turn Snappy Dragging ON for the Gumball,

From that point on, i can click, for example, on the X axis, start moving it a little and without releasing the

mouse button i type 0 and hit Enter. the object’ X moves to 0. And if i use the small rectangle representing

the XY plane for the Gumball, i can have the object’s XY centered on the origin. same thing goes for the Z.

Note: If two objects are selected, using this trick can have an averaging result.


#18

Here is an old .rvb from my library, it doesn’t support grouping, but maybe you can at least tell if it flashes or not…

AlignBottomToZero.rvb (559 Bytes)

–Mitch


#19

@Miled: thanx for you tip. It works fine if I want to move the object to 0 but is it possible to move to another coordinate?
@Mitch: Yesss, it works without flashing!!! Thank you a lot. Now…How can I modify z (different from 0)?

bye


(Miled Rizk) #20

@fabrizio_simonetti, for other coordinates, you need to type the X and Y values, at least, separated by comma.

of course if you like the object to move on the Z axis you need to provide the: X,Y,Z

For example, to get an object to be at 10 units away from the origin in the X axis and 3 in the Y axis, while

holding the small square, representing the X Y plane, and moving it a little, type in: 10,3 and press Enter


#21

I guess you can try this one… After the objects are selected, you are prompted for a Z value. Type in a value or just hit Enter if you want Z0. All objects move individually, does not support grouping.

AlignBottomToZValue.rvb (705 Bytes)

HTH, --Mitch