在grasshopper中,需要导入的包虽然不多,但是相当绕人,所要实现的操作往往找不到,暂时做个分类。
双击输入 python 电池:
# 导入rhino 包
import Rhino
#Rhino.Geometry 表示执行的是几何图形操作,例如:输入一个点和圆形
pt = Rhino.Geometry.Point3d(80233.3, 38977, 0)
cir = Rhino.Geometry.Circle(pt, 199)
p = pt
a = cir
例如求点到线段的最近距离点:
import Rhino.Geometry as rg
success, t = rg.Curve.ClosestPoint(curveInput, ptInput)
crv_pt = rg.Curve.PointAt(curveInput, t)
dist = ptInput.DistanceTo(crv_pt)
print(dist)
a = crv_pt
import rhinoscriptsyntax as rs
'''上述操作可同样用 rs包完成'''
t = rs.CurveClosestPoint(curveInput, ptInput)
crv_pt = rs.EvaluateCurve(curveInput, t)
dist = rs.Distance(ptInput, crv_pt)
a = crv_pt
官方文档:https://developer.rhino3d.com/api/RhinoScriptSyntax/
同时这里面还有很多案例:https://wiki.mcneel.com/developer/pythonandrhinocommon
手机扫一扫
移动阅读更方便
你可能感兴趣的文章