How to get the control points from a Polysurface

Well, as far as I know, turning on polysurface edit points is not exposed in any of the scripting interfaces. There is however a workaround - simply script rs.Command("_SolidPtOn"). The interesting thing is, that once the points are on, all of the rhinoscriptsyntax object grip manipulation methods do seem to work - you can select them, get/set their location, etc. See the rhinoscriptsyntax “grips” help section for all the methods.

One of the small quirks of any script that turns on object grips and manipulates them is that if you undo the script, the object grips will turn back on. To be lived with.

Below is a sample that gets an object’s solid editing points and scales them about the object’s bounding box center.

Beware, due to weaknesses in Rhino’s solid editing routines, randomly manipulating solid edit points can create completely crazy surfaces and potentially lock up or crash Rhino. I do not recommend editing objects this way unless you really know what you are doing. I would only try this example on a simple boxlike object. Use at your own risk.

–Mitch

"""Turns on an object's solid editing points and
scales their locations about object's bounding box center.
Beware, this script can lock up or crash Rhino!!!"""

import rhinoscriptsyntax as rs

def TestScaleObjSolidPts():
    msg="Select object to solid edit"
    obj=rs.GetObject(msg,8+16,preselect=True,select=True)
    if not obj: return
    
    sf=rs.GetReal("Scale factor for edit points?")
    if sf==None or sf<=0 :
        rs.UnselectObject(obj)
        return
    
    rs.EnableRedraw(False)
    
    #get object's solid point locations
    rs.Command("_SolidPtOn")
    grip_pts=rs.ObjectGripLocations(obj)
    
    #scale transformation by scale factor sf around object center
    bb=rs.BoundingBox(obj)
    xform=rs.XformScale(sf,(bb[0]+bb[6])/2)
    
    #transform the  points and move solid grips
    for i,pt in enumerate(grip_pts):
        new_loc=rs.PointTransform(pt,xform)
        rs.ObjectGripLocation(obj,i,new_loc)
        
    #turn off object grips
    rs.EnableObjectGrips(obj,False)
TestScaleObjSolidPts()
1 Like