Can someone tell me why the results of the two scripts are different - especially why the result of ScriptTest2 is seemingly “wrong”? Run “Test 1” on the two volumes in the file picking first “A” then “B”… then run “Test 2” on the two surfaces doing the same… Script Test 2 should just extrude the flat surfaces to the same boxes that are used for Script Test 1 before doing the Boolean Intersection… What stupid thing am I overlooking here? Thanks, --Mitch
OK, more on this… If I use the code below - which is essentially the same as Test2 above - I get the same problem. But if I invert the extrusion direction - that is to say extrude in the -Z direction - the result is what I expect… Why? A Boolean intersection between two solids like that should always give the same result… Curiouser and curiouser…
import rhinoscriptsyntax as rs
import Rhino, scriptcontext
def Test2():
tol=scriptcontext.doc.ModelAbsoluteTolerance
msg="Select base surface, then difference surface"
srfs=rs.GetObjects(msg,8,minimum_count=2,maximum_count=2)
if not srfs: return
#extrude both surfaces solid one unit in plane Z direction
plane=rs.WorldXYPlane()
line=Rhino.Geometry.Line(rs.coerce3dpoint((0,0,0)),rs.coerce3dpoint((0,0,1)))
# to extrude negative, uncomment line below, comment out line above
#line=Rhino.Geometry.Line(rs.coerce3dpoint((0,0,0)),rs.coerce3dpoint((0,0,-1)))
br0 = rs.coercebrep(srfs[0])
br1 = rs.coercebrep(srfs[1])
solid0 = br0.Faces[0].CreateExtrusion(line.ToNurbsCurve(), cap=True)
solid1 = br1.Faces[0].CreateExtrusion(line.ToNurbsCurve(), cap=True)
solDiff = Rhino.Geometry.Brep.CreateBooleanIntersection(solid0, solid1, tol)
if solDiff:
for brep in solDiff:
scriptcontext.doc.Objects.AddBrep(brep)
rs.DeleteObjects(srfs)
Test2()
I’ve been staring at this for quite a while and still haven’t quite figured out what is causing the problem. It is obviously a bug in Rhino, but I just can’t see the point where things go bad. It’s driving me crazy