MOHO Classes

class M_Mesh3D

The M_Mesh3D class represents a 3D object in a Mesh3DLayer.

Member Functions

void Clear()

Completely empties the mesh of all points, faces, materials, etc.

Return value: none

void SetDefaultColor(col)

Set the default color for faces with no assigned material.

Return value: none
col (rgb_color): default face color

rgb_color DefaultColor()

Get the default color for faces with no assigned material.

Return value (rgb_color): default face color

void SetEdgeColor()

Set the edge color.

Return value: none
col (rgb_color): edge color

rgb_color EdgeColor()

Get the edge color.

Return value (rgb_color): edge color

void SetClockwise()

Set whether front-facing 3D faces are aligned clockwise or counter-clockwise.

Return value: none
b (bool): true for clockwise, false for counter-clockwise

bool Clockwise()

Test whether front-facing 3D faces are aligned clockwise or counter-clockwise.

Return value (bool): true for clockwise, false for counter-clockwise

int CountPoints()

Returns the number of points in the mesh.

Return value (int): number of points

LM_Vector3 Point(id)

Get the position of a point in the mesh.

Return value (LM_Vector3): point location
id (int): point identifier

void AddPoint(vec)

Add a new point to the mesh.

Return value: none
vec (LM_Vector3): point location

void RemovePoint(id)

Remove a point from the mesh.

Return value: none
id (int): point identifier

void SetPoint(id, vec)

Change an existing point's position.

Return value: none
id (int): point identifier
vec (LM_Vector3): new position

int CountTexturePoints()

Return the number of texture coordinates.

Return value (int): the number of texture coordinates

LM_Vector2 TexturePoint(id)

Get the value of a texture coordinate.

Return value (LM_Vector2): the value of a texture coordinate
id (int): texture coordinate identifier

void AddTexturePoint(vec)

Add a new texture coordinate.

Return value: none
vec (LM_Vector2): the value of the new texture coordinate

void RemoveTexturePoint(id)

Remove a texture coordinate from the mesh.

Return value: none
id (int): texture coordinate identifier

int CountFaces()

Return the number of faces in the 3D mesh.

Return value (int): the number of faces

M_Face3D Face(id)

Get the properties of a particular face in the mesh.

Return value (M_Face3D): a face in the mesh
id (int): face identifier

void AddFace(p1, p2, p3)

Add a new three-sided face to the mesh.

Return value: none
p1 (int): first corner point
p2 (int): second corner point
p3 (int): third corner point

void AddFace(p1, p2, p3, p4)

Add a new four-sided face to the mesh.

Return value: none
p1 (int): first corner point
p2 (int): second corner point
p3 (int): third corner point
p4 (int): fourth corner point

void RemoveFace(id)

Delete a face from the mesh.

Return value: none
id (int): face identifier

int CountMaterials()

Returns the number of materials in the mesh.

Return value (int): number of materials

M_Material3D Material(id)

Gets the properties for a given material.

Return value (M_Material3D): a material in the mesh
id (int): material identifier

M_Material3D CreateNewMaterial()

Creates a new material in the mesh.

Return value (M_Material3D): the properties of the new material

void AddMaterial(m)

Adds a material to the mesh.

Return value: none
m (M_Material3D): material to add

void RemoveMaterial(id)

Deletes a material from the mesh.

Return value: none
id (int): material identifier

void ScaleToRadius(r)

Scale an entire mesh to fit a given radius. The larger dimension in X, Y, or Z will be scaled to fit this radius, and the other dimensions will scale to maintain the correct proportions. Scaling to a radius of 1.0 is a quick way to make sure that very large or very small 3D models fit the Moho workspace in a reasonable way.

Return value: none
r (float): radius to scale to

class M_Point

The M_Point class represents a single control point in a 2D vector layer.

Member Functions

int CountCurves()

Returns the number of curves that pass through the point.

Return value (int): the number of curves that pass through the point

M_Curve Curve(id, where)

Returns a curve that passes through the point.

Return value (M_Curve): a curve that passes through the point
id (int): the curve's id (0 is the first curve passing through the point)
where (int): the where value is returned, indicating where on the curve the point lies

void SetPos(pos, frame)

Set the position of the point at a given time.

