Autodesk Creative Platform Runtime Library Version 1.5.0
Implicit Capabilities and Client-Side Runtime

Runtime Overview

The Autodesk Creative Platform Runtime is onlyl accessible from the browser DOM member on the Window. The Runtime is not accessible from within a Creative Platform Library.

Introduced in Version: 1.0.0

1 Example:

var runtime = window.creativePlatformRuntime;

Class Member Summary

Class Member Details

• canExecute (library, callback) | Asynchronous

Check whether the library can execute by Runtime library
  • library: Object - The library-version descriptor, where the descriptor entries have the following members:
    • .id: String - The unique ID of the library i.e. lPUtCWdT7Ni
    • .version: Number - Libraries can have multiple versions, so this specifies which version the caller wants
  • callback: Function - A callback function that takes a boolean paramter indicating "can" or "can't" execute

1 Example:

var lib = { id: 'lPUtCWdT7Ni', version: 2 };

window.creativePlatformRuntime.canExecute(lib, function(can){
  if(can){
    ...
    window.creativePlatformRuntime.execute(payload, onSuccess, onError);
    ...
  } else {
    ...
  }
});

File createFile (json)

Creates a File instance given the corresponding json
  • json: Object - Information required to create the File instance

1 Example:

  {
      "url": "http://api.tinkercad.com/resources/public/a92skd23",
      "file": 
  }

Environment environment | Read Only

The environment for the runtime.

• execute (payload, onSuccess, onError)

Execute the specified library giving success and failure callbacks. The execution work is done in the iframe sandbox.
  • payload: Object - Information about the method to execute
    • .id: String - The Library.id of the library to execute.
    • .version: Number - The Library.version of the library to execute.
    • .executionMethod: String - The name of the method to execute.
    • .executionParams: Object - The Key-Value dictionary of parameter values to pass to the method.
    • .executionAsynchronous: Boolean - A boolean value indicating whether it's asynchronous. | Optional
    • .environment: Object - Additional environment variable key-value pairs that will get inserted into the Environment. | Optional
    • .defaultIfMissing: Object - If the execution method is not available, this defines the default value returned. | Optional
    • .scope: Array [ Object ] - If the execution method is not located directly on Library.exports but instead located on a static or function, this allows the caller to specify the scope of the method. Each entry in the array has two members: symbol and symbolIsMethod if the symbol is a method. | Optional
  • onSuccess: Function - A callback function when execution succeeds
  • onError: Function - A callback function when execution fails

3 Examples:

  {
      "id": "xxx",
      "version": 1,
      "executionMethod": "evaluate",
      "scope": [
        { "symbol": "shapeGenerator", "symbolIsMethod": true}
      ],
      "executionAsynchronous": true,
      "executionParams": {
          "height": 13
      },
      "environment": {
           "execution": { "scale": [1, 1, 1], "editorOpen": true}
      }
  }
  {
      "id": "xxx",
      "version": 1,
      "executionMethod": "evaluate",
      "scope": [
        { "symbol": "shapeConfigurator", "symbolIsMethod": true}
      ],
      "executionAsynchronous": true,
      "executionParams": {
          "shape": "xxx",
          "params": {
            "height": 13
          }
      },
      "environment": {
           "execution": { "scale": [1, 1, 1], "editorOpen": true}
      }
  }
  {
      "id": "xxx",
      "version": 1,
      "executionMethod": "evaluate",
      "scope": [
        { "symbol": "shapeModifier", "symbolIsMethod": true}
      ],
      "executionAsynchronous": true,
      "executionParams": {
          "instantces": [{"localToParent":[1,0,0,1....], "mesh":{"vertices":[1.0,1.0,0.0,...],"triangles":[0,1,2...]} }],
          "params": {
            "height": 13
          }
      },
      "environment": {
           "execution": { "scale": [1, 1, 1], "editorOpen": true}
      }
  }

Library findLibrary (criteria) | Coming Soon!

Searches through the existing libraries that are loaded for a particular library based on some search criteria.
  • criteria: Object - Search criteria for the library to find. The fields are mutually exclusive
    • .exportedSymbol: String - The name of an exported symbol to look for - i.e. 'shapeGeneratorEvaluate'

Boolean loadLibrary (library)

Loads a library into the environment assuming the library is already required
  • library: Object - The library-version descriptor, where the descriptor entry has the following members:
    • .id: String - The unique ID of the library i.e. lPUtCWdT7Ni
    • .version: Number - Libraries can have multiple versions, so this specifies which version the caller wants

• reload (library, [callbackOnSuccess], [callbackOnFailure]) | Asynchronous

Reloads a library, then calls a client supplied success or failure callback based on the result. If successfull, the callbackOnSuccess will be invoked with one argument for the library requested, and the arguments provided will be equivalent to Library.exports. If the library has not loaded to the client yet or the reload fails, the callbackOnFailure will be invoked. The reload work is done in the iframe sandbox.
  • library: Object - The library-version descriptor, where the descriptor entries have the following members:
    • .id: String - The unique ID of the library i.e. lPUtCWdT7Ni
    • .version: Number - Libraries can have multiple versions, so this specifies which version the caller wants
  • callbackOnSuccess: Function ( Object , ... ) - A callback to use when the library successfully loaded. | Optional
  • callbackOnFailure: Function ( Object ) - A callback to use if the loading encounters problems. No arguments are currently supplied. | Optional


See Also: Library.exports

1 Example:

var lib = { id: 'lPUtCWdT7Ni', version: 2 };
window.creativePlatformRuntime.reload(lib,
  function (libExports) { console.log('Succeeded!'); },
  function () { console.log('Failed!'); });

• require (libraries, [callbackOnSuccess], [callbackOnFailure]) | Asynchronous

Loads a set of libraries and necessary dependencies, then calls a client-supplied success or failure callback based on the result. If successfull, the callbackOnSuccess will be invoked with one argument for each library requested, and the arguments provided will be equivalent to Library.exports.
  • libraries: Array [ Object ] - An array of library-version descriptors, where the descriptor entries in the array have the following members:
    • .id: String - The unique ID of the library i.e. lPUtCWdT7Ni
    • .version: Number - Libraries can have multiple versions, so this specifies which version the caller wants
  • callbackOnSuccess: Function ( Object , ... ) - A callback to use when all libraries are successfully loaded. The number of arguments should be equal to the number of libraries in the libraries argument. | Optional
  • callbackOnFailure: Function ( Object ) - A callback to use if the loading encounters problems. No arguments are currently supplied. | Optional


See Also: Library.exports

1 Example:

var lib1 = { id: 'lPUtCWdT7Ni', version: 2 };
var lib2 = { id: 'h5umhDTzkhs', version: 3 };
window.creativePlatformRuntime.require([lib1, lib2],
  function (lib1Exports, lib2Exports) { console.log('Succeeded!'); },
  function () { console.log('Failed!'); });