I could use an UnlockAllObjects method. Currently, the unlock methods require objects id’s, but sometimes I need to unlock everything in the file. I have one scenario where I lock everything that isn’t a cylinder or a planar surface. When the task is done, I use the regular Rhino command “Unlock” to unlock everything, It seems to me a Python method would be handy.
Secondly, I could really use a method for sorting cylinders that are complete, not just portions. In our business we deal with a lot of holes, and a IsCylinderClosed method would be VERY useful. I don’t need to know if the ends are capped, just that the cylindrical surface forms a true cylinder. Currently, the IsCylinder method also finds fillets.
Of course, if any of this is currently possible and I’m not seeing it, I welcome suggestions.
As to the cylinder question, I can’t really answer that one, except to find all closed objects first with IsObjectSolid() and then check for IsCylinder() among the results…
Edit: rereading your question, I see that will not work for what you want… sorry
I’m guessing that only straight-edged fillets are getting found by IsCylinder() - otherwise there is something wrong…
rs.IsCylinder() is just calling Rhinocommon Rhino.Geometry.Surface.IsCylinder. Technically straight fillets are cylinder parts and IsCylinder doesn’t tell you what portion of a cylinder the chosen object might represent. What you might be able to do first isolate possible candidates with IsCylinder(), shrink the surfaces, then determine the U,V degrees of those surfaces with SurfaceDegree - for any “cylindrical” object they should be 1 and 2 - then check with rs.IsSurfaceClosed() in the degree 2 direction… Closed in the degree 2 direction should mean a full tube section…
One way to find out if a surface or brep is unrollable is to unroll it.
If it does not get a result, it cannot be unrolled. This example here shows how to unroll and if it worked, it creates the unrolled geometry. You could remove this part from the example, which creates the unrolled geometry:
for brep in breps: scriptcontext.doc.Objects.AddBrep(brep)
for curve in curves: scriptcontext.doc.Objects.AddCurve(curve)
for point in points: scriptcontext.doc.Objects.AddPoint(point)
for dot in dots: scriptcontext.doc.Objects.AddTextDot(dot)
Could you give me an example of how you used TryGetCylinder() to test for a closed cylinder? This subject has come up again for me. I need to separate cylindrical fillets from holes.
this might be one way to distinguish between closed cylinders and fillets (which are cylindric but not closed):
import rhinoscriptsyntax as rs
def SubSelectCylinder():
obj_ref = rs.GetObject(message="Sel", filter=8, preselect=False, subobjects=True)
if obj_ref:
subsrf=obj_ref.Surface()
if subsrf:
# check if part of cylinder
res, cyl = subsrf.TryGetCylinder()
if res:
# check if cylinder is closed in u or v direction
if subsrf.IsClosed(0) or subsrf.IsClosed(1):
circle = cyl.CircleAt(0.0)
print "Closed cylinder properties:"
print "axis vector:", cyl.Axis
print "center:", cyl.Center
print "height:", cyl.TotalHeight
print "diameter:", circle.Diameter
else:
print "this cylinder is not closed"
else:
print "sorry, i am not a cylinder"
if __name__=="__main__":
SubSelectCylinder()