Author Topic: Automating boolean union of shells  (Read 139 times)


  • Newbie
  • *
  • Posts: 2
    • View Profile
Automating boolean union of shells
« on: February 08, 2018, 06:58:32 AM »

I am trying to print creatures designed in the software tool Spore. Sadly, Spore is really made for 3D gaming, and not 3D printing. Although you can export creatures for 3D printing, different segments of their body aren't properly attached.

Here is the process I would like to automate:
1. Import an stl file
2. separate shells
3. boolean union all adjacent shells

Is this possible to do in script? (like python for meshmixer)


  • Administrator
  • Hero Member
  • *****
  • Posts: 1271
    • View Profile
Re: Automating boolean union of shells
« Reply #1 on: February 08, 2018, 04:08:49 PM »
Not sure if boolean union is the best choice to merge such low poly elements:
In MM there's also MakeSolid to get a single shell. For details see:

If you still want to do it via BooleanUnion:
Yes you can use mm-api which you can get here:

After setting up the api the attached script should do the BooleanUnion part automatically.
This does not do the Import and the SeparateShells part (but I think it should be doable to add it to the script) so you have to do this manually.
Run the script via python shell. It will pop up a topmost little GUI window
Now activate all objects to merge and hit the Union button....

Code: [Select]
from Tkinter import *
import ttk
import mmapi
from mmRemote import *
import mm

#create a centered "root" GUI window
root = Tk()
root.title("MM AutoUnion")  #name window
w = 300 # width Tk root
h = 70 # height Tk root
# get screen width and height:
ws = root.winfo_screenwidth() # width
hs = root.winfo_screenheight() # height
# calculate startup x and y coordinates for Tk root:
x = (ws/2) - (w/2)
y = (hs/2) - (h/2)
root.geometry('%dx%d+%d+%d' % (w, h, x, y))  # set root window's size and position at screen's center
root.attributes("-topmost", True) # keeps root window in front

# initialize connection to MM
remote = mmRemote();

def union():
    cur_objects = mm.list_selected_objects(remote)
    if len(cur_objects) <2:
        help_text.configure(text="This script requires more than one active object. Retry")
        i = len(cur_objects)         
        while (i > 1):           
            mm.select_objects(remote, [cur_objects[0], cur_objects[1]])
            #check if objects interesect
            cmd2 = mmapi.StoredCommands()
            ckey = cmd2.AppendQueryCommand_TestIntersection(cur_objects[0], cur_objects[1])
            if cmd2.GetQueryResult_TestIntersection( ckey ) == 1:
                mm.begin_tool(remote, "union")
                mm.set_toolparam(remote,"solutionType", 2) # BooleanUnion parameter - probably to change
                mm.set_toolparam(remote,"robustMode", 1) # BooleanUnion parameter - probably to change
                mm.set_toolparam(remote,"robustModeDelta", 0.001) # BooleanUnion parameter - probably to change
                mm.set_toolparam(remote,"postReduce", 0) # BooleanUnion parameter - probably to change
            else: #run Combine instead of Union if there's no intersection
                mm.begin_tool(remote, "combine")
            i -= 1           
    help_text.configure(text= "Done! Activate at least two objects to run again")
#applet's GUI elements
buttonM_union = ttk.Button(root, text="Union", command=union)
help_text = Label(root,text="Activate two ore more objects and hit Union", wraplength = 200,  compound = CENTER)

« Last Edit: February 09, 2018, 11:04:04 AM by MagWeb »
I'm just a user as you are. Being no Autodesk employee: I do not know where this road will lead to, nor do I claim to've all stuff got right.


  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Automating boolean union of shells
« Reply #2 on: February 10, 2018, 03:00:55 PM »
Your reply was very useful. I'm doing the make solid by hand right now, but I will try automating the make solid with the mm-api. I think you were right that make solid, over boolean union, is the right way to go. Thank you.