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.
The current time in the timeline.
The current document object open in Moho.
The currently selected layer in the Layers window.
The editing view.
True if the grid is turned on in the editing view, otherwise false.
The size of one grid unit.
Play a little clicking sound. This is currently used as feedback for welding operations.
Return value: noneSet the current time.
Return value: none frame (int): frame numberForce 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: noneTells 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 channelUpdates 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: noneChanges which layer is selected in the Layers window.
Return value: none layer (MohoLayer): new selected layerCreates 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 codeDuplicates 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 duplicateMoves 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 bottomMoves one layer behind (or below) another in the layer ordering.
Return value: none moveLayer (MohoLayer): layer to move behindThis (MohoLayer): layer to place it behindConverts 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 castConverts a generic layer object into a group layer.
Return value (GroupLayer): a GroupLayer object layer (MohoLayer): the layer to castConverts a generic layer object into a switch layer.
Return value (SwitchLayer): a SwitchLayer object layer (MohoLayer): the layer to castConverts a generic layer object into a particle layer.
Return value (ParticleLayer): a ParticleLayer object layer (MohoLayer): the layer to castConverts a generic layer object into a 3D layer.
Return value (Mesh3DLayer): a Mesh3DLayer object layer (MohoLayer): the layer to castReturns 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 objectTakes a vector position and "snaps" it to the nearest grid intersection.
Return value: none v (LM_Vector2): the vector to "snap"Adds a point motion keyframe to all the currently selected vector points.
Return value: none frame (int): frame numberCreates 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 shapesReturns 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 shapesCreates 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)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 objectReturns 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 objectSelects the points that are bound to the currently selected bone.
Return value: noneReturns 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 objectBegin extracting amplitude data from an audio file.
Return value (float): the duration (in seconds) of the audio file path (string): pathname to the audio fileGet 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 analyzeGet 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 analyzeGet 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 analyzeCall this function when you're finished extracting audio data from a sound file.
Return value: noneWhen 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 pixelsWhen 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 coordinatesReturns the number of points in the current vector layer.
Return value (int): number of pointsReturns the number of selected points in the current vector layer.
Return value (int): number of selected pointsReturns the number of curves in the current vector layer.
Return value (int): number of curvesReturns 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 edgesReturns 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 edgesReturns the number of shapes in the current vector layer.
Return value (int): number of shapesReturns the number of selected shapes in the current vector layer.
Return value (int): number of selected shapesReturns the number of bones in the current bone layer.
Return value (int): number of bonesReturns the number of selected bones in the current bone layer.
Return value (int): number of selected bonesFills 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 inGenerates 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 noiseImport 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