MoveGrips encountered some problems


(NARUTO) #1

Hello everyone
I want to move the control point to the curve,But I have some problems.Only the first control point is correct, the other is not the result I want.
I want to do this effect.
my code:

#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()

MoveGrips.py (824 Bytes)

MoveGrips.3dm (559.5 KB)

Thanks
——NARUTO


Rhinocommon access solid pt editing?
#2

@603419608,

your script seems to run fine if the regular grips come from curves, surfaces or meshes. But with grips obtained from a polysurface or a surface using _SolidPtOn, i get similar errors with a similar script.

To repeat this, create a surface and use _PointsOn, then run the script to move some of the surface grips. It seems to work fine. use _PointsOff and then _SolidPtOn on the same surface and the script does not work as expected.

I think it may be a bug in grip.Move and grip.CurrentLocation as everything else works fine in the script above.

@Dale could you please take a look ?

c.


(NARUTO) #3

Thanks Clement
I also think this is a bug.
@stevebaer could you please take a look ?
Thanks
——NARUTO