Script not working anymore
-
On 14/06/2014 at 23:40, xxxxxxxx wrote:
I put this script together to write the points and polys to a file to use again some place else. It worked a few times but not anymore. I tried it in a new python node but still not working.
import c4d
#Welcome to the world of Python
obj = doc.SearchObject("Head")def All_Points() :
obj_points = obj.GetAllPoints()
obj_poly = obj.GetAllPolygons()
PointFile = "D:\Users\Carel\Desktop\Point.txt"
Point_File = open('Point.txt','w')
for i, line in enumerate(obj_points) :
point_Ind = i
point_Ln = line
Point_File.write("mypoly.SetPoint(" + str(point_Ind) + ",c4d." + str(point_Ln) + ")" + '\n')
Point_File.close()
PolyFile = "D:\Users\Carel\Desktop\Poly.txt"
Poly_File = open('Poly.txt','w')
for i, line in enumerate(obj_poly) :
poly_Ind = i
poly_Ln = str(line)
Str_Line = poly_Ln.translate(None,"abcd:")
Poly_File.write("mypoly.SetPolygon(" + str(poly_Ind) + ",c4d.CPolygon" + str(Str_Line) + ")" + '\n')
Poly_File.close()
def Selected_Points() :
Pts_List = []
Max_Pts = obj.GetPointCount()
Sel_Pts = obj.GetPointS()
PointFile = "D:\Users\Carel\Desktop\Sel_Points.txt"
Point_File = open('Sel_Points.txt','w')
for index, selected in enumerate(Sel_Pts.GetAll(Max_Pts)) :
if not selected: continue
else:
Pts_List.append(index)
print Pts_List
Point_File.write(str(Pts_List) + '\n')
def main() :
if Input1 == True:
return All_Points()
if Input2 == True:
return Selected_Points()I don't get any errors, nothing.
Please anyone -
On 15/06/2014 at 06:40, xxxxxxxx wrote:
Ok I got it working again. The red color is what needs changing:
import c4d
#Welcome to the world of Python
obj = doc.SearchObject("Head")def All_Points() :
obj_points = obj.GetAllPoints()
obj_poly = obj.GetAllPolygons()
PointFile = "D:\Users\Carel\Desktop\Point.txt"
Point_File = open(PointFile,'w')
for i, line in enumerate(obj_points) :
point_Ind = i
point_Ln = line
Point_File.write("mypoly.SetPoint(" + str(point_Ind) +",c4d." + str(point_Ln) + ")" + '\n')
Point_File.close()
PolyFile = "D:\Users\Carel\Desktop\Poly.txt"
Poly_File = open(PolyFile,'w')
for i, line in enumerate(obj_poly) :
poly_Ind = i
poly_Ln = str(line)
Str_Line = poly_Ln.translate(None,"abcd:")
Poly_File.write("mypoly.SetPolygon(" + str(poly_Ind) +",c4d.CPolygon" + str(Str_Line) + ")" + '\n')
Poly_File.close()
def Selected_Points() :
Pts_List = []
Max_Pts = obj.GetPointCount()
Sel_Pts = obj.GetPointS()
PointFile = "D:\Users\Carel\Desktop\Sel_Points.txt"
Point_File = open(PointFile,'w')
for index, selected in enumerate(Sel_Pts.GetAll(Max_Pts)) :
if not selected: continue
else:
Pts_List.append(index)
print Pts_List
Point_File.write(str(Pts_List) + '\n')
def main() :
if Input1 == True:
return All_Points()
if Input2 == True:
return Selected_Points()