RhinoPython展开曲面并自动分层

此脚本能将曲面或多重曲面展开,并生成规范的加工文件

#coding=utf-8

import rhinoscriptsyntax as rs
from System.Drawing import Color
zxlayer = "折线"
lklayer = "轮廓"

brep = rs.GetObject("请选择要展开的面",filter=rs.filter.surface + rs.filter.polysurface,select=True)
if brep: ur = rs.UnrollSurface(brep)
urdf = rs.JoinSurfaces(ur,delete_input=True) #结合并删除展开面

#获取外圈线border并分层
border = rs.DuplicateSurfaceBorder(urdf)
if not rs.IsLayer(lklayer):#修改图层样式
    rs.AddLayer(name=lklayer, color=Color.Black, visible=True, locked=False, parent=None)
    rs.LayerLinetype(lklayer, linetype="continucous")
rs.ObjectLayer(border,lklayer)

#获取内圈线zx并分层
zx = rs.DuplicateEdgeCurves(urdf) #先复制所有边线
if not rs.IsLayer(zxlayer):#修改图层样式
    rs.AddLayer(name=zxlayer, color=Color.Magenta, visible=True, locked=False, parent=None)
    rs.LayerLinetype(zxlayer, linetype="center")
rs.ObjectLayer(zx,zxlayer)

for i in zx:
    midp = rs.CurveMidPoint(i) #获取中点,若中点在外圈上,则删除
    for j in border: #此处用循环避免轮廓线为多条曲线报错
        if rs.IsPointOnCurve(j, midp):
            rs.DeleteObject(i)
rs.DeleteObject(urdf)#删除展开面

#移动结果至指定点
translation = rs.GetPoint("请点选放置点")
rs.MoveObjects( zx+border, translation )

保存.py文件后,用rhino自动的编译器编译成插件

你可能感兴趣的:(RhinoPython展开曲面并自动分层)