This uses the last used settings of Remesh. So do some tiny selection first, enter Remesh and set your desired settings. That done cancel Remesh.
Now running the code will delete all current objects and call a file dialog where you can browse to your file and load them to MM. It will remesh the whole bundle of files and save them as something_out.stl to the same directory the files came from.
NOTE: There are two errors in scene.py which is in the mm directory.
The funktions select_objects and delete_objects need to be replaced by:
def select_objects(remote, objects_list):
"""Set the current objects selection to be the set of scene objects corresponding to the IDs in objects_list"""
select_objects = mmapi.vectori();
for object in objects_list:
select_objects.push_back(object);
cmd2 = mmapi.StoredCommands()
cmd2.AppendSceneCommand_SelectObjects(select_objects)
remote.runCommand(cmd2)
def delete_objects(remote, objects_list):
"""Delete the scene objects corresponding to the IDs in objects_list"""
cur_selection = list_selected_objects(remote)
select_objects(remote, objects_list)
cmd = mmapi.StoredCommands()
cmd.AppendSceneCommand_DeleteSelectedObjects();
remote.runCommand(cmd)
select_objects(remote, cur_selection)
That done this code should give a tiny one-button-dialog which triggers the whole process:
from Tkinter import *
from tkFileDialog import askopenfilenames
import ttk
import mmapi
from mmRemote import *
import mm
root = Tk()
root.attributes("-topmost", True)
remote = mmRemote()
def Remesh_Filez():
remote.connect()
cur_obj = mm.list_objects(remote)
mm.delete_objects(remote, cur_obj)
filez = askopenfilenames(parent = root,filetypes=[ ("OBJ","*.obj"),("STL","*.stl")] )
if filez is"":
return
else:
filez_list = root.tk.splitlist(filez)
for filez in filez_list:
mm.append_objects_from_file(remote, filez)
items_list = mm.list_objects(remote)
c = 0
for items in items_list:
mm.select_objects(remote,[items])
mm.select_all(remote)
mm.begin_tool(remote, "remesh")
mm.accept_tool(remote)
save_path = filez_list[c]
out_filez = save_path.split('.')[0] + "_out.stl"
mm.export_mesh(remote,out_filez)
c+=1
remote.shutdown()
button_Remesh = ttk.Button(root, text="Remesh All", command = Remesh_Filez)
button_Remesh.pack()
root.mainloop()
Gunter Weber
Triangle Artisan