Autodesk Creative Platform Library Editor Version 1.1.1
The IDE for Creative Platform Libraries

Editor Overview

The Editor is a UI component that allows the user to create/modify and extend Creative Platform Libraries.

Introduced in Version: 1.0.0

1 Example:

// Creates an instance of the Editor. 
creativePlatformRuntime.require(
  [{
    id: "1QyQF3M4CQ3", 
    version: 0
  }], // The ID of the Creative Library Editor

  function(library) { // The callback when it downloads
    
    //Get the editor object.
    var editor = library.editor;
    
    //Pass the parent withing which the editor should be created. This creates the Editor UI and initializes it.
    editor.initialize($('body'));
  
    //Load a specific Library by passing in the library id and version. Optionally, pass the callback parameter 
    //which raises the callback function after the Library has been loaded and/or the read only attribute which 
    //specifies if the Library should be editable or readonly.
    editor.loadLibrary(id, ver, {'callback' : function () { }, 'readonly': readonly});

  },
  function() { // Called on failure

  }
);

Class Member Summary

Class Member Details

• addResult (info)

Adds result information from a script execution. Since there could be multiple instances of a single library, each instance may have a unique set of outputs depending on the parameters for it. This function allows the application to append each result to editor so the editor can choose to present them.
  • info: Object - Information directly from the cloud infrastructure.
    • .stack: String - The raw stack trace from the cloud infrastructure. | Optional
    • .log: String - Information logged from the plugin using Debug.log. | Optional
    • .warning: String - Warnings logged from the plugin using Plugin.warning. | Optional
    • .error: String - Fatal error logged from the plugin using Plugin.panic. | Optional
    • .exception: Object - Information about an exception that occurred. | Optional
      • .description: String - A description of the error.
      • .stack: Array [ Object ] - The callstack information when the error occurred.
      • .stack.file: String - The filename
      • .stack.line: Number - The line number
      • .stack.column: Number - The column number
      • .stack.libraryId: String - The unique identifier of the library that contains the file
      • .stack.libraryVersion: Number - The version of the library that contains the file

2 Examples:

//This will show the error "some error" in the console.
editor.addResult({exception : {description :'some error'}});
//This will show the error "some error" in the console and highlight the line 120 on main.js
//if the "someid" library is currently displayed. 
editor.addResult({exception : {description :'some error'}, 
                  stack: {file: 'main.js', 
                          line: 120, 
                          column: 10, 
                          libraryId: 'someid', 
                          libraryVersion: 0
                          }
                  });

EventSource changed

The event that will be fired when the Editor changes (on save, release).

1 Example:

//Bind the changed event to perform some activity when the user saves or releases the Library within the Editor.
editor.changed.bind(function() {

  //Perform some task when the editor has some change

});

EventSource closeclick

The event that will be fired when the Close button is clicked.

1 Example:

//Bind the close button click event so that you can hide or close the editor UI or perform some other task 
//when the user closes the Editor.
editor.closeclick.bind(function() {  

  //Perform some action to hide/close the editor container

});

• createNewLibrary (options)

Creates a new Library and loads it in the Editor. This will replace any existing library loaded in the editor.
  • options: Object - Optional properties.
    • .callback: Function - An optional callback function that will be called on completion with true/false as an argument which specifies the success state of loading the library.
    • .readonly: Boolean - Loads the editor in a read-only mode if set to true. Note that setting this to false does not necessarily mean that the editor will load in the edit mode.

4 Examples:

editor.createNewLibrary();
editor.createNewLibrary({callback: function () { //Perform tasks after the library is loaded }});
editor.createNewLibrary({callback: function () { //Perform tasks after the library is loaded }, readonly: false});
editor.createNewLibrary({readonly: false});

• initialize (parent)

Initializes the Editor by passing in the parent element it needs to be bound to.
  • parent: HTMLElement - The container within which the Editor should be created.

1 Example:

editor.initialize($('body'));

• loadLibrary (libraryid, version, options)

Loads a library into the editor.
  • libraryid: String - The unique id of the library.
  • version: Number - The version of the library.
  • options: Object - Optional properties.
    • .callback: Function - An optional callback function that will be called on completion with true/false as an argument which specifies the success state of loading the library.
    • .readonly: Boolean - Loads the editor in a read-only mode if set to true. Note that setting this to false does not necessarily mean that the editor will load in the edit mode.

4 Examples:

editor.loadLibrary('someid',0);
editor.loadLibrary('someid',0, {callback: function () { //Perform tasks after the library is loaded }});
editor.loadLibrary('someid',
                    0, 
                    {
                      callback: function () { //Perform tasks after the library is loaded }, 
                      readonly: false
                    }
                  );
editor.loadLibrary('someid',0, {readonly: false});

• saveAll()

Saves all modified files to the server if they have not been saved yet.