How do you move an object's Z-Axis only?

import rhinoscriptsyntax as rs
import random
def ImportPoints():

sampling = 50
filename = rs.OpenFileName("Open File")
if not filename: return
file = open(filename, "r")
lines = file.readlines()
file.close()

image = []

for line in lines:
    image.append(line.strip("/n").split(","))
for j in range(0,len(image),sampling):
    for i in range(0, len(image[j]), 3*sampling):
        red = int(float(image[j][i]))
        green = int(float(image[j][i+1]))
        blue = int(float(image[j][i+2]))
        if red < 40 and green < 40 and blue < 100:
            width = 6000
            depth = 6000
            height = 3000
            p1 = [i/3,j,0]
            p2 = rs.VectorAdd (p1, [width,0,0])
            p3 = rs.VectorAdd (p2, [0,depth,0])
            p4 = rs.VectorAdd (p3, [-width,0,0])
            p5 = rs.VectorAdd (p1, [0,0,height])
            p6 = rs.VectorAdd (p2, [0,0,height])
            p7 = rs.VectorAdd (p3, [0,0,height])
            p8 = rs.VectorAdd (p4, [0,0,height])
            boxGarage = rs.AddBox ([p1, p2, p3, p4, p5, p6, p7, p8])
            rs.ObjectColor(boxGarage, (red, green, blue))
            for l in range(height):
                rs.MoveObject(boxGarage, (0, 0, random.randint(0,l)))

I only want move the z-axis in random without move x,y axis. But (0,0,random.randint(0,l)) move my boxes in same x,y axis.How can I do that?

Hmm, I don’t know why you need this line:
for l in range(height):

As far as I understood, you don’t need a loop here and you’re running that loop 3000 times for each box object… Also, on every iteration you are redefining “l”

I would just eliminate that line and the loop altogether…

            #...
            boxGarage = rs.AddBox ([p1, p2, p3, p4, p5, p6, p7, p8])
            rs.ObjectColor(boxGarage, (red, green, blue))
            rs.MoveObject(boxGarage, rs.coerce3dvector([0, 0, random.randint(0,l)]))

Which should move each box in Z by a random integer between 0 and height (3000)…

Thank you, Helvetosaur

import rhinoscriptsyntax as rs
import random
def ImportPoints():

sampling = 50
filename = rs.OpenFileName("Open File")
if not filename: return
file = open(filename, "r")
lines = file.readlines()
file.close()

image = []

for line in lines:
    image.append(line.strip("/n").split(","))
for j in range(0,len(image),sampling):
    for i in range(0, len(image[j]), 3*sampling):
        red = int(float(image[j][i]))
        green = int(float(image[j][i+1]))
        blue = int(float(image[j][i+2]))
        if red < 40 and green < 40 and blue < 100:
            width = 6000
            depth = 6000
            height = 3000
            p1 = [i/3,j,0]
            p2 = rs.VectorAdd (p1, [width,0,0])
            p3 = rs.VectorAdd (p2, [0,depth,0])
            p4 = rs.VectorAdd (p3, [-width,0,0])
            p5 = rs.VectorAdd (p1, [0,0,height])
            p6 = rs.VectorAdd (p2, [0,0,height])
            p7 = rs.VectorAdd (p3, [0,0,height])
            p8 = rs.VectorAdd (p4, [0,0,height])
            boxGarage = rs.AddBox ([p1, p2, p3, p4, p5, p6, p7, p8])
            rs.ObjectColor(boxGarage, (red, green, blue))
            rs.MoveObject(boxGarage, rs.coerce3dvector(0, 0, random.randint(0,height)))

class pixel:

pixelList = []

def __init__(self):
    pixelList.append(self)

if( name == “main” ):
ImportPoints()

Message: coerce3dvector() takes at most 2 arguments (3 given)

Traceback:
line 35, in ImportPoints, “C:\Users\52012\AppData\Local\Temp\TempScript.py”
line 47, in , “C:\Users\52012\AppData\Local\Temp\TempScript.py”

When I import csv. file, Something wrong?

Yeah, sorry, it should be
rs.coerce3dvector([0, 0, random.randint(0,height)])
You need the brackets