例1:将控制点以txt格式输出
title: Export Control Points
description: Demonstrates how to export control points with Python.
import rhinoscriptsyntax as rs
def ExportControlPoints():
"Export curve's control points to a text file"
#pick a curve object
object_id = rs.GetObject("Select curve", rs.filter.curve)
#get the curve's control points
points = rs.CurvePoints(object_id)
if not points: return
#prompt the user to specify a file name
filter = "Text File (*.txt)|*.txt|All files (*.*)|*.*||"
filename = rs.SaveFileName("Save Control Points As", filter)
if not filename: return
file = open( filename, "w" )
for pt in points:
file.write( str(pt.X) )
file.write( ", "

这篇博客展示了如何使用Python将控制点和点阵以txt格式进行输出和导入。通过示例1了解如何导出控制点,示例2讲解了点的导出,而示例三则说明了如何从txt文件中读取并导入点数据到Rhino环境中。

1661

被折叠的 条评论
为什么被折叠?



