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.
Sorry this thread got forgotten. There is a C# sample available to modify edit points in a SubD:
A Python version could use all the same RhinoCommon methods.
The caveat is that it will interpolate all limit surface points of the SubD at the same time, without any control on fixed control points. RhinoCommon access to an interpolator with more granular control is work that we plan to do during the Rhino 8 release cycle and tracked at the link I posted before: RH-59542 Allow for getting and setting SubD “edit” points using RhinoCommon.