brepjs API Reference
    Preparing search index...

    Interface Drawing

    Immutable wrapper around a 2D shape (Blueprint, CompoundBlueprint, or Blueprints).

    A Drawing can be transformed (translate, rotate, scale, mirror), combined with Boolean operations (cut, fuse, intersect), filleted/chamfered, serialized, and ultimately projected onto a 3D plane via sketchOnPlane.

    const profile = drawRectangle(40, 20)
    .fillet(3)
    .cut(drawCircle(5).translate(10, 0));
    const sketch = profile.sketchOnPlane("XY");
    interface Drawing {
        get blueprint(): Blueprint;
        get boundingBox(): BoundingBox2d;
        get repr(): string;
        approximate(
            target: "svg" | "arcs",
            options?: ApproximationOptions,
        ): Drawing;
        chamfer(
            radius: number,
            filter?: (c: CornerFinderFn) => CornerFinderFn,
        ): Drawing;
        clone(): Drawing;
        cut(other: Drawing): Drawing;
        fillet(
            radius: number,
            filter?: (c: CornerFinderFn) => CornerFinderFn,
        ): Drawing;
        fuse(other: Drawing): Drawing;
        intersect(other: Drawing): Drawing;
        mirror(
            centerOrDirection: Point2D,
            origin?: Point2D,
            mode?: "plane" | "center",
        ): Drawing;
        offset(distance: number, offsetConfig?: Offset2DConfig): Drawing;
        punchHole(
            shape: AnyShape<Dimension>,
            faceFinder: SingleFace,
            options?: { draftAngle?: number; height?: number; origin?: PointInput },
        ): AnyShape<Dimension>;
        rotate(angle: number, center?: Point2D): Drawing;
        scale(scaleFactor: number, center?: Point2D): Drawing;
        serialize(): string;
        sketchOnFace(face: Face, scaleMode: ScaleMode): SketchInterface | Sketches;
        sketchOnPlane(inputPlane: Plane): SketchInterface | Sketches;
        sketchOnPlane(
            inputPlane?: PlaneName,
            origin?: number | PointInput,
        ): SketchInterface | Sketches;
        stretch(ratio: number, direction: Point2D, origin: Point2D): Drawing;
        toSVG(margin?: number): string;
        toSVGPaths(): string[] | string[][];
        toSVGViewBox(margin?: number): string;
        translate(xDist: number, yDist: number): Drawing;
        translate(translationVector: Point2D): Drawing;
    }
    Index

    Drawing Modifications

    Other

    • get repr(): string

      Return a human-readable string representation of the drawing.

      Returns string

    • Approximate the drawing curves for a target format (currently only 'svg').

      Parameters

      • target: "svg" | "arcs"
      • options: ApproximationOptions = {}

      Returns Drawing

    • Offset the drawing contour by a signed distance (positive = outward).

      Parameters

      • distance: number
      • offsetConfig: Offset2DConfig = {}

      Returns Drawing

    • Serialize the drawing to a JSON string for persistence or transfer.

      Returns string

    • Export the drawing as a complete SVG string.

      Parameters

      • Optionalmargin: number

      Returns string

    • Return the SVG <path> d attribute strings for this drawing.

      Returns string[] | string[][]

    • Return the SVG viewBox attribute string for this drawing.

      Parameters

      • margin: number = 1

      Returns string