Get curves and edges in same operation


#1

Just checking: would the following be the optimum way to do this in Python/RhinoCommon?
Thx, Mitch

import Rhino
def GetCurvesAndEdges():
    filter=Rhino.DocObjects.ObjectType.EdgeFilter | Rhino.DocObjects.ObjectType.Curve
    rc, objrefs = Rhino.Input.RhinoGet.GetMultipleObjects("Select curves or surface edges", False, filter)
    if rc != Rhino.Commands.Result.Success: return rc    
    return [objref.Curve().ToNurbsCurve() for objref in objrefs]

Is it possible to select the edge of a polysurface inside a block?
Getting curves and edges in RhinoScript
(Menno Deij - van Rijswijk) #2

Looks pretty good to me. I seem to recall that ObjectType.Curve already selects surface edges so you may want to remove the ObjectType.EdgeFilter.

Secondly, you don’t necessarily need to convert with .ToNurbsCurve() unless you need the Nurb form later on.

Also, you may want to check for None on the objRefs list and any element in it. Does not hurt to be thorough :wink:

Lastly, you may also want to add a check if each curve returned has its IsValid property equal to True. Again, doesn’t hurt to be thorough :smile:


#3

Yep, you are correct, thanks!

Originally I had done this for compatibility for another operation, but in fact it works without as well.

Good advice, thanks!

–Mitch