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:
turning on grid snaps
dragging the gumball
snapping to origin
I was hoping there is a shortcut (command) that would do that in one step. Is there?
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).
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()
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?
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()
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.
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.
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.
@ 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.
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…
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?
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.
I’ll check for driver update of my gtx1060 and I will let you know
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?
@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)?
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.