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

Library Overview

A static object that represents the runtime instance of a Library, and provides some informational and configuration capabilities to the Library developer.

Introduced in Version: 1.0.0

Static Member Summary

Static Member Details

String description | Read Only

The description of the library.

Object [ String , Object ] exports | Read Only

The exported functionality the library provides its clients. A library developer can export functionality using this member. This is the object a user receives as the Alias reference when referencing another library, or on the client side when using the require function on the Runtime.

See Also: Runtime.require

1 Example:

var InternalObject = function() {
    // Class Implementation
};
Library.exports.ExportedObject = InternalObject;

String id | Read Only

The unique identifier of the library.

String imageURL ([resourceId])

This is a specialized version of resourceURL which accomodates the browser's devicePixelRatio properly when used correctly. For this API, the developer must name their resources such that the suffix corresponds to the file size. For example:

  • thumbnail-32x32.jpg
  • thumbnail-64x64.jpg
  • icon16x16.png
  • icon32x32.png

In this example, the method will do the following things:

  • First it will determine the browser's devicePixelRatio. If it's 1:1 it will return the original filename, otherwise continue.
  • Next it will parse out the size from the resource - such as 32 (Width) by 32 (Height) from thumbnail-32x32.jpg
  • If the ratio is 2:1 for example, then it will check to see whether a 64 x 64 version of the image exists.
  • In this case it will find thumbnail-64x64.jpg and return the URL for it instead of thumbnail-32x32.jpg

This responsive behavior is to accomodate devices such as the Retina Display Macbook. The only naming requirement when using this API is that the filename must conform to this format: <anything><width>x<height>.<extension>

  • resourceId: String - An Item ID (i.e. '1vxKXGNaLtr') or a Resource Filename (i.e. 'thumbnail-32x32.jpg') | Optional
See Also: resourceURL

2 Examples:

var urlToImage = Library.imageURL('thumbnail-32x32.jpg');
var urlToImage = Library.imageURL('icon16x16.png');

String name | Read Only

The name of the library.

• resourceDataView (resourceId, callback) | Asynchronous

Allows a library author to access the content of a resource as binary, given the id of the resource.
  • resourceId: String - An Item ID (i.e. '1vxKXGNaLtr') or a Resource Filename (i.e. 'custom.css')
  • callback: Function ( DataView ) - A function that is called with a view of the resource once loaded.

1 Example:

function shapeGeneratorEvaluate(params, callback) {
    Library.resourceDataView('dolphin-binary.stl', function(dataView) {
        var mesh = Conversions.toMesh3DFromSTL(dataView);
        var solid = Solid.make(mesh);
        callback(solid);
    });
}

File resourceFile (resourceId)

Allows a library author to get a File instance of a resource file.
  • resourceId: String - An Item ID (i.e. '1vxKXGNaLtr') or a Resource Filename (i.e. 'custom.css')

1 Example:

var file = Library.resourceFile('custom.css');

Array [ LibraryResourceJSON ] resources | Read Only

Information about the resources that are included in the library.

• resourceText (resourceId, callback) | Asynchronous

Allows a library author to access the content of a resource as text, given the id of the resource.
  • resourceId: String - An Item ID (i.e. '1vxKXGNaLtr') or a Resource Filename (i.e. 'custom.css')
  • callback: Function ( String ) - A function that is called with the content of the resource once loaded.

1 Example:

function shapeGeneratorEvaluate(params, callback) {
    Library.resourceText('Circle.svg', function(resourceContent) {
        var sketch = Conversions.toSketch2DFromSVG(resourceContent);
        var solid = Solid.extrude(sketch, 10.0);
        callback(solid);
    });
}

String resourceURL ([resourceId])

Allows a library author to get a public web-addressable URL for an item in the library. If resourceId is not provided, then the base URL is returned, which can then be used to concatenate the Item ID or Resource Name onto at a later time when there are 2+ items to retrieve. If the developer is trying to load an image, then it is suggested that they use imageURL which handles a browser's devicePixelRatio properly.
  • resourceId: String - An Item ID (i.e. '1vxKXGNaLtr') or a Resource Filename (i.e. 'custom.css') | Optional
See Also: imageURL

1 Example:

var urlToCss = Library.resourceURL('custom.css');

Number version | Read Only

The version of the library. The initial version is 0. Each time the library is published, the version is incremented by 1.