读取文本文档中的数据,每行为两个点的坐标:x1,y1,z1,x2,y2,z2,在场景中批量生成样条线
# XYZ to PolygonObject
# 908video / Michael Auerswald
# 908video.de / 908lab.de
import c4d
from c4d import gui
INVERT_Z = False
SCALE = 1.0
def main():
# Get input file
pts_file = c4d.storage.LoadDialog(title="Open XYZ file for processing", flags=c4d.FILESELECT_LOAD, def_path="d:\\")
if pts_file is None:
return # cancelled
doc = c4d.documents.GetActiveDocument()
lines=[]
lid=0
with open(pts_file,"r") as pts:
num_points = sum(1 for line in pts)
print("XYZ point count: " + str(num_points))
pts.seek(0)
mult_z = 1.0
if INVERT_Z is True:
mult_z = -1.0
idx = 0
for line in pts:
lines.append(c4d.SplineObject(2,1))
new_obj =