@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.
98 lines • 3.68 kB
JavaScript
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 { AcDbBlockTableRecord } from './AcDbBlockTableRecord';
import { AcDbSymbolTable } from './AcDbSymbolTable';
/**
* Symbol table for block table records.
*
* This class manages block table records which represent block definitions
* within a drawing database. Blocks are reusable collections of entities
* that can be inserted multiple times into a drawing.
*
* @example
* ```typescript
* const blockTable = new AcDbBlockTable(database);
* const modelSpace = blockTable.modelSpace;
* const block = blockTable.getAt('MyBlock');
* ```
*/
var AcDbBlockTable = /** @class */ (function (_super) {
__extends(AcDbBlockTable, _super);
/**
* Creates a new AcDbBlockTable instance.
*
* @param db - The database this block table belongs to
*
* @example
* ```typescript
* const blockTable = new AcDbBlockTable(database);
* ```
*/
function AcDbBlockTable(db) {
return _super.call(this, db) || this;
}
Object.defineProperty(AcDbBlockTable.prototype, "modelSpace", {
/**
* Gets the MODEL_SPACE block table record.
*
* This method returns the model space block table record, creating it
* if it doesn't exist. Model space is the primary drawing area where
* most entities are created and stored.
*
* @returns The MODEL_SPACE block table record
*
* @example
* ```typescript
* const modelSpace = blockTable.modelSpace;
* const entities = modelSpace.entities;
* ```
*/
get: function () {
var modelSpace = this.getAt(AcDbBlockTableRecord.MODEL_SPACE_NAME);
if (!modelSpace) {
modelSpace = new AcDbBlockTableRecord();
modelSpace.name = AcDbBlockTableRecord.MODEL_SPACE_NAME;
this.add(modelSpace);
}
return modelSpace;
},
enumerable: false,
configurable: true
});
/**
* Normalizes the specified block table record name if it is one paper spacce or model space
* block table record.
*
* @override
* @param name - The name of the block table record.
* @returns The normalized block table record name.
*/
AcDbBlockTable.prototype.normalizeName = function (name) {
var regularizedName = name;
if (AcDbBlockTableRecord.isModelSapceName(name)) {
regularizedName = AcDbBlockTableRecord.MODEL_SPACE_NAME;
}
else if (AcDbBlockTableRecord.isPaperSapceName(name)) {
var prefix = AcDbBlockTableRecord.PAPER_SPACE_NAME_PREFIX;
var suffix = name.substring(prefix.length);
regularizedName = prefix + suffix;
}
return regularizedName;
};
return AcDbBlockTable;
}(AcDbSymbolTable));
export { AcDbBlockTable };
//# sourceMappingURL=AcDbBlockTable.js.map