Export/Import Points将点以txt格式输出、输入

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

例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( "
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值