UNPKG

@mlightcad/data-model

Version:

The data-model package provides the core classes for interacting with AutoCAD's database and entities. This package mimics AutoCAD ObjectARX's AcDb (Database) classes and implements the drawing database structure that AutoCAD developers are familiar with.

288 lines 10.2 kB
var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); import { AcGeBox3d, AcGePoint3d } from '@mlightcad/geometry-engine'; import { AcDbDimension } from './AcDbDimension'; /** * Represents a radial dimension entity in AutoCAD. * * A radial dimension measures the radius of a curve (typically a circle or arc). * This dimension type requires a center point and a point on the curve being dimensioned * in order to draw the dimension line from the center point through the point on the curve. * * The dimension utilizes a "leader length" value to determine how far the dimension line * extends out past the curve before doing a horizontal dogleg (if necessary) to the annotation text. * * @example * ```typescript * // Create a radial dimension * const radialDim = new AcDbRadialDimension( * new AcGePoint3d(0, 0, 0), // Center point * new AcGePoint3d(5, 0, 0), // Point on curve * 2.0, // Leader length * "5.0", // Dimension text * "Standard" // Dimension style * ); * * // Access dimension properties * console.log(`Center: ${radialDim.center}`); * console.log(`Chord point: ${radialDim.chordPoint}`); * console.log(`Leader length: ${radialDim.leaderLength}`); * ``` */ var AcDbRadialDimension = /** @class */ (function (_super) { __extends(AcDbRadialDimension, _super); /** * Creates a new radial dimension entity. * * This constructor initializes a radial dimension using the specified center point, * chord point, and leader length. The dimension line behavior depends on whether * the text is inside or outside the curve being dimensioned. * * - If the text is inside the curve, the dimension line is drawn from the center * to the chordPoint, with a break for the annotation text. * - If the text is outside the curve, the dimension line is drawn from the center, * through the chordPoint and out the leaderLength distance past the chordPoint * where it does a short horizontal dogleg (if appropriate) to the annotation text. * * @param center - Center point (in WCS coordinates) of curve being dimensioned * @param chordPoint - Point (in WCS coordinates) on the curve being dimensioned * @param leaderLength - Leader length distance * @param dimText - Text string to use as the dimension annotation (optional) * @param dimStyle - String name of dimension style table record to use (optional) * * @example * ```typescript * // Create a radial dimension with default text and style * const radialDim = new AcDbRadialDimension( * new AcGePoint3d(0, 0, 0), * new AcGePoint3d(5, 0, 0), * 2.0 * ); * * // Create a radial dimension with custom text and style * const radialDim2 = new AcDbRadialDimension( * new AcGePoint3d(10, 10, 0), * new AcGePoint3d(15, 10, 0), * 3.0, * "5.0", * "Architectural" * ); * ``` */ function AcDbRadialDimension(center, chordPoint, leaderLength, dimText, dimStyle) { if (dimText === void 0) { dimText = null; } if (dimStyle === void 0) { dimStyle = null; } var _this = _super.call(this) || this; _this._center = new AcGePoint3d().copy(center); _this._chordPoint = new AcGePoint3d().copy(chordPoint); _this._leaderLength = leaderLength; _this._extArcStartAngle = 0; _this._extArcEndAngle = 0; _this.dimensionText = dimText; // TODO: Set it to the current default dimStyle within the AutoCAD editor if dimStyle is null _this.dimensionStyleName = dimStyle; return _this; } Object.defineProperty(AcDbRadialDimension.prototype, "center", { /** * Gets the center point of the curve being dimensioned. * * This point is the primary definition point for this dimension type. * * @returns The center point in WCS coordinates * * @example * ```typescript * const center = radialDim.center; * console.log(`Center point: ${center.x}, ${center.y}, ${center.z}`); * ``` */ get: function () { return this._center; }, /** * Sets the center point of the curve being dimensioned. * * @param value - The new center point * * @example * ```typescript * radialDim.center = new AcGePoint3d(0, 0, 0); * ``` */ set: function (value) { this._center.copy(value); }, enumerable: false, configurable: true }); Object.defineProperty(AcDbRadialDimension.prototype, "chordPoint", { /** * Gets the point where the dimension line intersects the curve being dimensioned. * * @returns The chord point in WCS coordinates * * @example * ```typescript * const chordPoint = radialDim.chordPoint; * console.log(`Chord point: ${chordPoint.x}, ${chordPoint.y}, ${chordPoint.z}`); * ``` */ get: function () { return this._chordPoint; }, /** * Sets the point where the dimension line intersects the curve being dimensioned. * * @param value - The new chord point * * @example * ```typescript * radialDim.chordPoint = new AcGePoint3d(5, 0, 0); * ``` */ set: function (value) { this._chordPoint.copy(value); }, enumerable: false, configurable: true }); Object.defineProperty(AcDbRadialDimension.prototype, "extArcStartAngle", { /** * Gets the extension arc start angle. * * @returns The extension arc start angle in radians * * @example * ```typescript * const startAngle = radialDim.extArcStartAngle; * console.log(`Extension arc start angle: ${startAngle} radians`); * ``` */ get: function () { return this._extArcStartAngle; }, /** * Sets the extension arc start angle. * * @param value - The new extension arc start angle in radians * * @example * ```typescript * radialDim.extArcStartAngle = 0; * ``` */ set: function (value) { this._extArcStartAngle = value; }, enumerable: false, configurable: true }); Object.defineProperty(AcDbRadialDimension.prototype, "extArcEndAngle", { /** * Gets the extension arc end angle. * * @returns The extension arc end angle in radians * * @example * ```typescript * const endAngle = radialDim.extArcEndAngle; * console.log(`Extension arc end angle: ${endAngle} radians`); * ``` */ get: function () { return this._extArcEndAngle; }, /** * Sets the extension arc end angle. * * @param value - The new extension arc end angle in radians * * @example * ```typescript * radialDim.extArcEndAngle = Math.PI / 2; * ``` */ set: function (value) { this._extArcEndAngle = value; }, enumerable: false, configurable: true }); Object.defineProperty(AcDbRadialDimension.prototype, "leaderLength", { /** * Gets the leader length. * * The leader length is the distance from the chordPoint dimension definition point * out to where the dimension does a horizontal dogleg to the annotation text * (or stops if no dogleg is needed). * * @returns The leader length value * * @example * ```typescript * const leaderLength = radialDim.leaderLength; * console.log(`Leader length: ${leaderLength}`); * ``` */ get: function () { return this._leaderLength; }, enumerable: false, configurable: true }); Object.defineProperty(AcDbRadialDimension.prototype, "leaderLenght", { /** * Sets the leader length. * * @param value - The new leader length value * * @example * ```typescript * radialDim.leaderLength = 3.0; * ``` */ set: function (value) { this._leaderLength = value; }, enumerable: false, configurable: true }); Object.defineProperty(AcDbRadialDimension.prototype, "geometricExtents", { /** * @inheritdoc */ get: function () { // TODO: Finish it return new AcGeBox3d(); }, enumerable: false, configurable: true }); /** * @inheritdoc */ AcDbRadialDimension.prototype.getLineArrowStyle = function (_line) { return { secondArrow: this.secondArrowStyle }; }; /** The entity type name */ AcDbRadialDimension.typeName = 'RadialDimension'; return AcDbRadialDimension; }(AcDbDimension)); export { AcDbRadialDimension }; //# sourceMappingURL=AcDbRadialDimension.js.map