Request

Response

    Autodesk.Viewing

    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}[])

    getProperties(dbId, onSuccess, onError) (Deprecated)

    Deprecated. Use getPropertiesAsync instead. This avoids the need to load the externalID table unless explicitly needed. This variant always enforces loading when doing queries with empty filter.

    Gets the properties for an ID.

    Parameters

    dbId*
    number
    The database identifier.
    onSuccessCallback for when the properties are fetched.
    onErrorCallback for when the properties are not found or another error occurs.
    * Required

    getProperties2(dbId, onSuccess, onError, options) (Deprecated)

    Deprecated. Use getPropertiesAsync instead.

    Gets the properties for an ID. New version of getProperties() that avoids loading of externalId table unless really needed.

    Parameters

    Expand all
    dbId*
    number
    The database identifier.
    onSuccessCallback for when the properties are fetched.
    onErrorCallback for when the properties are not found or another error occurs.
    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

    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.

    getBulkProperties(dbIds, propFilter, onSuccess, onError, ignoreHidden) (Deprecated)

    Deprecated. use getBulkPropertiesAsync instead - which makes sure that externalId table is only loaded if really needed.

    Bulk property retrieval with property name filter.

    Parameters

    dbIds*
    Array.<number>
    array of object dbIds to return properties for.
    propFilter
    object
    array of property names to retrieve values for. If empty, all properties are returned.
    onSuccess*
    function
    Callback function for when results are ready.
    onError*
    function
    Callback function for when something went wrong.
    ignoreHidden
    boolean
    true to ignore hidden properties.
    * Required

    getBulkProperties2(dbIds, options, onSuccess, onError) (Deprecated)

    Deprecated. Use getBulkPropertiesAsync instead.

    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.
    onSuccess*
    function
    Callback function for when results are ready.
    onError*
    function
    Callback function for when something went wrong.
    * Required

    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.

    getPropertySet(dbIds, options, onSuccess, onError) (Deprecated)

    Deprecated. Use getPropertySetAsync instead.

    Retrieves properties related to the specified dbIds. The results object that is passed into the onSuccess callback 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.
    onSuccess*
    function
    Callback function for when results are ready.
    onError*
    function
    Callback function for when something went wrong.
    * Required

    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