Bitbybit Docs
    Preparing search index...

    Class OCCTSVG

    Importing SVG drawings as OpenCascade shapes. The importer parses the document (paths, basic shapes, transforms and the style cascade), reduces every element to the generic path vocabulary of path and builds wires, and faces where it can, laid on the ground plane and placed by the import options. loadSVG gives one compound for the whole drawing; loadSVGStructured gives one shape per element with its fill and stroke.

    Index

    Constructors

    io

    • Parses an SVG document and builds every drawable element into one compound shape on the ground plane, ready to draw, extrude or transform as a whole.

      faceStrategy decides whether closed outlines become faces, scale and flipY map SVG units and its downward Y axis, and alignment, direction and center place the result. Invisible elements are skipped unless asked for.

      Parameters

      • inputs: LoadSVGDto

        The SVG text and the import and placement options

      Returns Promise<TopoDSCompoundPointer>

      One compound holding every element

      const drawing = await bitbybit.occt.svg.loadSVG({
      svg: svgText,
      faceStrategy: Bit.Inputs.OCCT.svgFaceStrategyEnum.auto,
      makeRibbons: false,
      includeInvisible: false,
      joinSegments: true,
      tolerance: 1e-7,
      scale: 0.1,
      flipY: true,
      alignment: Bit.Inputs.Base.basicAlignmentEnum.midMid,
      direction: [0, 1, 0],
      center: [0, 0, 0],
      });
    • Parses an SVG document and builds one shape per drawable element, each bundled with its resolved fill, stroke and stroke width, plus the parse warnings and the SVG view box.

      Use it when the elements need their own colors or separate handling; loadSVG gives the whole drawing as one shape. Faces are built where the outline allows it.

      Parameters

      • inputs: LoadSVGDto

        The SVG text and the import and placement options

      Returns Promise<SVGResult<TopoDSShapePointer>>

      The shapes with their styles, the warnings and the view box

      const options = new Bit.Inputs.OCCT.LoadSVGDto();
      options.svg = svgText;
      options.scale = 0.1;
      const result = await bitbybit.occt.svg.loadSVGStructured(options);
      result.shapes.forEach(s => console.log(s.fill, s.stroke));