Python insert objects and move: iteration over non-sequence of type function

script
rhino
python

#1

Hi, I have this problem when I try to use python script to read and insert 3dm object through a csv file and move them to the correct position, also read from a csv file.

import rhinoscriptsyntax as rs
import Rhino.Geometry as rg
import Rhino
import scriptcontext
import System.Guid
import scriptcontext as sc
import os
#############################################
#Select a file to open
filename = rs.OpenFileName("Open CSV file","*.csv|", None, None, None)
 
#open the file for reading
file = open(filename, 'r')
lines = file.readlines() 
file.close()
del lines[0]

#Read the lines in excel sheet and define the values needed
for line in lines:
    line = line.rstrip()
    ptInfo = line.split(',')
 
    ## Start to Insert objects
    #Read the position coordinates of the object
    x = 1000*float(ptInfo[4])
    y = 1000*float(ptInfo[5])
    z = 1000*float(ptInfo[6])  
    arrPoint = x,y,z

    #Read the path and insert the object
    file = ptInfo[7]
    rs.Command('_-Import ' + file + ' _Enter')

    #Try to move it to the correct position
    arrObjects = rs.LastCreatedObjects
    rs.MoveObjects(obj, arrPoint)

#2

@Yang_Cao,

try to create a vector from the 3 coordinates and pass it to rs.MoveObjects():

    # create the vector
    arrPoint = Rhino.Geometry.Vector3d(x,y,z)

    #Read the path and insert the object
    file = ptInfo[7]
    rs.Command('_-Import ' + chr(34) + file + chr(34) + ' _Enter')

    #Try to move it to the correct position
    arrObjects = rs.LastCreatedObjects()
    rs.MoveObjects(arrObjects, arrPoint)

Ps. Always use double quotes around your file to prevent errors with spaces in the file path.

c.