Class ScriptInterface
Version added: before 9.5
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.
Methods of ScriptInterface:
| Name | Returns | Description | Ver |
| AddPointKeyframe AddPointKeyframe(frame, layer, allSelectedKeys) | void | Adds a point motion keyframe to all the currently selected vector points | < 9.5 |
| AlignLayers AlignLayers(alignMessage) | void | Added in version 11.1 | 11.1 |
| AnglesEquivalent AnglesEquivalent(a1, a2, threshold) | bool | Added in version 14.4 | 14.4 |
| AppDir AppDir(variantDir) | char | Returns the path to Moho's application data | < 9.5 |
| AppVersion AppVersion() | char | Added in version 9.5 - Gets the AS version number as a text string | 9.5 |
| BeginFileListing BeginFileListing(dir, listHiddenAndSystemFiles) | void | < 9.5 | |
| BindingKeyName BindingKeyName() | char | Added in version 11 | 11.0 |
| ChannelAsAnimBool ChannelAsAnimBool(ch) | AnimBool | Added in version 12 | 12.0 |
| ChannelAsAnimColor ChannelAsAnimColor(ch) | AnimColor | Added in version 12 | 12.0 |
| ChannelAsAnimString ChannelAsAnimString(ch) | AnimString | Added in version 12 | 12.0 |
| ChannelAsAnimVal ChannelAsAnimVal(ch) | AnimVal | Added in version 12 | 12.0 |
| ChannelAsAnimVec2 ChannelAsAnimVec2(ch) | AnimVec2 | Added in version 12 | 12.0 |
| ChannelAsAnimVec3 ChannelAsAnimVec3(ch) | AnimVec3 | Added in version 12 | 12.0 |
| CheckIfLocked CheckIfLocked(layer, showAlert) | bool | < 9.5 | |
| Click Click() | void | Play a little clicking sound | < 9.5 |
| ClipboardText ClipboardText() | char | Added in version 9.5 | 9.5 |
| Copy Copy(mesh) | void | Basically the same as pressing Ctrl+C | < 9.5 |
| CopyAlternate CopyAlternate(mesh) | void | < 9.5 | |
| CopyColor CopyColor(color) | void | Added in version 9.5 | 9.5 |
| CopyText CopyText(text) | void | Added in version 9.5 | 9.5 |
| CountAudioLayers CountAudioLayers() | int32 | < 9.5 | |
| CountBones CountBones() | int32 | Returns the number of bones in the current bone layer | < 9.5 |
| CountCurves CountCurves() | int32 | Returns the number of curves in the current vector layer | < 9.5 |
| CountEdges CountEdges() | int32 | Returns the number of edges in the current vector layer | < 9.5 |
| CountFilledShapes CountFilledShapes() | int32 | Added in version 12 | 12.0 |
| CountPoints CountPoints() | int32 | Returns the number of points in the current vector layer | < 9.5 |
| CountSelectedBones CountSelectedBones(updateCount) | int32 | Returns the number of selected bones in the current bone layer | < 9.5 |
| CountSelectedCurves CountSelectedCurves(updateCount) | int32 | < 9.5 | |
| CountSelectedEdges CountSelectedEdges(updateCount) | int32 | Returns the number of selected edges in the current vector layer | < 9.5 |
| CountSelectedFilledShapes CountSelectedFilledShapes() | int32 | Added in version 12 | 12.0 |
| CountSelectedPoints CountSelectedPoints(updateCount) | int32 | Returns the number of selected points in the current vector layer | < 9.5 |
| CountSelectedShapes CountSelectedShapes(updateCount) | int32 | Returns the number of selected shapes in the current vector layer | < 9.5 |
| CountShapes CountShapes() | int32 | Returns the number of shapes in the current vector layer | < 9.5 |
| CreateNewLayer CreateNewLayer(layerType, undoable) | MohoLayer | Creates a new layer, inserts it directly above the currently selected layer in the Layers window, and makes it the selected layer | < 9.5 |
| CreateShape CreateShape(filled, behindNeighborStrokes, frame, checkForBadShapes, skipDuplicateStrokes, skipFill, skipLine) | int32 | Creates a shape based on the currently selected vector points | < 9.5 |
| CreateTextObject CreateTextObject() | void | < 9.5 | |
| CurrentEditStyle CurrentEditStyle() | M_Style | Added in version 9.5 | 9.5 |
| CurrentTool CurrentTool() | char | Added in version 12 | 12.0 |
| DeleteLayer DeleteLayer(layer) | void | < 9.5 | |
| DeleteMultipleLayers DeleteMultipleLayers() | void | Deletes selected layers | < 9.5 |
| DeselectShapes DeselectShapes() | void | Added in version 11 | 11.0 |
| DestroyDocument DestroyDocument(doc) | void | < 9.5 | |
| DisableDrawingTools DisableDrawingTools() | bool | < 9.5 | |
| DocToPixel DocToPixel(doc) | real | When the user specifies things like line width, blur radius, and shadow offset in Moho, they enter a value in pixels | < 9.5 |
| DrawingMesh DrawingMesh() | M_Mesh | Added in version 11 | 11.0 |
| DrawShape DrawShape(g, mesh, shapeID) | void | Added in version 10 | 10.0 |
| DuplicateLayer DuplicateLayer(layer, byReference) | MohoLayer | Duplicates the given layer, placing the new copy above the old one and making it the selected layer | < 9.5 |
| EditLayerSettings EditLayerSettings() | void | Doesn't seem to do anything. | < 9.5 |
| ExporterPath ExporterPath() | char | Added in version 12 | 12.0 |
| FileClose FileClose() | void | Added in version 11 | 11.0 |
| FileImport FileImport(path, mode) | void | < 9.5 | |
| FileNew FileNew() | void | < 9.5 | |
| FileOpen FileOpen(path) | void | < 9.5 | |
| FileRender FileRender(path) | void | Render current frame | < 9.5 |
| FileSave FileSave() | void | < 9.5 | |
| FileSaveAs FileSaveAs(path) | void | < 9.5 | |
| FillInFontList FillInFontList(list) | void | Fills in an LM_TextList interface object with the list of available fonts on the system | < 9.5 |
| GetAudioLayer GetAudioLayer(id) | AudioLayer | < 9.5 | |
| GetNextFile GetNextFile() | char | < 9.5 | |
| HasMaximumSmartBones HasMaximumSmartBones() | bool | Added in version 14.0 | 14.0 |
| HasMaximumWarpLayers HasMaximumWarpLayers() | bool | Added in version 14.0 | 14.0 |
| ImportEPS ImportEPS(path) | void | Import an EPS or Adobe Illustrator file into Moho, creating a new vector layer to hold it | < 9.5 |
| InsertText InsertText(text, font, fill, stroke, groupTogether, centerH, lineOffset) | void | Deprecated. Use the new InsertText method instead. | < 9.5 |
| InsertText InsertText(textParams, lineOffset) | void | Creates a new text object | < 9.5 |
| IsCopyable IsCopyable() | bool | < 9.5 | |
| IsPasteable IsPasteable() | bool | < 9.5 | |
| IsPlaying IsPlaying() | bool | < 9.5 | |
| IsPro IsPro() | bool | Added in version 10 | 10.0 |
| LayerAs3D LayerAs3D(layer) | Mesh3DLayer | Converts a generic layer object into a 3D layer | < 9.5 |
| LayerAsAudio LayerAsAudio(layer) | AudioLayer | < 9.5 | |
| LayerAsBone LayerAsBone(layer) | BoneLayer | < 9.5 | |
| LayerAsGroup LayerAsGroup(layer) | GroupLayer | Converts a generic layer object into a group layer | < 9.5 |
| LayerAsImage LayerAsImage(layer) | ImageLayer | Converts a generic layer object into an image layer | < 9.5 |
| LayerAsNote LayerAsNote(layer) | NoteLayer | < 9.5 | |
| LayerAsParticle LayerAsParticle(layer) | ParticleLayer | Converts a generic layer object into a particle layer | < 9.5 |
| LayerAsSwitch LayerAsSwitch(layer) | SwitchLayer | Converts a generic layer object into a switch layer | < 9.5 |
| LayerAsVector LayerAsVector(layer) | MeshLayer | < 9.5 | |
| LayersWindowGetSearchContext LayersWindowGetSearchContext() | LayersWindowSearchContext | Added in version 12.2 | 12.2 |
| LayersWindowGetSearchContextValue LayersWindowGetSearchContextValue() | char | Added in version 12.2 | 12.2 |
| LayersWindowSetSearchContext LayersWindowSetSearchContext(context) | void | Added in version 12.2 | 12.2 |
| LayersWindowSetSearchContextValue LayersWindowSetSearchContextValue(val) | void | Added in version 12.2 | 12.2 |
| LoadDocument LoadDocument(path) | MohoDoc | < 9.5 | |
| Mesh Mesh() | M_Mesh | Returns the 2D mesh associated with the currently active layer | < 9.5 |
| Mesh3D Mesh3D() | M_Mesh3D | Returns the 3D mesh object associated with the current layer | < 9.5 |
| NewKeyframe NewKeyframe(channel) | void | Tells the timeline window to display a new keyframe in the specified animation channel | < 9.5 |
| NewShapeFillColor NewShapeFillColor() | rgb_color | Added in version 9.5 | 9.5 |
| NewShapeLineColor NewShapeLineColor() | rgb_color | Added in version 9.5 | 9.5 |
| NewShapeLineWidth NewShapeLineWidth() | real | Returns what the line width would be for a new shape | < 9.5 |
| NewShapeProperties NewShapeProperties() | M_Shape | < 9.5 | |
| NoiseVector NoiseVector(pos, amp, freq) | Vector3 | Generates a semi-random vector | < 9.5 |
| OpenPoserPalette OpenPoserPalette() | void | < 9.5 | |
| ParentSkeleton ParentSkeleton() | M_Skeleton | Returns the skeleton object associated with the parent layer of the current layer | < 9.5 |
| Paste Paste() | void | Basically the same as pressing Ctrl+V | < 9.5 |
| PasteAlternate PasteAlternate() | void | < 9.5 | |
| PickStyleProperties PickStyleProperties(fromShape, skipFill, skipLine) | void | < 9.5 | |
| PixelToDoc PixelToDoc(pixel) | real | When the user specifies things like line width, blur radius, and shadow offset in Moho, they enter a value in pixels | < 9.5 |
| PlaceLayerBehindAnother PlaceLayerBehindAnother(moveLayer, behindThis) | void | Moves one layer behind (or below) another in the layer ordering | < 9.5 |
| PlaceLayerInGroup PlaceLayerInGroup(child, group, top, isUndoable) | void | Moves a layer into a group | < 9.5 |
| PresentFile PresentFile(path) | void | Open file in the default app, or display it in the Finder/Explorer, etc. | 14.4 |
| PurgeTracingImage PurgeTracingImage() | void | Added in version 11 | 11.0 |
| PushStyleProperties PushStyleProperties(toShape, skipFill, skipLine) | void | < 9.5 | |
| Quit Quit() | void | < 9.5 | |
| RestoreTracingImage RestoreTracingImage() | bool | Added in version 11 | 11.0 |
| SaveTracingImage SaveTracingImage() | void | Added in version 11 | 11.0 |
| SelectedShape SelectedShape() | M_Shape | Returns the first selected shape, but starting in version 10 there may be multiple selected shapes. (This method added in version 10) | 10.0 |
| SetCurFrame SetCurFrame(frame, outAccess, enableBoneDynamics) | void | Set the current time | < 9.5 |
| SetNewShapeLineWidth SetNewShapeLineWidth(width);) | void | Added in version 11 | 11.0 |
| SetSelLayer SetSelLayer(layer, multiSelect, allowDeselect) | void | Changes which layer is selected in the Layers window | < 9.5 |
| ShowLayerInLayersPalette ShowLayerInLayersPalette(layer) | void | < 9.5 | |
| Skeleton Skeleton() | M_Skeleton | Returns the skeleton object associated with the current layer | < 9.5 |
| SnapToGrid SnapToGrid(v) | void | Takes a vector position and "snaps" it to the nearest grid intersection | < 9.5 |
| TraceWhitePixels TraceWhitePixels(frame, gapFilling) | int32 | Added in version 10 | 10.0 |
| UpdateBonePointSelection UpdateBonePointSelection() | void | Selects the points that are bound to the currently selected bone | < 9.5 |
| UpdateSelectedChannels UpdateSelectedChannels() | void | Updates the display of "selected" channels in the timeline | < 9.5 |
| UpdateUI UpdateUI() | void | Force the user interface to redraw itself | < 9.5 |
| UserAppDir UserAppDir() | char | < 9.5 | |
| UserContentDir UserContentDir() | char | The path to the directory structure that holds User Content. | 13.5.2 |
| UserPrefsDir UserPrefsDir() | char | 13.5.2 | |
| UserPrefsFile UserPrefsFile() | char | 13.5.2 |
Properties of ScriptInterface:
| Name | Type | Description | Ver |
| document | MohoDoc | The current document object open in Moho | < 9.5 |
| drawingFrame | int32 | Added in version 11 | 11.0 |
| drawingLayer | MohoLayer | Added in version 11. This is the vector layer where drawn paths / shapes will be placed and, especially when using frame-by-frame, is not necessarily the layer that is shown as active in the Layers window | 11.0 |
| drawingLayerFrame | int32 | Added in version 11 | 11.0 |
| frame | int32 | The current frame in the timeline | < 9.5 |
| gridOn | bool | True if the grid is turned on in the editing view, otherwise false | < 9.5 |
| gridSize | real | The size of one grid unit | < 9.5 |
| layer | MohoLayer | The currently selected layer in the Layers window | < 9.5 |
| layerFrame | int32 | the frame relative to the start of the layer (if the layer has not been moved in the sequencer this will be the same as the timeline frame) | < 9.5 |
| view | MohoView | The editing view | < 9.5 |