曲线的- #coding=utf-8
- import Rhino.Geometry as rg
- import Rhino as r
- import rhinoscriptsyntax as rs
- import scriptcontext as sc
- result,grips = r.Input.RhinoGet.GetGrips("选择要移动的控制点")
- curve = rs.GetObject("选择用于干扰的曲线",rs.filter.curve)
- dis = {}
- if (result == r.Commands.Result.Success and curve):
- geo_curve = sc.doc.Objects.Find(curve).Geometry
- t = 0
- for i in grips:
- oid = i.OwnerId
- obj = sc.doc.Objects.Find(oid)
- if (obj and dis.has_key(oid)==False):
- dis.Add(oid,obj)
- Bool = geo_curve.ClosestPoint(i.Geometry.Location,t)
- if Bool[0]:
- cpt = geo_curve.PointAt(Bool[1])
- i.Move(cpt)
- for guid in dis:
- if dis[guid]:
- sc.doc.Objects.GripUpdate(dis[guid],True)
- sc.doc.Views.Redraw()
复制代码 |