Forgot password?

Create an account!


« back

RhinoScript – move an existing box in the z direction


Please log in to write a message.

  • 3. Hanno (Dec 14, 2010 09.30):

    BTW: You can also call MoveObject with a translation vector instead of start and end point, like this:

    Call Rhino.MoveObject(box, array(0, 0, i))
  • 2. Hanno (Dec 14, 2010 09.27):


    in terms of data structure, a point is nothing more than an array of 3 doubles. So if you want to alter the z coordinate, you don't even have to use AddPoint:

    Dim last : last = array(coord(0), coord(1), coord(2)+i)

    This gives you a perfectly valid point.
    Or, maybe better readable:

    Dim last : last = coord
    last(2) = last(2) + i

    First make a copy and then alter the third array item (z).



  • 1. Archimy (Dec 12, 2010 11.42):

    hey all,
    Ive been a GH user for some time now but I'm trying to get into scripting. I am trying to write a simple code that takes existing boxes and moves them by a random factor between -15 and 15 in the z direction from their current position. I have the code working except for the moveobjects function itself where i need a start point and an end point. for the start point i used surfacevolumecentroid to get the start point but I am stuck on the end point. basically i need to take the coordinates of the start point and add the z coordinate by the random value. this is what i have if anyone has help for me i would appreciate it.


    Sub Main()
            Dim box
            box = Rhino.GetObject("Select objects to move", , , True)
            If IsNull(box) Then Exit Sub

            Dim start: start= Rhino.SurfaceVolumeCentroid(box)
            Dim coord: coord= Rhino.pointcoordinate(start)
            Dim i :i= int((15*RND)-15)
            If -15>i<15 Then print("true")
            Dim last: last= Rhino.AddPoints(coord(0),coord(1),coord(2)+i)
            Call Rhino.MoveObject(box,start,last)
    End Sub

Why are these buttons gray?