RhinoPython镂空曲面
2021/7/20 1:06:24
本文主要是介绍RhinoPython镂空曲面,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
#coding:utf-8 import rhinoscriptsyntax as rs def SrfPts(srf,intU,intV): ptDict={} #设定曲面的UV区间 Udomain=rs.SurfaceDomain(srf,0) Vdomain=rs.SurfaceDomain(srf,1) print "Udomain:",Udomain print "Vdomain:",Vdomain #设定曲面UV方向的步长 stepU=(Udomain[1]-Udomain[0])/intU stepV=(Udomain[1]-Udomain[0])/intV print "stepU:",stepU print "stepV:",stepV for i in range(intU+1): for j in range(intV+1): u=Udomain[0]+stepU*i v=Vdomain[0]+stepV*j point=rs.EvaluateSurface(srf,u,v) ptDict[(i,j)]=point # rs.AddPoint(point) for i in range(intU+1): for j in range(intV+1): if i>0 and j>0: center=findMidPt(ptDict[i,j],ptDict[i-1,j-1]) curve1=rs.AddCurve((ptDict[i,j],center,ptDict[i,j-1]),3) curve2=rs.AddCurve((ptDict[i,j-1],center,ptDict[i-1,j-1]),3) curve3=rs.AddCurve((ptDict[i-1,j-1],center,ptDict[i-1,j]),3) curve4=rs.AddCurve((ptDict[i-1,j],center,ptDict[i,j]),3) outline=rs.JoinCurves([curve1,curve2,curve3,curve4],True) innerline=rs.AddCurve((ptDict[(i,j)],ptDict[(i,j-1)],ptDict[(i-1,j-1)], ptDict[(i-1,j)],ptDict[i,j]),3) rs.ScaleObject(innerline,center,(0.4,0.4,0.4)) sweepline=rs.AddLine(ptDict[i,j-1],rs.CurveStartPoint(innerline)) rs.AddSweep2([outline,innerline],[sweepline]) rs.DeleteObject(sweepline) # rs.AddTextDot((i,j),ptDict[(i,j)]) # rs.AddPoint(ptDict[i,j]) def findMidPt(point1,point2): midPt=((point1[0]+point2[0])/2, (point1[1]+point2[1])/2, (point1[2]+point2[2])/2,) return midPt def main(): strSrf=rs.GetObject("select a surface",rs.filter.surface) intU=rs.GetInteger("How many u intervals",8) intV=rs.GetInteger("How many v intervals",8) # rs.HideObject(strSrf) SrfPts(strSrf,intU,intV) main()
这篇关于RhinoPython镂空曲面的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-14Python编程入门指南
- 2024-11-13Python基础教程
- 2024-11-12Python编程基础指南
- 2024-11-12Python基础编程教程
- 2024-11-08Python编程基础与实践示例
- 2024-11-07Python编程基础指南
- 2024-11-06Python编程基础入门指南
- 2024-11-06怎么使用python 计算两个GPS的距离功能-icode9专业技术文章分享
- 2024-11-06Python 基础编程入门教程
- 2024-11-05Python编程基础:变量与类型