Setting Extrude Offset value problems in mmapi

grahamJDGU9
Observer
Observer

Setting Extrude Offset value problems in mmapi

grahamJDGU9
Observer
Observer

So I'm building a script that requires a step to extrude the frame of an object in mmapi, all my other steps in this script are working but this single function (single line in this function actually) refuses to work. I want to set offset to 3.5mm, however in this example offset will sometimes go to max mm (about 200mm and crash MeshMixer and my script), or it will go to a number around 3.5mm (such as 1.9-2.3mm or so), but I need to it be exactly 3.5mm. Does anyone have ideas on how to do this?  I have tried changing the values of offset, tried manually setting units with "offsetDistanceMm", tried finding a scaling factor. Any help is appretiated.

 

def extrudeFrame(r):
mm.select_all(r)
mm.begin_tool(r, "extrude")
mm.set_toolparam(r, "offset", 3.5)
mm.set_toolparam(r, "harden", 0.3)
mm.set_toolparam(r, "directionType", 0)
mm.set_toolparam(r, "preserveGroups", True)
mm.tool_utility_command(r, "update")
mm.accept_tool(r)
mm.cancel_tool(r)

 Thanks,

0 Likes
Reply
Accepted solutions (1)
1,064 Views
4 Replies
Replies (4)

MagWeb
Advisor
Advisor
Accepted solution

Inside its code MM uses a normalised coordinates system where the first object added to the scene defines a range of -1 to 1 for its largest XYZ-dimension "Scene Coordinates". A certain real world distance (e.g. 3.5mm) needs to be converted to that internal scene scale first.

 

import mmapi
from mmRemote import *
import mm

r = mmRemote()
r.connect()

off = mm.to_scene(r,3.5)

mm.select_all(r)
mm.begin_tool(r, "extrude")
mm.set_toolparam(r, "directionType", 0)
mm.set_toolparam(r, "offset", off)
mm.set_toolparam(r, "harden", 0.3)

mm.set_toolparam(r, "preserveGroups", True)
#mm.tool_utility_command(r, "update")
mm.accept_tool(r)
#mm.cancel_tool(r)

r.shutdown()

You need to use the update tool_utility_command only for tools which show an "Update" button.



Gunter Weber
Triangle Artisan

grahamJDGU9
Observer
Observer

It works perfectly thank you! I thought it was something like this but couldn't find any information on it. And thanks for the tips.

0 Likes

eliot543
Contributor
Contributor

In what way can I do it in c++ instead of python?

0 Likes

eliot543
Contributor
Contributor
Nvm I got it
0 Likes