My goal is to generate a model composed of many partially overlapping cubes. But I need to get rid of the parts where they overlap, so I have a single mesh without any intersections. One of the purposes is 3D printing. With the boolean modifier I can make it work sometimes, but often the resulting model is totally corrupt (missing parts, weird geometry, non-manifold). BMesh and Carve both have issues. I've had the same experience with the boolean modifier in e.g. Sketchup.
So my question here is how would I manually connect these cubes and remove the overlap? Eventually I will have to do this in Python, but I can't program it if I don't know how to do it to begin with...
Image of example model with partially overlapping cubes:
Image showing inside of example model with internal geometry removed:
- Each cube has the same height (Z scale)
- Each cube belongs to a certain 'floor'
- Therefore each 'floor' has the same height
- The difference in Z location between two following floors is the same (floors are distributed evenly)
- Every cube on a higher floor is supported by at least one cube from the floor directly below it (meaning no cube will float in the air, except for cubes on floor 0)
- Cubes on the same floor may intersect each other (I didn't show this in the example images)
Basically it's a tower of cubes with dedicated 'floors', like a building. But each floor is pushed down a little to overlap the floor below it.
The way I think I should tackle this is as follows:
- Place all the cubes in correct position, but without pushing down each floor (so no overlap, only touching)
- Calculate the places where the faces touch using the Shapely for Blender Python module (using 2D boolean operations)
- Cut a hole with the Knife project for each of these parts where the faces touch
- Somehow merge/connect the vertices which surround the newly cut hole - this should connect the previously separate floors
- Continue with 2, 3 and 4 until finished
- Select the faces that face down (except for the faces of floor 0) and pull them down a bit to create the overlap which we didn't make at step 1
I hope I'm on the right track here. I can do step 1 and 2 but from step 3 I don't know how. It sure would have been nice if the Bool Tool Auto Boolean Union would have worked for me but unfortunately that's not the case. I've included a simple example Blend file, as well as a complex one where the Bool Tool fails.
I'm using Blender Version 2.78c.