Move to certain coordinate one one or two axes, without changing the other coordinates

Hello,
Is there a way to move an object using world coordinates, but leaving some axis coordinates the same?
Example: Moving an object from (12.56, 5.22, 2.14) to (12.56, 5.22, 8).
I guess typing something similar to (-,-,8).

Being the first time that I have to write a question, I want to thank you guys for being such an awesome community, and spending so much of your time helping other people. You have saved me many times over the years.

Hello - you can use relative coordinates - for your target location use r0,0,8 or @0,0,8

-Pascal

Thank you Pascal,
but wouldn’t that move my object 8 units in the z direction? i want to move it to z=8 (r0,r0,w8).
perhaps a Setpt with rigid option?

Sorry, yes, I see what you mean- you can use .x, .y, .z for this

e.g

Move Pause Pause .z 0,0,8

meaning only the Z value of the point 0,0,8 will be used when you pick a point, x and y will come from the pick point (which can be your From point)

-Pascal

Thank you very much Pascal.
I found that .z 8 (instead of .z 0,0,8) works the same.
One last question please, is there a command like copy’s InPlace, so i can avoid the last step (having to click again the From point) and put it in a macro?
Thanks again,
John

-They say laziness leads to inventiveness, so I prefer to think of myself as an inventor :laughing:

Hi John - here is something you can try on a button to see if it does anything - bascially, when you’ve set your .z and get to the part where you want the From point just Ctrl-V to the command line.

! _-RunPythonScript (

import rhinoscriptsyntax as rs
import Rhino


import rhinoscriptsyntax as rs
import Rhino
def test():
    wxy = Rhino.Geometry.Plane.WorldXY
    
    ids = rs.GetObjects("Select objects to move", preselect=True)
    if not ids: return
    
    pt = rs.GetPoint("Point to move from")
    if not pt: return
    xForm = Rhino.Geometry.Transform.PlaneToPlane(wxy, rs.ViewCPlane())
    ptCPlane = rs.PointTransform(pt, xForm)
    
    rs.ClipboardText (ptCPlane.ToString())
    print "From point copied to the clipboard, paste when you need it."
    rs.SelectObjects(ids)
    rs.Command("Move " + ptCPlane.ToString() +" " )
    
test()

-Pascal

1 Like

Hi Pascal,

Returning on the issue after some years, the python script gives me an error and doesn’t work.
line 24 is “test()”

If you could please help me.
Thank you!

Screenshot_1

Usually this error message means that something is missing from the end of the script (EOF=End Of File). Is Test() out-dented as shown above?

Hi Helvetosaur,

I copied the script as is, form Pascal’s reply. Should I change something before pasting?
Thank you

To run the script in a button, you need one more close parentheses after the line Test()
That matches the open parentheses at the top after ! _-RunPythonScript (

    ...
    rs.ClipboardText (ptCPlane.ToString())
    print "From point copied to the clipboard, paste when you need it."
    rs.SelectObjects(ids)
    rs.Command("Move " + ptCPlane.ToString() +" " )
    
test()
)  <---
2 Likes

Thank you very much!

Hi, I would like to do this kind of movement as well, but I don’t seem to get the hang of it. Can someone please elaborate how this works step by step? when I use the move command, select a point to start from, enter, and then type “.z” I can indeed specify a coordinate value, but afterwards it still asks me additionally where to move to… No matter what I type then, the object does not get moved to the z-coordinate provided…

Hi Kliefhead,
Using “.z” will lock the z coordinate on the value that you input, and then it lets you pick the x & y by clicking on a snap point. Personally I never use this way.

Here’s what I do instead
If you want to move an object to a certain z coordinate (for example z=5), without moving the object on x & y axis, you can try this:
A) Move > Vertical > 0,0,5
B) Move > Vertical > Click to snap on a point that is at the desired height.
C) In case you haven’t tried already, you could also check the box edit side panel, which is extremely useful and doesn’t get the love it deserves. You can input object coordinates there.
I show all three options on the video

Hope this helps