Request

Response

    Autodesk.Viewing
    Version 8 preview
    This page documents a preview of the Viewer SDK v8. APIs and content can still change before the final release.

    PropDbLoader

    Per model property database interface, talks to the worker thread behind the scenes.

    new PropDbLoader(sharedDbPath, model, eventTarget)

    Parameters

    sharedDbPath*
    model*
    eventTarget*
    * Required

    Methods

    getAttributeDefinitions(force)

    Gets a list of all available attributes in the property database

    Parameters

    force
    boolean
    fetch the attribute definitions afresh (and update the cache)

    Returns

    typedescription
    Promise ({category: string, dataTypeContext: (string|undefined), description: (string|undefined), flags: number, name: string, precision: number, propertyHash: string}[])

    getPropertiesAsync(dbId, options)

    Gets the properties for an ID. Avoids loading of externalId table unless really needed.

    Parameters

    Expand all
    dbId*
    number
    The database identifier.
    options
    object
    needsExternalId
    boolean
    If true, we enforce loading of externalIDs if necessary. ExternalIds may significantly increase memory consumption and should only be loaded if unavoidable.
    * Required

    Returns

    typedescription
    Promise (GetPropertiesResult) Resolves with the properties of the object.

    getBulkPropertiesAsync(dbIds, options)

    Bulk property retrieval with property name filter.

    Parameters

    Expand all
    dbIds*
    Array.<number>
    array of object dbIds to return properties for.
    options
    object
    propFilter
    Array.<string>
    array of property names to retrieve values for. If empty, all properties are returned.
    categoryFilter
    Array.<string>
    array of category names to retrieve values for. If empty, all properties are returned.
    ignoreHidden
    boolean
    true to ignore hidden properties.
    needsExternalId
    boolean
    If true, it is ensured that externalId table is loaded before doing the property query.
    * Required

    Returns

    typedescription
    Promise (GetPropertiesResult[]) Resolves with the properties of each object.

    getPropertySetAsync(dbIds, options)

    Retrieves properties related to the specified dbIds. The resolved object contains the displayName and displayCategory separated by a ‘/’ as the key and all of the related properties as the entry’s value. The results can be used to create a new PropertySet instance.

    Parameters

    Expand all
    dbIds*
    Array.<number>
    array of object dbIds to return properties for.
    options
    Object
    propFilter
    Array.<string>
    array of property names to retrieve values for. If empty, all properties are returned.
    ignoreHidden
    boolean
    true to ignore hidden properties.
    needsExternalId
    boolean
    If true, it is ensured that externalId table is loaded before doing the property query.
    * Required

    Returns

    typedescription
    Promise (object) Resolves with the properties grouped by displayCategory/displayName.

    executeUserFunction(code, userData)

    Allows executing user supplied function code on the worker thread against the PropertyDatabase instance. The returned value from the supplied function will be used to resolve the returned Promise.

    Parameters

    code*
    function, string
    Function takes two arguments, the PropertyDatabase instance and userData.
    userData*
    A value that will get passed to the code function when run in the property worker context. it needs to be serializable.
    * Required

    Returns

    typedescription
    Promise
    • Resolves with the return value of user function.

    Examples

    function myCustomFunction(pdb, userData) {
           const dbId = 1;
           pdb.enumObjectProperties(dbId, function(propId, valueId) {
                 // do stuff
           });
           return 42 * userData; // userData will be 2 in this example
      }
      executeUserFunction(myCustomFunction, 2).then(function(result) {
           console.log(result); // result === 84 === 42 * 2
      })
    
    Show More

    You can also directly pass in a string, which must contain just the function definition.


    await executeUserFunction('function myCustomFunction(pdb, userData) { ... }');
    

    Note that the function must be fully self-contained, and free of any syntax that causes e.g. babel to change it using polyfills (e.g. decopomposition operators). Since the polyfills don’t exist in the worker, the function could fail depending on babeling.


    getLoadProgress()

    Estimated load progress in percent.

    Returns

    typedescription
    number in the range 0..100

    isLoadDone()

    Returns true if loading is finished (either with success or with error)

    Returns

    typedescription
    boolean