Bitbybit Docs
    Preparing search index...

    Class OCCTSVG

    Importing SVG drawings as OpenCascade shapes. The importer parses the document (paths, basic shapes, transforms, reused elements, nested viewports, units and the style cascade with CSS), 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 into one compound on the ground, ready to draw, extrude or transform.

      faceStrategy decides which closed outlines become faces; unit, scale and flipY map SVG units and its downward Y; alignment, direction, center and keepOrigin place it. A very large file is read up to its limits; loadSVGStructured lists what was left out.

      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 warnings, the view box and the page size in millimetres.

      Use it when the elements need their own colors or separate handling; loadSVG gives the whole drawing as one shape.

      Parameters

      • inputs: LoadSVGDto

        The SVG text and the import and placement options

      Returns Promise<SVGResult<TopoDSShapePointer>>

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

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