Skip to main content

Customise Javascript based DCCs

Photoshop Javascript function

In this example we will show how to add a new function to the Photoshop CEP plugin, that can be called from the integration using the RPC mechanism.

We will also demonstrate how to execute a custom call when the ftrack integration is up and running.

  1. Copy projects/framework-photoshop/extensions/js/ps-include.jsx to a new folder locally, or in your pipeline repository to have it under source control.
  2. Modify the file to include the new function:
/*
ftrack Photoshop Framework integration extendscript base functions

Exposed by RPC call event to Python standalone host.

Copyright (c) 2024 ftrack
*/

// Add additional functions here

function showMessage(message) {
alert("Message to user: "+message);
return message;
}

  1. Copy bootstrap-dcc.js to the same folder as ps-include.jsx and modify it to include the new function, and make a call when the integration is up and running:

/*
ftrack Adobe Photoshop framework integration bootstrap

Copyright (c) 2024 ftrack
*/


function jsx_callback(){
console.log("ps.jsx loaded");
}

try {
jsx.evalFile('./ps.jsx', jsx_callback);
} catch (e) {
error("[INTERNAL ERROR] Failed to load JSX resource "+e+" Details: "+e.stack);
}

function jsx_include_callback(){
console.log("ps-include loaded");
}

// Load custom extension JSX if exists
try {
jsx.evalFile('./ps-include.jsx', jsx_include_callback);
} catch (e) {
console.log("[WARNING] Failed to load JSX include resource "+e+" Details: "+e.stack);
}

// Whitelisted functions and their mappings, add entrypoints from ps.jsx here
window.FTRACK_RPC_FUNCTION_MAPPING = {
hasDocument:"hasDocument",
documentSaved:"documentSaved",
getDocumentPath:"getDocumentPath",
getDocumentData:"getDocumentData",
saveDocument:"saveDocument",
exportDocument:"exportDocument",
openDocument:"openDocument",
showMessage:"showMessage"
};

window.ftrackInitialiseExtension = function(session, event_manager, remote_integration_session_id) {
// Do additional initialisations here
};


window.ftrackIntegrationConnected = function() {
// React upon integration connected
alert("My integration is running!");
};

  1. Follow the instructions in the Photoshop integration README to prepare the CEP plugin build.
  2. Rebuild the ZXP plugin to include the new files and deploy it to your users:
    python tools/build.py build_cep --include <path-to-custom-javascript-functions> projects/framework-photoshop

Distribute and install the XZP plugin as required, in your custom framework extensions you should now be able to make an RPC call to showMessage(..) function.