Lost texture in boolean operations (Python vs. GUI)

I have two valid closed meshes, the “stone” — with a .mtl. texture — and the “box” — manually created default mesh box in GUI (picture 1). If I perform within the GUI manually a boolean difference between the “stone” and the “box”, the carved out intersection of the “stone” recieves a (presumably interpolated) texture (picture 2). That is what I want.

If I do now perform the same operation with below Rhinoscript Python

input0 = rs.GetObjects("Select first set of meshes", rs.filter.mesh)
input1 = rs.GetObjects("Select second set of meshes", rs.filter.mesh)
rs.MeshBooleanDifference(input0, input1)

the cutting works (see picture 3), but the “stone” lost its texture.

So, the GUI is doing what I want and maps the old texture to the new mesh after carve-out, while the Python code is not.

How do i tweak my Python code to do exactly as the GUI?

@Carsten_Keil - can you post a 3dm file with your textured mesh?

Thanks,

– Dale

@Dale,

thank you for your support!

My original “stone” model is actually copy right protected, so I created a very simple .3dm sample on the fly in the rhino GUI to show the effect and I can freely upload:

demo.3dm (216.2 KB)

[1] is a default “cone” mesh with a rhino-out-of-the-box “granite” texture applied as well as a “box” mesh (all valid solid meshes). If I do boolean difference manually in the GUI I get the “desired” effect [2]: the box is is carved out from the cone, and rhino applies an (admittedly oddly) interpolated texture to the carved out section - key point being, there is a texture applied.

If I now do the same with my 3 line python code,

carveout.py (983 Bytes)

the texture gets destroyed while the actual “physical” carving out worked [3].

Any help appreciated to tune the python code in a way to yield the same effect as within the GUI. Presumbly the GUI applies some default “interpolate texture” process which i would like to utilize as well in my python script.

Hi @Carsten_Keil,

Does this work any better?

test_mesh_boolean_difference.py (1.6 KB)

– Dale

Dale,

thank you very much. Your code indeed works! now I need to understand why…

CK