mm python module documentation¶
The mm python module is a wrapper for the SWIG-generated mmapi python module. The purpose of this module is to provide shorter, more convenient function names, that respect python conventions.
The mm module is organized into various top-level modules:
core meshmixer manipulation modules:
mm.scene
: Scene manipulationmm.selection
: create/manipulate Selectionsmm.tool
: run Tools, set parameters
meshmixer query modules:
mm.convert
: conversion utility functionsmm.util
: spatial queries
utility modules:
mm.frame
: mmFrame classmm.mm_math
: linear algebra, math utilities
Important Notes¶
This documentation was generated on December 10, 2014, the current version of meshmixer at this time is 2.7. You can get the most recent version of the mm-api package, including the mm module and this documentation, at https://github.com/meshmixer/mm-api
Please also see the github mainpage readme (ie follow the link above) for more details on the mm-api package, including setup instructions. This package is under active development and will change frequently. In particular, you must have a version compatible with the meshmixer installation you are running.
Usage Tips¶
These modules all depend on the mmapi
module, which is part of the mm-api package, found in the /distrib/python
folder.
You can import mm
and then access most top-level functions as mm.<function_name>
, rather than importing each sub-module. However, specifically for the math manipulation functions, you may find you can write cleaner code by also adding import mm.mm_math
.
The Meshmixer desktop application uses a normalized coordinate system internally. These coordinates are referred to as Scene coordinates, versus World coordinates, which are in the current physical dimensions of the scene. Currently many API functions expect and return points/dimensions in this space. See the mm.convert
module for details on converting between Scene and World coordinates.
Meshmixer Manipulation Modules¶
mm.scene module¶
-
mm.scene.
append_objects_from_file
(remote, filename)[source]¶ Read objects from a mesh file, append them to the scene, and return a list of new object IDs
-
mm.scene.
delete_objects
(remote, objects_list)[source]¶ Delete the scene objects corresponding to the IDs in objects_list
-
mm.scene.
find_object_by_name
(remote, obj_name)[source]¶ Find the ID of the scene object with the given string name. Returns a 2-tuple (boolFound, object_id)
-
mm.scene.
get_object_name
(remote, object_id)[source]¶ Return the string name of the scene object with the given ID
-
mm.scene.
list_selected_groups
(remote)[source]¶ Returns a list of unique facegroup IDs for the current face selection (requires an active selection)
-
mm.scene.
list_selected_objects
(remote)[source]¶ Returns a list of object IDs for the current set of selected scene objects
-
mm.scene.
save_mix
(remote, path)[source]¶ Save the current scene as a .mix file at the given location
mm.selection module¶
-
mm.selection.
clear_face_selection
(remote)[source]¶ Clear the current face selection (if there is one) and exit the Selection Tool
-
mm.selection.
select_all
(remote)[source]¶ Select all faces of the active object (will initialize a Selection Tool if necessary)
-
mm.selection.
select_facegroups
(remote, groups_list)[source]¶ Select the faces which have a facegroup ID in groups_list
mm.tool module¶
- Tool string names: Tool Strings
- Tool parameters: Tool Parameters
-
mm.tool.
get_toolparam
(remote, param_name)[source]¶ Returns the current value of the given Tool parameter, or empty list if the parameter is not found.
-
mm.tool.
set_toolparam
(remote, param_name, f)[source]¶ Set the parameter param_name of the current tool. This function handles int,float,boolean,vector3,and matrix9 inputs
Meshmixer Query Modules¶
mm.convert module¶
This module contains functions for converting to/from Meshmixer API values, including:
- Conversion between SWIG-generated API helper structs/classes and python lists/tuples
- Conversion between Meshmixer’s internal World and Scene coordinates
World/Scene coordinate conversion is one complication of Meshmixer that is not exposed in the desktop application, but must (currently) be managed by API clients.
Meshmixer internally re-scales imported meshes to a normalized coordinate space, ie a 2x2x2 unit box centered at the origin. API functions for spatial queries, bounding boxes, etc, currently expect points and dimensions in this normalized space, and return normalized results as well.
You can use the functions in this module to convert between Scene and World coordinates, where World coordinates are in the current units selected in the Units/Dimension Tool. By default, new scenes (i.e. after an import) have units in millimetres.
-
mm.convert.
to_scene
(remote, v)[source]¶ convert input from World space to Scene space (dimension or 3D point)
-
mm.convert.
to_scene_f
(remote, f)[source]¶ convert a scalar dimension from World space to Scene space
-
mm.convert.
to_scene_xyz
(remote, x, y, z)[source]¶ convert a 3D point from World space to Scene space
-
mm.convert.
to_world
(remote, v)[source]¶ convert input from Scene space to World space (dimension or 3D point)
-
mm.convert.
to_world_f
(remote, f)[source]¶ convert a scalar dimension from Scene space to World space
mm.util module¶
This module contains spatial query functions, i.e. functions which return bounding-boxes, find nearest-point-on-surface, ray-cast, etc.
This module is likely to be renamed in the near future
-
mm.util.
find_nearest
(remote, position)[source]¶ Find the nearest point on the 3D surface to the input 3-tuple. Returns a tuple (bOK, hitFrame), where bOK is a boolean indicating if a nereast point was found, and hitFrame is an mmFrame at the hit point, with Z axis oriented to the surface normal
-
mm.util.
find_ray_hit
(remote, ray_origin, ray_direction)[source]¶ Find the intersection of a ray (specified by 3-tuples for origin and direction) and the 3D surface. Returns a tuple (bOK, hitFrame), where bOK is a boolean indicating if a hit was found, and hitFrame is an mmFrame at the hit point, with Z axis oriented to the surface normal
-
mm.util.
get_face_selection_bounding_box
(remote)[source]¶ return the axis-aligned bounding box of the selected faces as two 3-tuples (min, max). Requires active face selection.
Utility Modules¶
These modules do not actually make meshmixer API calls, they are included to make it easier to use the python API, and/or to write sample code.
mm.frame module¶
mm.mm_math module¶
-
mm.mm_math.
make_rotX_matrix
(angle)[source]¶ construct matrix that rotates around X axis by angle (in radians)
-
mm.mm_math.
make_rotY_matrix
(angle)[source]¶ construct matrix that rotates around Y axis by angle (in radians)