Return value: none
pos (LM_Vector2): position
frame (int): frame number

void SetCurvature(curvature, frame)

Sets the curvature of all curves that pass through this point.

Return value: none
curvature (float): curvature value
frame (int): frame number

bool IsEndpoint()

Tests whether this point is the endpoint of a curve

Return value (bool): true if endpoint, false if the point is in the middle of a curve

void GetEndpointEdge(curveID, segID)

Returns which curve, and which segment of that curve, this point is an endpoint of.

Return value: none
curveID (int): the curve identifier
segID (int): which segment of that curve

Member Variables

fSelected (bool)

true if the point is selected, otherwise false


fPrevSelected (bool)

true if the point was previously selected, otherwise false


fPos (LM_Vector2)

the point's current position


fTempPos (LM_Vector2)

a temporary variable for storing position, useful when transforming points


fAnimPos (AnimVec2)

the point's position animation channel


fWidth (float)

the width of curves that pass through this point (-1 means that curves aren't affected by variable width)


fTempWidth (float)

a temporary variable to store line width


fParent (int)

id number of the parent bone this point is bound to. A value of -1 means the point is not bound to any bone. A value of -2 means the point is flexi-bound to all bones in the parent layer.

class M_PointGroup

The M_PointGroup class represents a named group of points in a vector mesh.

Member Functions

string Name()

Returns the name of the group.

Return value (string): the name of the group

int CountPoints()

Returns the number of points in the group.

Return value (int): the number of points in the group

M_Point Point(id)

Returns a point in the group.

Return value (M_Point): a point in the group
id (int): the id number of the point (0 is the first point in the group)

class M_Shape

The M_Shape class represents a visible shape in Moho. A shape can either be a fill, an outline, or both.

Member Functions

int CountEdges()

Returns the number of edges that make up this shape.

Return value (int): -- the number of edges that make up this shape

void GetEdge(edgeID, curveID, segID)

Returns information about a specific edge. Given an edge on the shape, this function returns the curve id and segment id of the actual curve in the underlying mesh.

Return value: none
edgeID (int): the id number of the edge (0 for the first edge in a shape)
curveID (int): curve id
segID (int): which segment of the curve is this edge

void CopyStyleProperties(fromShape)

Copies the style properties from another shape.

Return value: none
fromShape (M_Shape): shape to copy from

void RemoveStyles()

Removes all inherited styles from the shape.

Return value: none

Member Variables

fSelected (bool)

True if the shape is selected, otherwise false.


fName (LM_String)

Name of the shape.


fHasFill (bool)

True if the shape is filled, otherwise false.


fHasOutline (bool)

True if the shape has an outline, otherwise false.


fFillAllowed (bool)

True if a fill is allowed, whether the shape actually has a fill or not.


fMyStyle (M_Style)

The shape's style properties. The style defines a shape's fill color, line width, etc.

class M_Skeleton

The M_Skeleton class represents the actual skeleton structure that is encapsulated by a bone layer.

Member Functions

int CountBones()

Returns the number of bones in the skeleton.

Return value (int): number of bones

M_Bone Bone(id)

Access a particular bone in the skeleton.

Return value (M_Bone): a bone object
id (int): bone identifier

int BoneID(bone)

Given a bone object, this function returns the identifier value for that bone in the skeleton.

Return value (int): bone identifier
bone (M_Bone): a bone in the skeleton

int SelectedBoneID()

Returns the identifier of the currently selected bone.

Return value (int): bone identifier

void UpdateBoneMatrix(id)

Updates the transformation matrices for the given bone. Use this after changing a bone's position or rotation.

Return value: none
id (int): bone identifier

M_Bone AddBone(frame)

Create a new bone and add it to the skeleton.

Return value (M_Bone): the newly-created bone
frame (int): frame number

void DeleteBone(id, recursion=0)

Delete a bone from the skeleton.

Return value: none
id (int): bone identifier
recursion (int): ignore this argument - leave it set to 0

int CountBoneChildren(id)

Returns the number of child bones attached to the given bone.

Return value (int): number of children bones
id (int): bone identifier

int GetFirstChildBone(id)

Return the first child of the given bone.

Return value (int): bone identifier
id (int): bone identifier

bool IsBoneChild(boneID, childID)

Test whether one bone is a decendant of another.

Return value (bool): true if the childID bone is decended from boneID, otherwise false
boneID (int): bone identifier
childID (int): bone identifier

bool IsBoneParent(boneID, parentID)

Test whether one bone is an ancestor of another.

Return value (bool): true if parentID is an ancestor of boneID, otherwise false
boneID (int): bone identifier
parentID (int): bone identifier

int NearestBone(vec)

Returns the closest bone to a 2D vector position.

Return value (int): bone identifier
vec (LM_Vector2): a 2D position in the bone layer

void LockBone(id, frame)

Locks the given bone at a specified time.

Return value: none
id (int): bone identifier
frame (int): frame number

void UnlockBone(id, frame)

Unlocks the given bone at a specified time.

Return value: none
id (int): bone identifier
frame (int): frame number

void IKAngleSolver(boneID, target, iterMultiplier=1)

Runs the inverse kinematics solver in order to move a chain of bones to reach a specified target point. The specified bone will move as necessary in order for its tip to touch the given target.

Return value: none
boneID (int): bone identifier
target (const LM_Vector2): target location
iterMultiplier (int): the default setting of 1 should be fine, but increase this number for a more accurate IK solution

Member Variables

fBindingMode (int)

Which automatic binding mode should be used for this skeleton. See the binding mode constants.

class M_Style

The M_Style class represents the visual style of a shape, either the shape's own style or an inherited style

Member Functions

void SetSoftEdge(radius)

Applies a soft edge effect.

Return value: none
radius (float): radius of the blur

void SetShading(angle, offset, blur, color)

Applies a shading effect.

Return value: none
angle (float): shading angle
offset (float): shading offset
blur (float): blur radius
color (rgb_color): shading color

Member Variables

fName (LM_String)

The name of the style.


fDefineFillCol (bool)

True if this style defines a fill color, otherwise false.


fFillCol (AnimColor)

The style's fill color.


fDefineLineWidth (bool)

True if this style defines a line width, otherwise false.


fLineWidth (float)

The style's line width.


fDefineLineCol (bool)

True if this style defines a line color, otherwise false.


fLineCol (AnimColor)

The style's line color.

class NoteLayer

New Feature

class ParticleLayer

Member Functions

void FinalizeSettings()

Call this function after making any changes to the particle parameters. This function will re-evaluate all the parameters to start a new particle simulation.

Return value: none

void SetRandomSeed(seed)

Re-randomizes the particle simulation. Enter a random number for a random particle effect, or some known number to get back to an older simulation.

Return value: none
seed (int): the random seed

void SetNumParticles(num, displayNum)

Set the number of particles.

Return value: none
num (int): number of particles for rendering
displayNum (int): number of particles to display in the editing view

void GetNumParticles(num, displayNum)

Find out how many numbers are in the particle system.

Return value: none
num (int): number of particles for rendering
displayNum (int): number of particles to display in the editing view

void SetLifetime(lifetime)

Set the lifetime of an individual particle.

Return value: none
lifetime (int): lifetime in frames

int Lifetime()

Find out the lifetime of an individual particle.

Return value (int): the lifetime of an individual particle

void SetOrientation(orient)

Set whether the particles should orient themselves to follow their path of motion.

Return value: none
orient (bool): true to orient the particles, otherwise false

bool Orientation()

Tests whether the particles are oriented or not.

Return value (bool): the orientation status of the particles

void SetFreeFloating(freeFloating)

Set whether particles should be free-floating.

Return value: none
freeFloating (bool): true for free-floating, otherwise false

bool FreeFloating()

Tests whether particles are free-floating or not.

Return value (bool): the free-floating status of the particles

void SetEvenlySpaced(evenlySpaced)

Return value: none
evenlySpaced (bool):

bool EvenlySpaced()

Return value (bool):

void SetRandomStartTime(randomStartTime)

Return value: none
randomStartTime (bool):

bool RandomStartTime()

Return value (bool):

void SetSourceDimensions(v)

Sets the shape of the source region of the particle system.

Return value: none
v (const LM_Vector3): the 3D shape of the particle source region

LM_Vector3 SourceDimensions()

Returns the dimensions of the particle source region.

Return value (LM_Vector3): the dimensions of the particle source region

void SetDirection(angle, spread)

Return value: none
angle (float):
spread (float):

void GetDirection(angle, spread)

Return value: none
angle (float):
spread (float):

void SetVelocity(v, spread)

Return value: none
v (float):
spread (float):

void GetVelocity(v, spread)

Return value: none
v (float):
spread (float):

void SetDamping(d)

Return value: none
d (float):

float Damping()

Return value (float):

void SetAcceleration(angle, rate)

Return value: none
angle (float):
rate (float):

void GetAcceleration(angle, rate)

Return value: none
angle (float):
rate (float):

void SetFullSpeedStart(b)

Return value: none
b (bool):

bool FullSpeedStart()

Return value (bool):

AnimBool RunningTrack()

Returns the animation channel that represents the on/off status of the particle simulation.

Return value (AnimBool): the particle on/off animation channel

class PoserActorGroup

New Feature

class ScriptInterface

The ScriptInterface class is a script's way of interacting with the Moho application itself. When a script is invoked (by a mouse click, a key press, or a menu command), it is provided with an object called "moho" - this object is an instance of the ScriptInterface class.

Member Variables

fFrame (int)

The current time in the timeline.


fDoc (MohoDoc)

The current document object open in Moho.


fLayer (MohoLayer)

The currently selected layer in the Layers window.


fView (MohoView)

The editing view.


fGridOn (bool)

True if the grid is turned on in the editing view, otherwise false.


fGridSize (float)

The size of one grid unit.

Member Functions

void Click()

Play a little clicking sound. This is currently used as feedback for welding operations.

Return value: none

void SetCurFrame(frame)

Set the current time.

Return value: none
frame (int): frame number

void UpdateUI()

Force the user interface to redraw itself. This is in case certain elements have become disabled or enabled due to the changing state of the Moho document.

Return value: none

void NewKeyframe(channel)

Tells the timeline window to display a new keyframe in the specified animation channel. This does not actually add the keyframe - you need to do that separately - it just displays the keyframe in the timeline. See the animation channel constants.

Return value: none
channel (int): which animation channel

void UpdateSelectedChannels()

Updates the display of "selected" channels in the timeline. (Like selected points, selected bone, selected shape, etc.) Use this function if your script changes which object(s) are selected.

Return value: none

void SetSelLayer(layer)

Changes which layer is selected in the Layers window.

Return value: none
layer (MohoLayer): new selected layer

MohoLayer CreateNewLayer(layerType)

Creates a new layer, inserts it directly above the currently selected layer in the Layers window, and makes it the selected layer.

Return value (MohoLayer): the new layer
layerType (int): a layer type code

MohoLayer DuplicateLayer(layer)

Duplicates the given layer, placing the new copy above the old one and making it the selected layer.

Return value (MohoLayer): the new layer
layer (MohoLayer): an existing layer to duplicate

void PlaceLayerInGroup(child, group, top)

Moves a layer into a group.

Return value: none
child (MohoLayer): the layer to move
group (MohoLayer): the group layer to put it in
top (bool): true to place it at the top of the group, false to place it at the bottom

void PlaceLayerBehindAnother(moveLayer, behindThis)

Moves one layer behind (or below) another in the layer ordering.

Return value: none
moveLayer (MohoLayer): layer to move
behindThis (MohoLayer): layer to place it behind

ImageLayer LayerAsImage(layer)

Converts a generic layer object into an image layer. The layer is not modified - this is equivalent to "casting" from one type of pointer to another in C. Some functions return a generic layer object, even if the layer is really an image layer - use this function if you need to work with ImageLayer-specific functions.

Return value (ImageLayer): an ImageLayer object
layer (MohoLayer): the layer to cast

GroupLayer LayerAsGroup(layer)

Converts a generic layer object into a group layer.

Return value (GroupLayer): a GroupLayer object
layer (MohoLayer): the layer to cast

SwitchLayer LayerAsSwitch(layer)

Converts a generic layer object into a switch layer.

Return value (SwitchLayer): a SwitchLayer object
layer (MohoLayer): the layer to cast

ParticleLayer LayerAsParticle(layer)

Converts a generic layer object into a particle layer.

Return value (ParticleLayer): a ParticleLayer object
layer (MohoLayer): the layer to cast

Mesh3DLayer LayerAs3D(layer)

Converts a generic layer object into a 3D layer.

Return value (Mesh3DLayer): a Mesh3DLayer object
layer (MohoLayer): the layer to cast

M_Mesh Mesh()

Returns the 2D mesh associated with the currently active layer. If the active layer is not a vector layer, then this function returns nil.

Return value (M_Mesh): a 2D mesh object

void SnapToGrid(v)

Takes a vector position and "snaps" it to the nearest grid intersection.

Return value: none
v (LM_Vector2): the vector to "snap"

void AddPointKeyframe(frame)

Adds a point motion keyframe to all the currently selected vector points.

Return value: none
frame (int): frame number

int CreateShape(filled, frame, checkForBadShapes)

Creates a shape based on the currently selected vector points. Not all shapes are "legal" (for example, non-closed fill shapes), so if this function fails it will return -1.

Return value (int): id number of the new shape
filled (bool): true to create a filled shape, false to create an outline only
frame (int): frame number to create the shape at
checkForBadShapes (bool): true to first do extra testing for "bad" or illegal shapes

float NewShapeLineWidth()

Returns what the line width would be for a new shape. This is based on the user settings in the Style window.

Return value (float): line width for new shapes

void InsertText(text, font, groupTogether, centerH, lineOffset)

Creates a new text object in the currently active vector layer. See the FillInFontList function below for information on how to get a list of the available fonts.

Return value: none
text (string): the text to create
font (string): the name of the font to use
groupTogether (bool): true to group all characters as a single fill shape, false to fill them separately
centerH (bool): true to center the text horizontally, false to left-justify
lineOffset (int): how many lines down to offset the text (used to create multi-line text objects)

M_Skeleton Skeleton()

Returns the skeleton object associated with the current layer. If the current layer is not a bone layer, this function returns nil.

Return value (M_Skeleton): a skeleton object

M_Skeleton ParentSkeleton()

Returns the skeleton object associated with the parent layer of the current layer. If there is no parent layer, or the parent layer is not a bone layer, this function returns nil.

Return value (M_Skeleton): a skeleton object

void UpdateBonePointSelection()

Selects the points that are bound to the currently selected bone.

Return value: none

M_Mesh3D Mesh3D()

Returns the 3D mesh object associated with the current layer. If the current layer is not a 3D layer, this function returns nil.

Return value (M_Mesh3D): a 3D mesh object

float BeginAudioExtraction(path)

Begin extracting amplitude data from an audio file.

Return value (float): the duration (in seconds) of the audio file
path (string): pathname to the audio file

float GetAudioAmplitude(startTime, duration)

Get the average audio amplitude of a section of an audio file. Audio amplitude will be normalized from between 0.0 and 1.0.

Return value (float): average amplitude
startTime (float): the start time (in seconds) of the section to analyze
duration (float): the duration (in seconds) of the section to analyze

float GetAudioRMSAmplitude(startTime, duration)

Get the RMS audio amplitude of a section of an audio file. Audio amplitude will be normalized from between 0.0 and 1.0.

Return value (float): RMS amplitude
startTime (float): the start time (in seconds) of the section to analyze
duration (float): the duration (in seconds) of the section to analyze

float GetAudioMaxAmplitude(startTime, duration)

Get the maximum audio amplitude of a section of an audio file. Audio amplitude will be normalized from between 0.0 and 1.0.

Return value (float): maximum amplitude
startTime (float): the start time (in seconds) of the section to analyze
duration (float): the duration (in seconds) of the section to analyze

void EndAudioExtraction()

Call this function when you're finished extracting audio data from a sound file.

Return value: none

float PixelToDoc(pixel)

When the user specifies things like line width, blur radius, and shadow offset in Moho, they enter a value in pixels. However, behind the scenes, these values are stored in "document coordinates". This allows an animation to be rendered at different resolutions while still looking correct. This function will convert between pixels and document coordinates.

Return value (float): the equivalent distance in document coordinates
pixel (int): a distance in pixels

int DocToPixel(doc)

When the user specifies things like line width, blur radius, and shadow offset in Moho, they enter a value in pixels. However, behind the scenes, these values are stored in "document coordinates". This allows an animation to be rendered at different resolutions while still looking correct. This function will convert between document coordinates and pixels.

Return value (int): the equivalent distance in pixels
doc (float): a distance in document coordinates

int CountPoints()

Returns the number of points in the current vector layer.

Return value (int): number of points

int CountSelectedPoints()

Returns the number of selected points in the current vector layer.

Return value (int): number of selected points

int CountCurves()

Returns the number of curves in the current vector layer.

Return value (int): number of curves

int CountEdges()

Returns the number of edges in the current vector layer. (An edge is one segment of a curve between two control points.)

Return value (int): number of edges

int CountSelectedEdges()

Returns the number of selected edges in the current vector layer. (An edge is considered selected if both points at the ends of the edge are selected.)

Return value (int): number of selected edges

int CountShapes()

Returns the number of shapes in the current vector layer.

Return value (int): number of shapes

int CountSelectedShapes()

Returns the number of selected shapes in the current vector layer.

Return value (int): number of selected shapes

int CountBones()

Returns the number of bones in the current bone layer.

Return value (int): number of bones

int CountSelectedBones()

Returns the number of selected bones in the current bone layer.

Return value (int): number of selected bones

void FillInFontList(list)

Fills in an LM_TextList interface object with the list of available fonts on the system.

Return value: none
list (LM_TextList): a text list GUI object to fill in

LM_Vector3 NoiseVector(pos, amp, freq)

Generates a semi-random vector.

Return value (LM_Vector3): the random vector
pos (LM_Vector3): location to generate the random vector at (nearby locations will have similar "random" vectors)
amp (float): the average amplitude of the generated vector
freq (float): the frequency of the noise

void ImportEPS(path)

Import an EPS or Adobe Illustrator file into Moho, creating a new vector layer to hold it.

Return value: none
path (string): pathname to the imported file

class ScriptPrefs

The ScriptPrefs class allows user scripts to store and retrieve settings. These stored settings are re-loaded each time Moho is run. Stored values are stored under a key name (a text string). Typically, so that different scripts don't interfere with one another, a script should use its own name as part of the key. For example, if the "MyFirstScript" script wanted to save the "pointCount" setting, it would save it using the key "MyFirstScript.pointCount".

Member Functions

void SetBool(key, value)

Store a boolean value.

Return value: none
key (string): the key to locate the value
value (bool): the value to store

bool GetBool(key, defaultValue)

Retrieve a boolean value that was previously stored.

Return value (bool): the stored value
key (string): the key to locate the value
defaultValue (bool): a default value to return if the key cannot be found

void SetInt(key, value)

Return value: none
key (string):
value (int):

int GetInt(key, defaultValue)

Return value (int):
key (string):
defaultValue (int):

void SetFloat(key, value)

Return value: none
key (string):
value (float):

float GetFloat(key, defaultValue)

Return value (float):
key (string):
defaultValue (float):

void SetString(key, value)

Return value: none
key (string):
value (string):

string GetString(key, defaultValue)

Return value (string):
key (string):
defaultValue (string):

class SwitchLayer

Member Functions

string GetValue(frame)

Returns the switch value at a given frame. The value of a switch layer represents which sub-layer is active at that frame.

Return value (string): the switch value at a given frame
frame (int): frame number

void SetValue(frame, value)

Set the switch value at a given frame. The value of a switch layer represents which sub-layer is active at that frame.

Return value: none
frame (int): frame number
value (string): the name of the sub-layer to activate at that frame

AnimString SwitchValues()

Returns the animation channel asscoiated with the switching function.

Return value (AnimString): switch animation channel

bool InterpMode()

Test whether sub-layer interpolation is on or off.

Return value (bool): true if the sub-layers are interpolated during switching, otherwise false

void SetInterpMode(b)

Turn on or off sub-layer interpolation.

Return value: none
b (bool): true to turn on sub-layer interpolation, false to turn it off

void SetSourceFile(path)

Assign a switch data file to the switch layer.

Return value: none
path (string): file path to the switch data file

class TrackingPoint

New Feature

<<  1 2 [3