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.

122 lines 4.51 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 __()); }; })(); var __values = (this && this.__values) || function(o) { var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; if (m) return m.call(o); if (o && typeof o.length === "number") return { next: function () { if (o && i >= o.length) o = void 0; return { value: o && o[i++], done: !o }; } }; throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); }; var __read = (this && this.__read) || function (o, n) { var m = typeof Symbol === "function" && o[Symbol.iterator]; if (!m) return o; var i = m.call(o), r, ar = [], e; try { while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); } catch (error) { e = { error: error }; } finally { try { if (r && !r.done && (m = i["return"])) m.call(i); } finally { if (e) throw e.error; } } return ar; }; import { AcDbDictionary } from '../AcDbDictionary'; /** * Dictionary for storing and managing AcDbLayout objects. * * This class extends AcDbDictionary to provide specialized functionality * for managing layout objects, including searching by block table record ID * and tracking the maximum tab order. * * @example * ```typescript * const layoutDict = new AcDbLayoutDictionary(database); * const layout = layoutDict.getBtrIdAt('some-block-id'); * const maxOrder = layoutDict.maxTabOrder; * ``` */ var AcDbLayoutDictionary = /** @class */ (function (_super) { __extends(AcDbLayoutDictionary, _super); function AcDbLayoutDictionary() { return _super !== null && _super.apply(this, arguments) || this; } /** * Searches the dictionary for a layout associated with the specified block table record ID. * * @param id - The block table record ID to search for * @returns The layout associated with the block table record ID, or undefined if not found * * @example * ```typescript * const layout = layoutDict.getBtrIdAt('some-block-id'); * if (layout) { * console.log('Found layout:', layout.layoutName); * } * ``` */ AcDbLayoutDictionary.prototype.getBtrIdAt = function (id) { var e_1, _a; try { for (var _b = __values(this._recordsByName), _c = _b.next(); !_c.done; _c = _b.next()) { var _d = __read(_c.value, 2), _ = _d[0], layout = _d[1]; if (layout.blockTableRecordId == id) return layout; } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (_c && !_c.done && (_a = _b.return)) _a.call(_b); } finally { if (e_1) throw e_1.error; } } return undefined; }; Object.defineProperty(AcDbLayoutDictionary.prototype, "maxTabOrder", { /** * Gets the maximum tab order value of layouts in the layout dictionary. * * @returns The maximum tab order value, or -1 if no layouts exist * * @example * ```typescript * const maxOrder = layoutDict.maxTabOrder; * console.log('Maximum tab order:', maxOrder); * ``` */ get: function () { var maxValue = -1; this._recordsByName.forEach(function (layout) { if (layout.tabOrder > maxValue) { maxValue = layout.tabOrder; } }); return maxValue; }, enumerable: false, configurable: true }); return AcDbLayoutDictionary; }(AcDbDictionary)); export { AcDbLayoutDictionary }; //# sourceMappingURL=AcDbLayoutDictionary.js.map