UNPKG

@bitbybit-dev/base

Version:

Bit By Bit Developers Base CAD Library to Program Geometry

106 lines (105 loc) 3.65 kB
import { DxfGenerator } from "./dxf-generator"; export class Dxf { constructor() { this.dxfGenerator = new DxfGenerator(); } /** * Creates a line segment definition for DXF export (pass-through for validation). * Example: start=[0,0], end=[10,5] → DXF line segment from origin to [10,5] * @param inputs Line segment definition * @returns Line segment DTO * @group dxf * @shortname line segment * @drawable false */ lineSegment(inputs) { return inputs; } /** * Creates an arc segment definition for DXF export (curved path between two points). * Example: center=[5,5], radius=5, startAngle=0°, endAngle=90° → quarter circle arc * @param inputs Arc segment definition * @returns Arc segment DTO * @group dxf * @shortname arc segment * @drawable false */ arcSegment(inputs) { return inputs; } /** * Creates a circle segment definition for DXF export (closed circular path). * Example: center=[10,10], radius=5 → full circle with diameter 10 centered at [10,10] * @param inputs Circle segment definition * @returns Circle segment DTO * @group dxf * @shortname circle segment * @drawable false */ circleSegment(inputs) { return inputs; } /** * Creates a polyline segment definition for DXF export (connected line segments through points). * Example: points=[[0,0], [5,0], [5,5], [0,5]] → rectangular polyline path * @param inputs Polyline segment definition * @returns Polyline segment DTO * @group dxf * @shortname polyline segment * @drawable false */ polylineSegment(inputs) { return inputs; } /** * Creates a spline segment definition for DXF export (smooth curve through control points). * Example: controlPoints=[[0,0], [5,10], [10,0]] → smooth curved path through points * @param inputs Spline segment definition * @returns Spline segment DTO * @group dxf * @shortname spline segment * @drawable false */ splineSegment(inputs) { return inputs; } /** * Creates a path from multiple segments (combines lines, arcs, circles, polylines, splines). * Similar to OCCT wires - segments are connected to form a continuous or multi-part path. * Example: segments=[lineSegment, arcSegment, polylineSegment] → combined path entity * @param inputs Path definition with segments * @returns Path DTO * @group dxf * @shortname path * @drawable false */ path(inputs) { return inputs; } /** * Creates a paths part with layer and color assignment for DXF organization. * Groups multiple paths into a single layer with consistent styling. * Example: paths=[path1, path2], layer="Outlines", color=red → grouped geometry * @param inputs Paths part definition * @returns Paths part DTO * @group dxf * @shortname paths part * @drawable false */ pathsPart(inputs) { return inputs; } /** * Generates a complete DXF file from paths parts (exports 2D CAD drawing format). * Supports lines, arcs, circles, polylines, and splines organized in layered paths. * Example: model with 3 parts on different layers → valid DXF file string for CAD software * @param inputs DXF model definition * @returns DXF file content as string * @group dxf * @shortname dxf create * @drawable false */ dxfCreate(inputs) { return this.dxfGenerator.generateDxf(inputs); } }