Community
Meshmixer
Welcome to Autodeskโ€™s Meshmixer Forums. Share your knowledge, ask questions, and explore popular Meshmixer topics.
cancel
Showing results forย 
Showย ย onlyย  | Search instead forย 
Did you mean:ย 

MeshMixer Scripting for repetive task

26 REPLIES 26
SOLVED
Reply
Message 1 of 27
Anonymous
8728 Views, 26 Replies

MeshMixer Scripting for repetive task

Anonymous
Not applicable

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

0 Likes

MeshMixer Scripting for repetive task

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

Tags (3)
26 REPLIES 26
Message 21 of 27
prazmjou
in reply to: Anonymous

prazmjou
Observer
Observer

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

0 Likes

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

Message 22 of 27
MagWeb
in reply to: Anonymous

MagWeb
Advisor
Advisor

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

0 Likes

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

Message 23 of 27
prazmjou
in reply to: MagWeb

prazmjou
Observer
Observer

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 *'

 

0 Likes

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 *'

 

Message 24 of 27
MagWeb
in reply to: prazmjou

MagWeb
Advisor
Advisor

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

0 Likes

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

Message 25 of 27
nmhoogeweg
in reply to: Anonymous

nmhoogeweg
Explorer
Explorer

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!

0 Likes

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!

Message 26 of 27
MagWeb
in reply to: nmhoogeweg

MagWeb
Advisor
Advisor

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

0 Likes

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

Message 27 of 27
nmhoogeweg
in reply to: MagWeb

nmhoogeweg
Explorer
Explorer

Thank you so much!! It worked perfectly. 

0 Likes

Thank you so much!! It worked perfectly. 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report