Request

Response

    Autodesk.Viewing

    ObjectTreeBuilder

    Transient builder for a static object-tree hierarchy. Accumulates nodes in plain JS maps, then ObjectTreeBuilder#build flattens them into an immutable ObjectTree.

    The resulting tree carries no instance membership. Node to instance lookup goes through InstanceCollection3D. See ObjectTree#enumNodeInstances.

    new ObjectTreeBuilder(rootId, rootName)

    Parameters

    rootId
    number
    dbId for the root node. Must be a non-zero int32.
    rootName
    string
    Display name for the root node.

    Methods

    getRootId()

    Returns

    typedescription
    number dbId of the root node.

    createNode(dbId, parentDbId, name, nodeType)

    Adds a node to the hierarchy.

    Parameters

    dbId
    number
    dbId for the new node. Auto-allocated when undefined.
    parentDbId*
    number
    dbId of an already-added parent node.
    name
    string
    nodeType
    * Required

    Returns

    typedescription
    number The dbId of the new node.

    removeNode(dbId, options)

    Removes a node from the hierarchy.

    Parameters

    Expand all
    dbId*
    number
    options
    object
    recursive
    boolean
    Required to remove a node that has children.
    * Required

    setNodeName(dbId, name)

    Sets the display name of a node.

    Parameters

    dbId*
    number
    name*
    string
    * Required

    setNodeType(dbId, nodeType)

    Sets the node type; only the low 3 type bits are affected.

    Parameters

    dbId*
    number
    nodeType*
    * Required

    setParent(dbId, newParentDbId)

    Reparents a node and its subtree. Cheap: this happens before the tree is frozen.

    Parameters

    dbId*
    number
    newParentDbId*
    number
    * Required

    fromObjectTree(tree)

    Seeds a builder from an existing ObjectTree, so a new tree can be derived from it. The source tree is not modified.

    Parameters

    tree*
    * Required

    Returns

    typedescription
    ObjectTreeBuilder

    build()

    Flattens the accumulated hierarchy into a packed, immutable ObjectTree.

    Returns

    typedescription
    ObjectTree