In design automation, appbundle can be used to provide custom code, plugin, script, content that need to be used during every workitem execution.
In this sample we provide an appbundle that automatically load a maxscript file on 3ds Max start up.
The appbundle that is uploaded to design automation must be a zip that contain a folder with a name that finish with .bundle.
In this folder there should be an xml file name PackageContents.xml. This file will describe to 3ds Max what to load on start up. For more documentation on this xml file check here.
In this sample, the PackageContents.xml file mention that functions.ms must be loaded as a pre-start-up script.
In this script we define a maxscript function customMaxscriptFunctionDefinedInAppBundleToExportToFBX that contain the logic to export the current scene to FBX.
This function is used inside our activity definition, where we define the 3dsmaxbatch.exe command line to be executed.
The createAndUploadApp.js create and upload the appbundle following these steps:
- Zip the ../appbundle/export.bundle folder.
- Delete the appbundle versions and alias that might already exist by calling DELETE appbundles/:id.
- Create the first version of the appbundle by calling POST appbundles using postApp.hbs template to generate the body of the request.
- Upload the zipped folder from step 1. To do so, we take the form-data and url from the response received by creating the appbundle in step 3 and we add the field
filewhere we add the content of the zip file. - Create an alias that point to version 1 of the appbundle by calling POST appbundles/:id/aliases using postAlias.hbs template to generate the body of the request.
For more details take a look at the createApp inside appCreator.js.
Note: In an iterative process, it might be more appropriate to create new versions of your appbundle instead of deleting it every time. This can be done using POST appbundles/:id/versions.
In design automation an activity define what need to be executed when sending a workitem. It also define what appbundle needs to be loaded and what are the parameters that will need to be provided when sending a workitem.
The createActivity.js script create the activity following these steps:
- Delete the activity versions and alias that might already exist by calling DELETE activities/:id.
- Create the first version of the activity by calling POST activities using postActivityExportToFBX.hbs template to generate the body of the requests.
- Create an alias that point to version 1 of the appbundle by calling POST activities/:id/aliases using postAlias.hbs template to generate the body of the request.
For more detail you can look at the createActivity function in activityCreator.js.
Note: In an iterative process, it might be more appropriate to create new versions of your activity instead of deleting it every time. This can be done using POST activities/:id/versions.
When sending a workitem, we will need to provide urls to download the inputs and uploads the output specified in the activity.
The executeWorkitem.js script, manage the upload of input 3ds Max file from your local machine to OSS. It also manage the creation of signed urls that will be used for the arguments when sending the workitem.
Generating signed urls is done following these steps:
- Retrieve the name of the bucket to use from the config file. Check
Setup Config filesection of this README.md for more information. - Check if the bucket already exist and our forge app is the owner of the bucket. This is done by calling GET buckets/:bucketKey/details.
- If the bucket doesn't exist, create it by calling POST buckets.
- Generate the required signed url by calling POST buckets/:bucketKey/objects/:objectName/signed.
The workitem is what launch the execution of an activity on design automation. The executeWorkitem.js script by calling POST workitems using postWorkitemExportToFBX.bhs template to generate the body of the request.
NOTE: In this sample we wait for the workitem to complete by polling for status using GET workitems/:id requests. The prefered way to get notify when a workitem is completed is to register a callback url using the onComplete argument in the body when sending your POST workitems request.
This is a special argument that can be used without being defined in the activity.
Here is an example of how to use the onComplete argument:
"arguments": {
"onComplete": {
"url": "https://yourUrlToCallbackHere.com/callback/on/complete"
"verb": "post",
"ondemand": true
}
}
The resulting FBX file should be downloaded back from OSS in the Results folder. This folder will get created if it doesn't exist. The file will be named with the jobId which can be found the in console output when running executeWorkitem.js.