Bitbybit Docs
    Preparing search index...

    Class JSCADPath

    Building JSCAD paths, the 2D polylines that walls are extruded along, offsets follow and filled shapes are closed from. A path lies in the XY plane and is open or closed; it grows by appending points, polylines and arcs to its end, and a closed path accepts nothing more. Points given in 3D keep only X and Y.

    Index

    Constructors

    append

    • Adds points to the end of an open 2D path, giving a longer copy.

      Only X and Y of each point are used and repeated consecutive points are removed; a closed path throws an error.

      Parameters

      Returns Promise<JSCADEntity>

      The extended 2D path

      const longer = await bitbybit.jscad.path.appendPoints({ path, points: [[20, 10], [20, 0]] });
      
    • Adds the points of a polyline to the end of an open 2D path, giving a longer copy.

      Only X and Y of each point are used and repeated consecutive points are removed; a closed path throws an error.

      Parameters

      Returns Promise<JSCADEntity>

      The extended 2D path

      const longer = await bitbybit.jscad.path.appendPolyline({ path, polyline: { points: [[20, 10, 0], [20, 0, 0]] } });
      
    • Adds an elliptical arc from the last point of an open 2D path to endPoint, giving a longer copy.

      radiusX and radiusY size the ellipse and xAxisRotation tilts it in degrees; clockwise and large pick one of the four arcs that fit, and radii too small to reach the end point are scaled up.

      Parameters

      • inputs: PathAppendArcDto

        The 2D path, the end point, the two radii, the tilt, the arc choice and the segment count

      Returns Promise<JSCADEntity>

      The extended 2D path

      const start = await bitbybit.jscad.path.createFromPoints({ points: [[0, 0]], closed: false });
      const arc = await bitbybit.jscad.path.appendArc({ path: start, endPoint: [10, 10], radiusX: 10, radiusY: 10, xAxisRotation: 0, clockwise: false, large: false, segments: 32 });

    create

    • Makes an empty open 2D path with no points, a starting point for appendPoints, appendPolyline and appendArc.

      Returns Promise<JSCADEntity>

      The empty 2D path

      const empty = await bitbybit.jscad.path.createEmpty();
      const path = await bitbybit.jscad.path.appendPoints({ path: empty, points: [[0, 0], [10, 0], [10, 10]] });

    edit

    • Closes an open 2D path by joining its last point back to its first, giving a closed copy; a path that is already closed comes back closed.

      A 2D shape or a solid throws an error.

      Parameters

      Returns Promise<JSCADEntity>

      The closed 2D path

      const closed = await bitbybit.jscad.path.close({ path });
      

    from

    • Builds a 2D path through the points in order, open or closed back to the first point as closed says.

      Only X and Y of each point are used and repeated consecutive points are removed.

      Parameters

      Returns Promise<JSCADEntity>

      The 2D path

      const path = await bitbybit.jscad.path.createFromPoints({ points: [[0, 0], [10, 0], [10, 10]], closed: false });
      
    • Builds one 2D path per list of points, in the same order; a list whose last point coincides with its first becomes a closed path, any other stays open.

      Only X and Y of each point are used and repeated consecutive points are removed.

      Parameters

      Returns Promise<JSCADEntity[]>

      One 2D path per list

      const paths = await bitbybit.jscad.path.createPathsFromPoints({ pointsLists: [[[0, 0], [10, 0], [10, 10], [0, 0]], [[20, 0], [30, 0]]] });
      
    • Builds a 2D path through the points of a polyline, open or closed back to the first point as closed says, whatever the polyline's own flag holds.

      Only X and Y of each point are used and repeated consecutive points are removed.

      Parameters

      Returns Promise<JSCADEntity>

      The 2D path

      const path = await bitbybit.jscad.path.createFromPolyline({ polyline: { points: [[0, 0, 0], [10, 0, 0], [10, 10, 0]] }, closed: true });