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, the whole hierarchy as a tree, and the dimensions and tolerances it carries. 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));
    • Reads the product manufacturing information a document holds: dimensions, geometric tolerances and the datums they refer to, each under its own label.

      Each entry names its shapes by label, which getShapeFromLabel reads, and in shapeRefs as the part and index manager.addDocumentPmi takes. Lengths are in the document's unit, angles in degrees; a document without any gives empty lists.

      Parameters

      Returns Promise<DocumentPmi>

      The dimensions, the tolerances and the datums, each with its label

      const pmi = await bitbybit.occt.assembly.query.getDocumentPmi({ document: doc });
      const measured = await bitbybit.occt.assembly.query.getShapeFromLabel({ document: doc, label: pmi.dimensions[0].shapes[0] });
    • Beta

      Reads the dimensions, tolerances and datums a document carries as a STEP AP242 file draws them, and the views the file saved.

      Each has its plane, its lines as polylines and its letters as loops to fill even-odd, in the document's axes and units or turned Y-up; a part placed twice shows its annotations twice. Experimental.

      Parameters

      Returns Promise<DocumentAnnotations>

      The annotations, the saved views and how many of each were left out

      const doc = await bitbybit.occt.assembly.manager.loadStepToDoc({ stepData });
      const pmi = await bitbybit.occt.assembly.query.getDocumentAnnotations({ document: doc, deflection: 0.05 });
      const drawn = await bitbybit.draw.drawAnyAsync({ entity: pmi });