MochaImport+ V6 comes with build-in KBar support, which means that you can execute any MochaImport+ function using custom toolbar buttons of KBar (or let any other scripts remote execute MochaImport+ functions).

You want a single button that loads the tracking data, duplicates your layer and creates a stabilized precomp on the duplicate? Yes, we've got you covered!

Overview

Overview

To create a custom KBar button, go to the KBar Settings, click on "Add Button" and choose as button type "Run JSX/JSXBIN File".

In the dialog that opens, choose the MochaImport+ script (MochaImportPlus.jsxbin) as file to execute and enter at Script function or argument one of the functions listed in the section Available Functions below. If you leave the script function field empty, the button will simply launch MochaImport+ and show its user interface.

Available Functions

for tracking

  • trackInMocha
    (like clicking the "track" button)

for loading tracking data

  • loadFromFile
    (shows file open dialog to load tracking data from a file)
  • loadFromClipboard
    (loads tracking data from the clipboard)
  • loadFromEffect
    (loads tracking data from the mocha effect of the selected layer)
  • loadFromCornerPin
    (loads tracking data from the selected corner pin effect)

for applying Tracking Data

  • applyCornerPin
    (applies corner pin to the selected layer)
  • moveLayers
    (moves the selected layer(s))
  • moveProperties
    (moves the selected point properties or masks)
  • stabilizedPrecomp
    (creates a stabilized precomp from the selected layer)
  • stabilizeLayer
    (stabilizes selected layer)
  • generateAeTrackpoints
    (creates Ae track points from the mocha tracking data)

to execute the toolbar functions

  • addKeyframe
    (like clicking the "Add Keyframe" button in the MochaImport+ toolbar)
  • sendFromToPrecomp
    (like clicking the "Send from/to Precomp" button in the MochaImport+ toolbar

Icons

You can use the following icons for your KBar buttons.

Download Icon Pack

You created your own icons and want to share them here? Please let us know!

Advanced Features

Executing Several Functions

Sometimes a button should do more than just one thing. You can simply enter several functions separated by white-space or semicolons:

loadFromClipboard applyCornerPin
This first loads tracking data from the clipboard and then applies a corner pin effect to the selected layer. If you like, you can also write it as
loadFromClipboard;applyCornerPin
or
loadFromClipboard() applyCornerPin()

Function Arguments

You can provide optional arguments for your script functions. If you enter as function

trackInMocha
the button creates the mocha effect on the selected layer. But if you enter
trackInMocha({layer:app.project.activeItem.layers(1)})
it applies it to the first layer of the composition instead. Note that the arguments are given as an object, i.e. have the form
({argument1:value1, argument2:value2})
.

List of available function arguments

  • trackInMocha({layer})
  • loadFromFile({file})
  • loadFromClipboard({})
  • loadFromEffect({mochaEffectProp})
  • loadFromCornerPin({cornerPinEffectProp})
  • addKeyframe({propertiesArray, time})
  • applyCornerPin({layer, cornerPinEffect, useLiveExpressions, keepCurrentFrame})
  • moveLayers({layerArray})
  • moveProperties({propertyArray, useLiveExpressions})
  • stabilizedPrecomp({layer, cornerPinEffect, scaleFactor, useLiveExpressions, collapseTransformations})
  • stabilizeLayer({layer, useTransformData, smoothMovement, cornerPinEffect})
  • generateAeTrackpoints({layer, exportCorners, exportPosition})
  • sendFromToPrecomp({})

In addition, all functions accept the following two arguments:

  • forceNoUndoGroup (bool)
    - forces MochaImport+ to create no undo groups
  • silent (bool)
    - forces MochaImport+ to show no dialogs or messages (instead of a message it then throws an error when something went wrong).

eval - executing any scripting code

The special function eval allows you to execute arbitrary scripting code:

eval(alert("Hello World"))
This is useful if you want to combine the execution of MochaImport+ functions with other scripting tasks in a single button.

Examples

Note that the examples are written in multiple lines for better readability, but have to be entered without linebreaks as a single line in the Kbar function field.

  • Load tracking data from selected layer, duplicate the layer, create a stabilized precomp with the tracking data and move the precomp on top of the duplicate.

    loadFromEffect({silent:true});
    eval(duplicate = app.project.activeItem.selectedLayers[0].duplicate());
    stabilizedPrecomp();
    eval(app.project.activeItem.selectedLayers[0].moveBefore(duplicate))