Bitbybit Docs
    Bereite Suchindex vor...

    Klasse OCCTWIO

    Lesen und Schreiben von CAD-Dateien mit OCCT: alles, was io auf dem Kernel bietet, plus Lader, die eine STEP- oder IGES-Datei als File-Objekt oder als ihren Text nehmen und eine Form zurückgeben. Dateien sind per Konvention Z-oben, daher dreht adjustZtoY die geladene Form in das Y-oben dieser Bibliothek, sofern es nicht auf false gesetzt ist.

    Hierarchie (Zusammenfassung anzeigen)

    Index

    Konstruktoren

    Eigenschaften

    occWorkerManager: OCCTWorkerManager

    assembly

    • Converts a STEP file into a binary glTF (GLB), keeping the assembly tree as glTF nodes along with part names, colors, materials and placements.

      stepData is the file as text, ArrayBuffer or Uint8Array. The mesh settings say how finely curved surfaces are triangulated: meshPrecision is the deflection, meshAngle the angular deflection. Z-up becomes glTF's Y-up. Failure throws.

      Parameter

      Rückgabewert Promise<Uint8Array<ArrayBufferLike>>

      The GLB file as bytes

      const glb = await bitbybit.occt.io.convertStepToGltf({ stepData: stepText, meshPrecision: 0.005, meshAngle: 0.5, meshRelative: true, internalVerticesMode: false, controlSurfaceDeflection: false });
      
    • Converts a STEP file into a binary glTF (GLB) like convertStepToGltf, with every option exposed.

      The read flags choose what to take from the file (colors, names, materials, layers, properties), the mesh settings how finely to triangulate, the export settings how the glTF is written (merged faces, 16-bit indexes, naming, scale). Switch off what you do not need.

      Parameter

      Rückgabewert Promise<Uint8Array<ArrayBufferLike>>

      The GLB file as bytes

      const options = new Bit.Inputs.OCCT.ConvertStepToGltfAdvancedDto();
      options.stepData = stepText;
      options.readColors = true;
      options.readNames = true;
      options.meshDeflection = 0.005;
      options.mergeFaces = true;
      options.adjustZtoY = true;
      const glb = await bitbybit.occt.io.convertStepToGltfAdvanced(options);
    • Converts a STEP file into a binary glTF (GLB) like convertStepToGltf and compresses the geometry with Draco, which makes the file much smaller at the cost of a Draco-capable loader.

      The Draco settings set the compression level and how many bits positions, normals, texture coordinates and colors keep; fewer bits mean a smaller file and less precision.

      Parameter

      Rückgabewert Promise<Uint8Array<ArrayBufferLike>>

      The GLB file as bytes

      const options = new Bit.Inputs.OCCT.ConvertStepToGltfWithDracoDto();
      options.stepData = stepText;
      options.meshPrecision = 0.005;
      options.dracoCompressionLevel = 7;
      options.dracoQuantizePositionBits = 14;
      const glb = await bitbybit.occt.io.convertStepToGltfWithDraco(options);
    • Converts a STEP file into a binary glTF (GLB) with every reading, meshing and writing option exposed, as convertStepToGltfAdvanced does, and compresses the geometry with Draco.

      The Draco settings set the compression level and how many bits positions, normals, texture coordinates and colors keep; fewer bits mean a smaller file and less precision.

      Parameter

      Rückgabewert Promise<Uint8Array<ArrayBufferLike>>

      The GLB file as bytes

      const options = new Bit.Inputs.OCCT.ConvertStepToGltfAdvancedWithDracoDto();
      options.stepData = stepText;
      options.readColors = true;
      options.meshDeflection = 0.005;
      options.dracoCompressionLevel = 7;
      const glb = await bitbybit.occt.io.convertStepToGltfAdvancedWithDraco(options);
    • Reads the assembly structure of a STEP file without building geometry: every part and sub-assembly as a node with its id, name, whether it is an assembly, its visibility, its color and its placement matrix.

      The nodes come in depth-first order, so children follow their parent. A file that cannot be parsed reports its error in the result.

      Parameter

      Rückgabewert Promise<AssemblyJsonResult>

      The list of nodes, the format version and any error

      const tree = await bitbybit.occt.io.parseStepToJson({ stepData: stepText });
      console.log(tree.nodes.map(n => n.name));

    dxf

    • Turns the wires of a shape into DXF path records, the first step of a 2D DXF export.

      The shape must lie flat on the XZ ground plane, since DXF drawings are two-dimensional. The deflection settings say how closely curved edges are followed. Give the paths a layer with dxfPathsWithLayer and write the file with dxfCreate.

      Parameter

      Rückgabewert Promise<DxfPathDto[]>

      The DXF paths

      const paths = await bitbybit.occt.io.shapeToDxfPaths({
      shape: flatOutline,
      angularDeflection: 0.1,
      curvatureDeflection: 0.1,
      minimumOfPoints: 2,
      uTolerance: 1e-9,
      minimumLength: 1e-7,
      });
    • Puts DXF paths on a named layer with a color, making one part of a DXF drawing.

      A drawing may hold several parts, each with its own layer and color; dxfCreate writes them into one file.

      Parameter

      Rückgabewert Promise<DxfPathsPartDto>

      The paths as one layered part

      const part = await bitbybit.occt.io.dxfPathsWithLayer({ paths, layer: "cut", color: "#ff0000" });
      
    • Writes DXF parts into one DXF file and returns its text.

      colorFormat chooses AutoCAD's indexed colors or true color, acadVersion the DXF version: AC1009 is R12, the most widely readable, AC1015 is 2000. fileName and tryDownload matter only where a browser download can be started.

      Parameter

      • inputs: DxfPathsPartsListDto

        The layered parts, the color format, the DXF version and the download options

      Rückgabewert Promise<string>

      The DXF file as text

      const dxf = await bitbybit.occt.io.dxfCreate({
      pathsParts: [part],
      colorFormat: Bit.Inputs.OCCT.dxfColorFormatEnum.aci,
      acadVersion: Bit.Inputs.OCCT.dxfAcadVersionEnum.AC1009,
      fileName: "drawing.dxf",
      tryDownload: false,
      });

    io

    • Writes a shape as STEP, the standard exchange format for exact CAD geometry, and starts a browser download of the file.

      With adjustYtoZ true the shape is turned so this library's Y-up becomes STEP's Z-up; fromRightHanded skips the mirror that swap otherwise includes. fileName names the download and tryDownload false skips it. saveShapeSTEPAndReturn gives the file's text instead.

      Parameter

      Rückgabewert Promise<void>

      Nothing; the download starts when the file is ready

      await bitbybit.occt.io.saveShapeSTEP({ shape: box, fileName: "box.step", adjustYtoZ: true, tryDownload: true });
      
    • Writes a shape as STEP, the standard exchange format for exact CAD geometry, and returns the file's text.

      With adjustYtoZ true the shape is turned so this library's Y-up becomes STEP's Z-up; fromRightHanded skips the mirror that swap otherwise includes. fileName and tryDownload matter only where a browser download can be started.

      Parameter

      Rückgabewert Promise<string>

      The STEP file as text

      const step = await bitbybit.occt.io.saveShapeSTEPAndReturn({ shape: box, fileName: "box.step", adjustYtoZ: true, tryDownload: false });
      
    • Triangulates a shape, writes it as STL, the mesh format 3D printers read, and starts a browser download of the file.

      precision is the meshing tolerance in model units; smaller values follow curved surfaces more closely and make a bigger file. adjustYtoZ turns Y-up into Z-up. fileName names the download, tryDownload false skips it. saveShapeStlAndReturn gives the text instead.

      Parameter

      Rückgabewert Promise<void>

      Nothing; the download starts when the file is ready

      await bitbybit.occt.io.saveShapeStl({ shape: box, fileName: "box.stl", precision: 0.01, adjustYtoZ: true, tryDownload: true });
      
    • Triangulates a shape and writes it as STL, the mesh format 3D printers and slicers read, returning the file's text.

      precision is the meshing tolerance in model units; smaller values follow curved surfaces more closely and make a bigger file. adjustYtoZ turns the shape so Y-up becomes Z-up. fileName and tryDownload only matter where a download can start.

      Parameter

      Rückgabewert Promise<string>

      The STL file as text

      const stl = await bitbybit.occt.io.saveShapeStlAndReturn({ shape: box, fileName: "box.stl", precision: 0.01, adjustYtoZ: true, tryDownload: false });
      
    • Liest eine STEP- oder IGES-Datei, gegeben als File, in eine Form ein.

      Die Erweiterung der Datei entscheidet über die Art: .step, .stp sind STEP, .iges, .igs sind IGES. adjustZtoY verwandelt das Z-oben der Datei in Y-oben. Eine Datei, die nicht gelesen werden kann, ergibt undefined.

      Parameter

      Rückgabewert Promise<TopoDSShapePointer>

      Die geladene Form

      const file = await bitbybit.asset.getFile({ fileName: "part.step" });
      const shape = await bitbybit.occt.io.loadSTEPorIGES({ assetFile: file, adjustZtoY: true });
      await bitbybit.draw.drawAnyAsync({ entity: shape });
    • Liest eine STEP- oder IGES-Datei, gegeben als ihr Text, in eine Form ein; fileType sagt, in welchem der beiden Formate der Text vorliegt.

      adjustZtoY verwandelt das Z-oben der Datei in Y-oben. Text, der nicht gelesen werden kann, ergibt undefined.

      Parameter

      Rückgabewert Promise<TopoDSShapePointer>

      Die geladene Form

      const text = await bitbybit.asset.fetchText({ url: "https://example.com/models/part.step" });
      const shape = await bitbybit.occt.io.loadSTEPorIGESFromText({ text, fileType: Bit.Inputs.OCCT.fileTypeEnum.step, adjustZtoY: true });