I am attempting to modify the coordinates of a subd vertex using python. I thought that editing the vertex ControlNetPoint would work (docs say it has both a setter and getter), but the subd does not change. Am I doing something wrong? Code posted below.
Also, it would great to be able to edit the vertex surface point directly rather than the control point. I see that vert.SurfacePoint() returns a Point3d object, but not sure if this is editable or not. Is it possible to edit the surface point directly?
import Rhino
def edit_subd_verts():
filter = Rhino.DocObjects.ObjectType.SubD
rc, objref = Rhino.Input.RhinoGet.GetOneObject("Select SubD", False, filter)
if not objref or rc != Rhino.Commands.Result.Success: return
subd = objref.SubD()
if not subd: return
vert = subd.Vertices.First
print(vert.ControlNetPoint)
vert.ControlNetPoint.X = 30.0 # This has no effect
edit_subd_verts()
I am currently using Rhino 7 SR12 2021-11-9 on Windows 10.
I think this is not possible, but you can work with Grips or work with the control mesh instead, move the vertices, convert to subd and delete the old subd.
vert.ControlNetPoint.X = 30.0 gets the value of the control point location (copies it to a temporary Point3d) and sets the X property of that value to 30. For this to work like you want, SubDVertex.ControlNetPoint would need to be able to deal with a reference to the control point; I don’t think we have a safe way to do that.
Instead you can set the vert.ControlNetPoint property to a new Point3d:
import Rhino
def edit_subd_verts():
filter = Rhino.DocObjects.ObjectType.SubD
rc, objref = Rhino.Input.RhinoGet.GetOneObject("Select SubD", False, filter)
if not objref or rc != Rhino.Commands.Result.Success: return
subd = objref.SubD()
if not subd: return
vert = subd.Vertices.First
print(vert.ControlNetPoint)
cnp = vert.ControlNetPoint
cnp.X = 30
vert.ControlNetPoint = cnp
print(vert.ControlNetPoint)
Rhino.RhinoDoc.ActiveDoc.Objects.AddSubD(subd)
Setting surface point locations hasn’t made its way to RhinoCommon yet, it’s being tracked there: RH-59542 Allow for getting and setting SubD “edit” points using RhinoCommon.