RhinoCommon CreateBooleanDifference question


#1

I am experimenting with RhinoCommon in Python… I am doing essentially the same thing as Rhino’s BooleanDifference command, but I ran across something I wasn’t expecting…

If you have two disjoint volumes, Rhino’s BooleanDifference (also union, intersect) doesn’t do anything - correct, it shouldn’t. If you do the same thing with vb Rhinoscript, the same thing occurs, you get a Null return from the operation.

However, in RhinoCommon a volume IS created, one that is the same as the base volume… So if you delete the original input objects, the volume to subtract disappears, leaving a new object (new ID) identical to the base volume… This is also the case with the Python Rhinoscriptsyntax method, as it just calls the RhinoCommon method.

Shouldn’t the RhinoCommon method return None if there is no intersection between the volumes?

Below is the code I used to test…

Thanks, --Mitch

Python/Rhinoscriptsyntax/RhinoCommon

import rhinoscriptsyntax as rs
import Rhino, scriptcontext

tol=scriptcontext.doc.ModelAbsoluteTolerance
msg="Select base volume, then difference volume"
srfs=rs.GetObjects(msg,8+16,minimum_count=2,maximum_count=2)

solid0 = rs.coercebrep(srfs[0])
solid1 = rs.coercebrep(srfs[1])

solDiff = Rhino.Geometry.Brep.CreateBooleanDifference(solid0, solid1, tol)    
if solDiff:
    for i in range(len(solDiff)):
        scriptcontext.doc.Objects.AddBrep(solDiff[i])
    scriptcontext.doc.Objects.Delete(srfs[0],True)
    scriptcontext.doc.Objects.Delete(srfs[1],True)
scriptcontext.doc.Views.Redraw()

Python/Rhinoscriptsyntax

import rhinoscriptsyntax as rs

msg="Select base volume, then difference volume"
srfs=rs.GetObjects(msg,8+16,minimum_count=2,maximum_count=2)
rs.BooleanDifference(srfs[0],srfs[1],True

vbRhinoscript

Option Explicit
Call Test()
Sub Test()
	Dim msg,srfs,result	
	msg="Select base volume, then difference volume"
	srfs=Rhino.GetObjects(msg,8+16,,,,,2,2)
	result=Rhino.BooleanDifference(srfs(0),srfs(1),True)
	If IsNull(result) Then Call Rhino.Print ("Null")
End Sub

#2

Hi Mitch
For me it’s a Python bug
Ciao Vittorio


#3

Hey Vittorio

Yes, at least the Python rhinoscriptsyntax is “wrong” in the sense that it doesn’t do the same thing as the vb method does. But the question of whether RhinoCommon is wrong or not is more important to me… From the Brep.CreateBooleanDifference Method SDK:

Return Value
An array of Brep results or null on failure.

The question here is if not finding an intersection is to be considered a “failure”. In any case returning the original geometry if there is no intersection is not extremely useful, as if that is added to the document and substituted for the original, the original changes ID. That is NOT what the Rhino native function does.

So, are the objects checked for intersection BEFORE the BD is launched and if no intersection found is the operation cancelled? Or is the vbscript counterpart using different code?

Ciao,
–Mitch


#4

Now we need a response from Steve
Ciao Vittorio


(Steve Baer) #5

I’m looking into this


(Steve Baer) #6

I see the problem; I’ll get this fixed for SR6. Thanks for finding this.


#7

Cool, thanks Steve!
–Mitch