Hi there,
i get from a 3rd party software several STL-Files which i have to modify in MM.
Always the same steps:
1) open file ๐
2) hollow with wall thickness 2.5 mm
3) horizontal plane cut about 1/3 of the model height from the bottom (model is plane and horizontaly aligned)
4) save/export to another directory
Takes a lot of time and is boring, too!
I think there should be a solution that a task will take all files from the import directory one by one, performing the operations with MM and finally save the new STLs in my output dir.
Is such a repetive task makeable with AppleScript or only with the MM API (python or C++) ?
We have iMacs as well as Windows-PCs
And, i would pay for that script of course if a solution is to time consuming.
Best regards and thanks in advance
Karim
Solved! Go to Solution.
Hi there,
i get from a 3rd party software several STL-Files which i have to modify in MM.
Always the same steps:
1) open file ๐
2) hollow with wall thickness 2.5 mm
3) horizontal plane cut about 1/3 of the model height from the bottom (model is plane and horizontaly aligned)
4) save/export to another directory
Takes a lot of time and is boring, too!
I think there should be a solution that a task will take all files from the import directory one by one, performing the operations with MM and finally save the new STLs in my output dir.
Is such a repetive task makeable with AppleScript or only with the MM API (python or C++) ?
We have iMacs as well as Windows-PCs
And, i would pay for that script of course if a solution is to time consuming.
Best regards and thanks in advance
Karim
Solved! Go to Solution.
Solved by MagWeb. Go to Solution.
I tried using this code from mmapi on github, but I have windows 10 in which I download and used hfcandrew updated files for it to work on windows 10. Anyway we can make this work with hfcandrew updated files? Thank you
I tried using this code from mmapi on github, but I have windows 10 in which I download and used hfcandrew updated files for it to work on windows 10. Anyway we can make this work with hfcandrew updated files? Thank you
Yes, one can use mmApi on WIN10. What happens on your side if you're running code? Which errors do you get in the Python Shell?
Gunter Weber
Triangle Artisan
Yes, one can use mmApi on WIN10. What happens on your side if you're running code? Which errors do you get in the Python Shell?
Gunter Weber
Triangle Artisan
Hello, here is an example when I used the code you placed in this thread:
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python27\lib\lib-tk\Tkinter.py", line 1547, in __call__
return self.func(*args)
File "C:/Users/prazm/Downloads/Win 10 mmapi Python2-20211017T225337Z-001/Win 10 mmapi Python2/hollowask.py", line 23, in Load_File
mm.append_objects_from_file(remote,input_dir+'/'+i)
File "C:/Users/prazm/Downloads/Win 10 mmapi Python2-20211017T225337Z-001/Win 10 mmapi Python2\mm\scene.py", line 26, in append_objects_from_file
key = cmd.AppendSceneCommand_AppendMeshFile(filename);
File "C:/Users/prazm/Downloads/Win 10 mmapi Python2-20211017T225337Z-001/Win 10 mmapi Python2\mmapi.py", line 690, in AppendSceneCommand_AppendMeshFile
def AppendSceneCommand_AppendMeshFile(self, *args): return _mmapi.StoredCommands_AppendSceneCommand_AppendMeshFile(self, *args)
TypeError: in method 'StoredCommands_AppendSceneCommand_AppendMeshFile', argument 2 of type 'char const *'
Hello, here is an example when I used the code you placed in this thread:
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python27\lib\lib-tk\Tkinter.py", line 1547, in __call__
return self.func(*args)
File "C:/Users/prazm/Downloads/Win 10 mmapi Python2-20211017T225337Z-001/Win 10 mmapi Python2/hollowask.py", line 23, in Load_File
mm.append_objects_from_file(remote,input_dir+'/'+i)
File "C:/Users/prazm/Downloads/Win 10 mmapi Python2-20211017T225337Z-001/Win 10 mmapi Python2\mm\scene.py", line 26, in append_objects_from_file
key = cmd.AppendSceneCommand_AppendMeshFile(filename);
File "C:/Users/prazm/Downloads/Win 10 mmapi Python2-20211017T225337Z-001/Win 10 mmapi Python2\mmapi.py", line 690, in AppendSceneCommand_AppendMeshFile
def AppendSceneCommand_AppendMeshFile(self, *args): return _mmapi.StoredCommands_AppendSceneCommand_AppendMeshFile(self, *args)
TypeError: in method 'StoredCommands_AppendSceneCommand_AppendMeshFile', argument 2 of type 'char const *'
Seems you are on WIN
On WIN one needs to convert OS paths to a string explicitly. One doesn't need to do this on MAC.
So you need to replace line 23:
mm.append_objects_from_file(remote,input_dir+'/'+i)
with:
mm.append_objects_from_file(remote,str(input_dir+'/'+i))
AND to replace line 51:
mm.export_mesh(remote,save_path)
with:
mm.export_mesh(remote,str(save_path))
Gunter Weber
Triangle Artisan
Seems you are on WIN
On WIN one needs to convert OS paths to a string explicitly. One doesn't need to do this on MAC.
So you need to replace line 23:
mm.append_objects_from_file(remote,input_dir+'/'+i)
with:
mm.append_objects_from_file(remote,str(input_dir+'/'+i))
AND to replace line 51:
mm.export_mesh(remote,save_path)
with:
mm.export_mesh(remote,str(save_path))
Gunter Weber
Triangle Artisan
Hi! Is there a way to autmatically select a boundary of an object? So without having to click on it myself. I have automated a lot of steps with the mm api, however I cannot find a way to do this. Thanks!
Hi! Is there a way to autmatically select a boundary of an object? So without having to click on it myself. I have automated a lot of steps with the mm api, however I cannot find a way to do this. Thanks!
yep, there's select_hole:
import mmapi
from mmRemote import *
import mm
remote = mmRemote()
remote.connect()
# get number of holes
holes = mm.list_number_of_holes(remote)
# launch SELECT
mm.begin_tool(remote, "select")
# select all boundary loops
## replace an existing selection for the first hole index
i=0
mm.select_hole(remote, i, mode = 0) # The modes are 0=Replace 1=Append 2=Remove
## append selections for further holes
i+=1
while i < holes:
mm.select_hole(remote, i, mode = 1)
i+=1
remote.shutdown()
Gunter Weber
Triangle Artisan
yep, there's select_hole:
import mmapi
from mmRemote import *
import mm
remote = mmRemote()
remote.connect()
# get number of holes
holes = mm.list_number_of_holes(remote)
# launch SELECT
mm.begin_tool(remote, "select")
# select all boundary loops
## replace an existing selection for the first hole index
i=0
mm.select_hole(remote, i, mode = 0) # The modes are 0=Replace 1=Append 2=Remove
## append selections for further holes
i+=1
while i < holes:
mm.select_hole(remote, i, mode = 1)
i+=1
remote.shutdown()
Gunter Weber
Triangle Artisan
Thank you so much!! It worked perfectly.
Thank you so much!! It worked perfectly.
Can't find what you're looking for? Ask the community or share your knowledge.