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.

277 lines 9.91 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 an aligned dimension entity in AutoCAD. * * An aligned dimension measures the distance between two points located anywhere in space. * The dimension's normal vector must be perpendicular to the line between the two points. * The two selected points are also used as the definition points for the start of the * two dimension extension lines. * * Aligned dimensions are commonly used to measure distances that are not parallel to * the X or Y axes, providing accurate measurements regardless of the orientation. * * @example * ```typescript * // Create an aligned dimension * const alignedDim = new AcDbAlignedDimension( * new AcGePoint3d(0, 0, 0), // First extension line point * new AcGePoint3d(10, 5, 0), // Second extension line point * new AcGePoint3d(5, 2.5, 0), // Dimension line point * "10.0", // Dimension text * "Standard" // Dimension style * ); * * // Access dimension properties * console.log(`Dimension line point: ${alignedDim.dimLinePoint}`); * console.log(`Extension line 1 point: ${alignedDim.xLine1Point}`); * console.log(`Extension line 2 point: ${alignedDim.xLine2Point}`); * ``` */ var AcDbAlignedDimension = /** @class */ (function (_super) { __extends(AcDbAlignedDimension, _super); /** * Creates a new aligned dimension entity. * * This constructor initializes an aligned dimension using the specified points. * The extension line obliquing angle is set to 0.0 by default. * * @param xLine1Point - Start point (in WCS coordinates) of first extension line * @param xLine2Point - Start point (in WCS coordinates) of second extension line * @param dimLinePoint - Point (in WCS coordinates) on dimension line itself * @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 an aligned dimension with default text and style * const alignedDim = new AcDbAlignedDimension( * new AcGePoint3d(0, 0, 0), * new AcGePoint3d(10, 5, 0), * new AcGePoint3d(5, 2.5, 0) * ); * * // Create an aligned dimension with custom text and style * const alignedDim2 = new AcDbAlignedDimension( * new AcGePoint3d(0, 0, 0), * new AcGePoint3d(15, 10, 0), * new AcGePoint3d(7.5, 5, 0), * "15.0", * "Architectural" * ); * ``` */ function AcDbAlignedDimension(xLine1Point, xLine2Point, dimLinePoint, dimText, dimStyle) { if (dimText === void 0) { dimText = null; } if (dimStyle === void 0) { dimStyle = null; } var _this = _super.call(this) || this; _this._dimLinePoint = new AcGePoint3d().copy(dimLinePoint); _this._xLine1Point = new AcGePoint3d().copy(xLine1Point); _this._xLine2Point = new AcGePoint3d().copy(xLine2Point); _this._oblique = 0; _this._rotation = 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(AcDbAlignedDimension.prototype, "dimLinePoint", { /** * Gets the definition point that specifies where the dimension line will be. * * This point will be somewhere on the dimension line and determines the position * of the dimension text and arrows. * * @returns The dimension line point in WCS coordinates * * @example * ```typescript * const dimLinePoint = alignedDim.dimLinePoint; * console.log(`Dimension line point: ${dimLinePoint.x}, ${dimLinePoint.y}, ${dimLinePoint.z}`); * ``` */ get: function () { return this._dimLinePoint; }, /** * Sets the definition point that specifies where the dimension line will be. * * @param value - The new dimension line point * * @example * ```typescript * alignedDim.dimLinePoint = new AcGePoint3d(5, 2.5, 0); * ``` */ set: function (value) { this._dimLinePoint.copy(value); }, enumerable: false, configurable: true }); Object.defineProperty(AcDbAlignedDimension.prototype, "xLine1Point", { /** * Gets the start point for the first extension line of the dimension. * * @returns The first extension line point in WCS coordinates * * @example * ```typescript * const xLine1Point = alignedDim.xLine1Point; * console.log(`Extension line 1 point: ${xLine1Point.x}, ${xLine1Point.y}, ${xLine1Point.z}`); * ``` */ get: function () { return this._xLine1Point; }, /** * Sets the start point for the first extension line of the dimension. * * @param value - The new first extension line point * * @example * ```typescript * alignedDim.xLine1Point = new AcGePoint3d(0, 0, 0); * ``` */ set: function (value) { this._xLine1Point.copy(value); }, enumerable: false, configurable: true }); Object.defineProperty(AcDbAlignedDimension.prototype, "xLine2Point", { /** * Gets the start point for the second extension line of the dimension. * * @returns The second extension line point in WCS coordinates * * @example * ```typescript * const xLine2Point = alignedDim.xLine2Point; * console.log(`Extension line 2 point: ${xLine2Point.x}, ${xLine2Point.y}, ${xLine2Point.z}`); * ``` */ get: function () { return this._xLine2Point; }, /** * Sets the start point for the second extension line of the dimension. * * @param value - The new second extension line point * * @example * ```typescript * alignedDim.xLine2Point = new AcGePoint3d(10, 5, 0); * ``` */ set: function (value) { this._xLine2Point.copy(value); }, enumerable: false, configurable: true }); Object.defineProperty(AcDbAlignedDimension.prototype, "rotation", { /** * Gets the dimension's rotation angle. * * @returns The rotation angle in radians * * @example * ```typescript * const rotation = alignedDim.rotation; * console.log(`Rotation: ${rotation} radians (${rotation * 180 / Math.PI} degrees)`); * ``` */ get: function () { return this._rotation; }, /** * Sets the dimension's rotation angle. * * @param value - The new rotation angle in radians * * @example * ```typescript * alignedDim.rotation = Math.PI / 4; // 45 degrees * ``` */ set: function (value) { this._rotation = value; }, enumerable: false, configurable: true }); Object.defineProperty(AcDbAlignedDimension.prototype, "oblique", { /** * Gets the extension line obliquing angle. * * @returns The obliquing angle in radians * * @example * ```typescript * const oblique = alignedDim.oblique; * console.log(`Oblique angle: ${oblique} radians`); * ``` */ get: function () { return this._oblique; }, /** * Sets the extension line obliquing angle. * * @param value - The new obliquing angle in radians * * @example * ```typescript * alignedDim.oblique = Math.PI / 6; // 30 degrees * ``` */ set: function (value) { this._oblique = value; }, enumerable: false, configurable: true }); Object.defineProperty(AcDbAlignedDimension.prototype, "geometricExtents", { /** * @inheritdoc */ get: function () { // TODO: Finish it return new AcGeBox3d(); }, enumerable: false, configurable: true }); Object.defineProperty(AcDbAlignedDimension.prototype, "isAppendArrow", { /** * @inheritdoc */ get: function () { return false; }, enumerable: false, configurable: true }); /** The entity type name */ AcDbAlignedDimension.typeName = 'AlignedDimension'; return AcDbAlignedDimension; }(AcDbDimension)); export { AcDbAlignedDimension }; //# sourceMappingURL=AcDbAlignedDimension.js.map