How to MergeAllFaces using rhonscript Python objects?

How can one do the equivalent of -_MergeAllFaces, working with rhinoscript objects in Python?

I’ve managed to MergeAllFaces in Python by cheating:

But would prefer to apply MergeFaces directly to the rhinoscript Python closed surface list object, named “basemodel”, getting back an updated object to use in subsequent operations. Thus far, I’m stuck. Hints please?

   breps = [rs.coercebrep(id, True) for id in basemodel]

Seems to work OK, but then
Mbreps = Rhino.Geometry.Brep.MergeCoplanarFaces(breps,tol)
Fails (returns None) for any tolerance I’ve tried (up to 10x rhinoscript.document.UnitAbsoluteTolerance())

Even if it worked, I’m not clear on how to get back to rhinoscript objects after merging the breps.
Any suggestions where to look for hints on working at the Rhino.Geometry level?

Hints, please?


I’m creating a model for 3D printing with text cut into the top surface of a complex “cubical” object.
The object is 6-way symmetric, so the Python script explicitly creates one section, then “rotates with copy” to make the rest (first 180 deg about 1 axis, then rotating the combined result by 120 and 240 deg about a different axis). The surfaces meet in common planes.

The cut-in text is created by a boolean difference, which does not work right unless MergeAllFaces is first applied to the “cubical” model. BooleanUnion fails, but does not seem to be necessary.

The “cheat” above allows teh script to produce a suitable .stl file for printing.

Hi @Darin_Williams


takes a single Brep. In fact, it’s a “self” type of member, that works on the instance.

See Brep_MergeCoplanarFaces and compare it with, for example, Brep_MergeBreps which takes several items.

The operation that -_MergeAllFaces does requires a few calls on each Brep in your Breps list. Does it help?

It’s a start, thanks.

If you don’t mind, what would be a Python equivalent to _MergeAllFaces?
You say it takes several calls.
Is there a way I can look this up myself?


Since your intended output is an .STL file for printing, and the .STL is a mesh model, perhaps you should convert your “cubical” solid and 3d text to meshes, and then use mesh Boolean operations? These are sometime more reliable than solid Booleans in Rhino.

Just a thought…

Alternatively, it looks like the links above are a good start to developing a custom face merging function in python, but I don’t think there is a built-in Python equivalent.

Join the “faces” (several Brep’s) and then run MergeCoplanarFaces (info above). For improving Booleans, also run SplitKinkyFaces.