Bitbybit Docs
    Preparing search index...

    Class OCCTAssemblyQuery

    Reading an assembly document: the parts and sub-assemblies it holds, the shape behind a label, a label's color, placement and details, and the whole hierarchy as a tree. Labels are the ids the document gives every part, instance and assembly, such as 0:1:1:1; getDocumentParts and getAssemblyHierarchy list them, the other methods take one. The document itself is not changed by any query.

    Index

    Constructors

    query

    • Lists every part and sub-assembly in a document with its label, name, type, color and how many times it is placed.

      The labels are what the other query methods and the label setters take.

      Parameters

      Returns Promise<DocumentPartInfo[]>

      One entry per part or assembly

      const parts = await bitbybit.occt.assembly.query.getDocumentParts({ document: doc });
      parts.forEach(part => console.log(part.name, part.type, part.label));
    • Reads the color assigned to a label of a document, as red, green, blue and alpha from 0 to 1, together with a flag saying whether the label has a color at all.

      Parameters

      Returns Promise<LabelColorInfo>

      The color with its hasColor flag

      const color = await bitbybit.occt.assembly.query.getLabelColor({ document: doc, label: "0:1:1:1" });
      if (color.hasColor) console.log(color.r, color.g, color.b);
    • Reads the placement of an instance label in a document as a column-major matrix plus its translation, rotation quaternion and uniform scale.

      A part label, as opposed to an instance, carries no placement of its own.

      Parameters

      Returns Promise<LabelTransformInfo>

      The matrix, the translation, the quaternion and the scale

      const placement = await bitbybit.occt.assembly.query.getLabelTransform({ document: doc, label: "0:1:1:1" });
      console.log(placement.translation);
    • Describes one label of a document: its name, its type and whether it is a simple shape, an assembly, a reference to another label or a component of one.

      Parameters

      Returns Promise<LabelInfo>

      The label's name, type and flags

      const info = await bitbybit.occt.assembly.query.getLabelInfo({ document: doc, label: "0:1:1:1" });
      console.log(info.name, info.isAssembly);
    • Reads the whole assembly tree of a document as a flat list of nodes with their parents, so it can be walked or shown as a tree.

      Each node carries its label, name, type and placement, in depth-first order, so children follow their parent. An unnamed instance is named after what it places, numbered when repeated; definitionName holds that name.

      Parameters

      Returns Promise<AssemblyHierarchyResult>

      The nodes of the tree with their count and the format version

      const tree = await bitbybit.occt.assembly.query.getAssemblyHierarchy({ document: doc });
      console.log(tree.totalNodes, tree.nodes.map(n => n.name));