On 17/12/2014 at 12:09, xxxxxxxx wrote:
To explain better I want to achieve this.
This script is to move certain points of my cube with python but this script is a little long and I'm sure there is a simpler shorter way to do this.
obj = doc.SearchObject("Null")
poly = doc.SearchObject("Polygon")
Points_List = [" 0, -100, -100, -100 ", " 1, -100, 100, -100 ", " 2, 100, -100, -100 ", " 3, 100, 100, -100 ", " 4, 100, -100, 100 ", " 5, 100, 100, 100 ", " 6, -100, -100, 100 ", " 7, -100, 100, 100 "]
Targ_List = [" 0, -100, -100, -100 ", " 1, -100, 60.326, -100 ", " 2, 100, -100, -100 ", " 3, 100, 100, -59.691 ", " 4, 100, -100, 100 ", " 5, 100, 165.287, 100 ", " 6, -100, -100, 100 ", " 7, -100, 15.892, 100 "]
cntrl = obj[c4d.ID_USERDATA,1]
N_des_list = []
cmp_L_A = []
for i,line in enumerate(Points_List) :
in_L = Points_List[i]
in_line = in_L.split(",")
in_nr = int(in_line[0])
in_vec_X = float(in_line[1])
in_vec_Y = float(in_line[2])
in_vec_Z = float(in_line[3])
tar_L = Targ_List[i]
tar_line = tar_L.split(",")
tar_nr = int(tar_line[0])
tar_vec_X = float(tar_line[1])
tar_vec_Y = float(tar_line[2])
tar_vec_Z = float(tar_line[3])
if in_vec_X == tar_vec_X:
N_x = 0
else:
N_x = tar_vec_X
if in_vec_Y == tar_vec_Y:
N_y = 0
else:
N_y = tar_vec_Y
if in_vec_Z == tar_vec_Z:
N_z = 0
else:
N_z = tar_vec_Z
N_des_list.append(c4d.Vector(N_x,N_y,N_z))
for line in Points_List:
coord = line.split(",")
nr = int(coord[0])
Vec_X = float(coord[1])
Vec_Y = float(coord[2])
Vec_Z = float(coord[3])
cmp_L_A.append(c4d.Vector(Vec_X,Vec_Y,Vec_Z))
for i in range(len(cmp_L_A)) :
morph = cntrl*N_des_list[i] + cmp_L_A[i]
poly.SetPoint(i,morph)
poly.Message(c4d.MSG_UPDATE)