Move on 1 or 2 Axis

Hi all,

i’m trying to move an object on only one or two axis, for example move on XY or XZ etc…

i thought leave blank a number ( , 10 , 10 ) or use ( null , 10, 10 ) in my arrEnd , but of course that didn’t work , it seems rhino need 3 coordinates anyway.

How can i do ?

Thanks.

Call Main()
Sub Main()

	Dim 	strObject, arrStart, arrEnd
	
	strObject = Rhino.GetObject("select Object to move")
	
	arrStart = Rhino.GetPoint(" select point")	
	
	arrEnd = array(, 10, 10)
	
	Rhino.MoveObject strObject, arrStart, arrEnd
	
End Sub

@Cyver, if you want to have zero movement on one axis, enter zero for that axis:

arrEnd = Array(0,10,10) 

or, to move from the coordinate arrStart add to its coordinate eg:

arrEnd = Array(arrStart(0), arrStart(1) + 10, arrStart(2) + 10)

c.

Hi Clement,

Thanks for reply,

Yes , that was my first idea, but i think there is something i don’t understand,

Zero is a value, if i use for example arrEnd = array(10, 0, 0) , my object is moved to 10 on X , and 0 on Y And Z world axis .

Ah didn’t see you updated your post , i’ll will try that

Thanks !

Yes, you’ll need to just create a transform from your vector like below and can get rid of a start point:

Option Explicit

Call Main()
Sub Main()
    
    Dim strObject, arrVector, arrXForm
    
    strObject = Rhino.GetObject("Select object to move")
    If IsNull(strObject) Then Exit Sub
    
    arrVector = Array(10, 10, 0)
    arrXForm = Rhino.XformTranslation(arrVector)
    strObject = Rhino.TransformObject(strObject, arrXForm)

End Sub

It basically does the same as my second code snippet above.

c.

1 Like

Hi guys

It also could be simplified a little passing the vector directly to Rhino.MoveObject()

Option Explicit

Call Main()
Sub Main()
    
	Dim strObject, arrVector, arrXForm
    
	strObject = Rhino.GetObject("Select object to move")
	If IsNull(strObject) Then Exit Sub
    
	arrVector = Array(10, 10, 0)
	strObject = Rhino.MoveObject(strObject, arrVector)

End Sub

Cheers

1 Like

Hey guys,

Thanks for multiple solutions :relaxed: