Creates a new AcDbDatabase instance.
ReadonlyeventsEvents that can be triggered by the database.
These events allow applications to respond to various database operations such as entity modifications, layer changes, and progress updates.
Fired when an object in the dictionary is removed
Fired when an object is set to the dictionary
Fired when an entity is appended to the database
Fired when an entity is erased from the database
Fired when an entity is modified in the database
Fired when a layer is appended to the database
Fired when a layer is erased from the database
Fired when a layer is modified in the database
Fired when AcDbDatabase.read or AcDbDatabase.openUri fails
Fired during database opening operations to report progress
ReadonlytransactionManages transactions and undo/redo for this database.
The zero (0) base angle with respect to the current UCS in radians.
The direction of positive angles.
Gets the attributes object for this AcDbObject.
The AcCmObject instance containing all attributes
Angular unit display and entry format for the drawing (AutoCAD system variable AUNITS).
This does not change how angles are stored internally (radians in geometry); it controls how angles are formatted in the UI and how numeric angle input is interpreted, together with angbase (ANGBASE) and angdir (ANGDIR).
Integer code matching AcDbAngleUnits:
| Value | Meaning |
|---|---|
0 |
Decimal degrees ??e.g. 45.5 |
1 |
Degrees/minutes/seconds ??e.g. 45d30'15" |
2 |
Gradians ??e.g. 50g (400 grads = full circle) |
3 |
Radians ??e.g. 0.785398... |
4 |
Surveyor's units ??quadrant bearing notation (e.g. N 45d30'15" E) |
Prefer assigning AcDbAngleUnits enum members for readability instead of raw integers.
Sets AUNITS ??the angular unit display format (see aunits getter for value meanings).
Integer 0??4per {@link AcDbAngleUnits}, orundefined/nullcoerced to0` by the setter chain.
Angular display precision for the drawing (AUPREC): how many decimal places (or equivalent) are used when showing angles, in conjunction with aunits.
AutoCAD typically uses integers in the range 0??; behavior for other values is implementation-defined in this library (stored as-is).
Sets AUPREC ??angular display precision (see auprec getter).
The line type scaling for new objects relative to the ltscale setting. A line created with celtscale = 2 in a drawing with ltscale set to 0.5 would appear the same as a line created with celtscale = 1 in a drawing with ltscale = 1.
The linetype of new objects as they are created.
The layer of new objects as they are created.
The transparency level of new objects as they are created.
Can be ByLayer, ByBlock, or a value from 0 to 90 (percentage).
Gets or sets class definitions from the drawing (DXF CLASSES / DWG class table).
Proxy entities resolve their application class ID (group code 91) against this list (IDs start at 500 for the first entry).
The layer of new objects as they are created.
The multileader style name used for newly created MLEADER entities.
The multiline scale used for newly created MLINE entities.
The multiline style name used for newly created MLINE entities.
Whether hatch objects are included in drawing comparison (COMPAREHATCH).
0: Hatch objects are excluded (AutoCAD default)1: Hatch objects are includedOffset between a change-set boundary and the revision cloud (COMPARERCMARGIN). AutoCAD range is 1–25; default is 5.
Whether text objects are included in drawing comparison (COMPARETEXT).
0: Text objects are excluded1: Text objects are included (AutoCAD default)Decimal-place geometric tolerance used when comparing two drawings (COMPARETOLERANCE). AutoCAD range is 0–14; default is 6.
Gets the object ID of the AcDbBlockTableRecord of the current space.
The current space can be either model space or paper space.
The object ID of the current space
Sets the current space by object ID.
The object ID of the block table record to set as current space
Gets the database in which this object is resident.
When an object isn't added to a database, this property returns the current working database. After it is added to a database, it will be set automatically. You should never set this value manually.
The database this object belongs to
Sets the database for this object.
This is typically set automatically when the object is added to a database. Manual setting should be avoided unless you know what you're doing.
The database to associate with this object
The dimension style name for new dimension objects ($DIMSTYLE).
Display tessellation side count for a full circle.
Configured via AcDbOpenDatabaseOptions.circleSides when the database is opened. Defaults to ACDB_DRAW_CIRCLE_SIDES_DRAFT.
Whether entities on non-plottable layers should be drawn.
Configured via AcDbOpenDatabaseOptions.drawNoPlotLayers when the
database is opened. Defaults to true.
Name of the current drawing file (DWGNAME), including extension.
Read-only through the system-variable API; updated when a drawing is opened or via setDwgName after save.
Gets the objectId of the extension dictionary owned by this object.
If the object does not have an extension dictionary, this returns undefined.
In ObjectARX terms, this is equivalent to AcDbObject::extensionDictionary().
The extension dictionary objectId, or undefined
Sets the objectId of the extension dictionary owned by this object.
This does not create or delete the dictionary object itself ??it only establishes or clears the ownership relationship.
Passing undefined removes the association.
The extension dictionary objectId, or undefined
The current Model Space EXTMAX value
The current Model Space EXTMIN value
Formatter for linear distances, point coordinates, and angles using this database's LUNITS, AUNITS, and related system variables.
The default layer used for newly created hatches and fills.
The default transparency string used for newly created hatches and fills.
Gets the drawing-units value for automatic scaling of blocks, images, or xrefs.
This is the current INSUNITS value for the database.
The insertion units value
Sets the drawing-units value for automatic scaling.
The new insertion units value
Returns true if this object is temporary and not yet committed to the database.
A temporary object is identified by its objectId starting with the TEMP prefix.
The most recent failure from read or openUri, or null after a successful open.
Useful when a caller catches no exception (for example a viewer that returns false)
but still needs to distinguish worker out-of-memory from other parse failures.
Gets the Layer Properties Manager filter tree for this database.
The current AcLyLayerFilterTree.
Mirrors AutoCAD .NET Database.LayerFilters / ObjectARX AcLy* filters.
This is the property/group filter tree, not the flat
objects.layerFilter dictionary used by AcDbLayerFilter /
AcDbLayerIndex.
Like AutoCAD, treat this value as retrieved by value: mutate the tree, then assign it back via the setter if your workflow expects that pattern.
Sets the Layer Properties Manager filter tree for this database.
New filter tree.
Gets the line type scale factor.
The line type scale factor
Sets the line type scale factor.
The new line type scale factor
Linear unit display and entry format for coordinates and lengths (LUNITS).
This does not set real-world drawing units for inserts (see insunits); it controls how linear distances are shown and parsed (scientific, decimal, engineering, and so on).
Integer code matching AcDbLinearUnits:
| Value | Meaning |
|---|---|
1 |
Scientific |
2 |
Decimal |
3 |
Engineering (feet + decimal inches) |
4 |
Architectural (feet + fractional inches) |
5 |
Fractional |
6 |
Windows desktop (processing / computational format) |
Prefer assigning AcDbLinearUnits enum members instead of raw integers.
Sets LUNITS ??linear display format (see lunits getter).
Integer per AcDbLinearUnits, or coerced default AcDbLinearUnits.Decimal when undefined/null.
Linear display precision for the drawing (LUPREC): number of decimal places (or equivalent) used when showing linear distances, together with lunits.
AutoCAD typically uses integers in the range 0??; initial value is commonly 4. Values outside that range are stored as-is by this library.
Sets LUPREC ??linear display precision (see luprec getter).
Gets the flag whether to display line weight.
The flag whether to display line weight.
Legacy drawing measurement system (MEASUREMENT): 0 = English, 1 = metric.
When INSUNITS is unitless, this selects the default real-world unit family for labels.
Gets the object ID.
AutoCAD uses 64-bit integers to represent handles, which exceed the maximum integer value of JavaScript. Therefore, strings are used to represent object handles.
The object ID as a string
Sets the object ID.
The new object ID
Gets all nongraphical objects in this drawing database.
Object containing all nongraphical objects in the database
Orthogonal mode flag (ORTHOMODE). When on, cursor movement is constrained to horizontal or vertical relative to the current UCS.
Running Object Snap (OSNAP) mode bitmask.
Gets the object ID of the owner of this object.
The owner object ID
Sets the object ID of the owner of this object.
The new owner object ID
Point display mode. Please get more details on value of this property from this page.
Point display size.
0: Specifies an absolute size
PSLTSCALE: paper space linetype scaling.
Gets all tables in this drawing database.
Object containing all the symbol tables in the database
The text style name for new text objects.
Gets or sets the drawing thumbnail preview image.
Corresponds to AutoCAD .NET Database.ThumbnailBitmap, DXF
THUMBNAILIMAGE section (group codes 90/310), and the DWG file preview.
Stored as raw image bytes (typically BMP/DIB or PNG).
Thumbnail image bytes, or undefined when none exist.
TILEMODE: true = model space (1), false = paper space (0).
Controls how feet-inch and fractional linear values are delimited (UNITMODE).
0: Report format (for example 1'-3 1/2")1: Input format (for example 1'-3-1/2", fewer spaces)Gets the version of the database.
The version of the database
Sets the version of the database.
The version value of the database
ProtectedassignAssociates this object with a database. Subclasses may override database
and call this helper to avoid super setter restrictions.
Begins suppressing database events until endEventBatch is called.
Create default layer, line type, dimension type, text style and layout.
Creates the extension dictionary for this object if it does not already exist.
This method closely mirrors the behavior of
AcDbObject::createExtensionDictionary() in ObjectARX.
The objectId of the extension dictionary
Reads this object from a DXF filer (ObjectARX dxfIn).
Reads common handle/owner fields, then delegates to dxfInFields. XData (group 1001+) is consumed when present after object fields.
Group-102 control strings ({ACAD_XDICTIONARY, {ACAD_REACTORS, …) are
consumed here so subclass readers still see handle/owner/subclass markers
that follow them. Many real DXF writers emit these blocks on LAYER and
entity records; skipping them would leave name/layer unset.
ProtecteddxfConsumes a DXF group-102 control-string block that was already opened
(the opening 102 value is startValue, typically {ACAD_XDICTIONARY
or {ACAD_REACTORS).
For {ACAD_XDICTIONARY, the first soft-owner handle (360) is stored as
extensionDictionary. Other control strings are skipped until the
matching closing 102 / }.
Reads object-specific DXF fields (ObjectARX dxfInFields).
Subclasses should override, call super.dxfInFields(filer) first when
appropriate, then consume their subclass marker and fields in an
order-independent loop.
Per the AutoCAD DXF specification, readers must ignore undefined group
codes and must not assume field order. Within a subclass loop the
correct unknown-code behavior is break (skip and continue). Use
pushBackItem only to hand a group-100 subclass marker (or XData) to
another reader — never to abort on an unrecognized optional code.
ProtecteddxfConsume XData pairs starting at group 1001 until end of object.
Exports the current database into DXF (ASCII string or binary bytes).
The fileName parameter is kept for ObjectARX API parity. In this web
implementation the method returns the DXF payload instead of writing the
filesystem directly.
Optional_fileName: stringKept for ObjectARX parity. Ignored in this implementation.
Numeric precision used by the DXF filer.
Target DXF/DWG version name or value.
Legacy boolean thumbnail flag, or options with
saveThumbnailImage and format: 'ascii' | 'binary'.
ASCII DXF string, or Uint8Array when format is 'binary'.
Writes DXF fields for this object.
The instance (for chaining).
ProtecteddxfEmit all attached XData buffers (DXF groups 1000–1071).
Ends the outermost event batch, flushing entityAppended notifications in
chunks so converters can report ENTITY progress while the viewer adds/renders.
Nested batches still require matching endEventBatch / endEventBatchChunked calls; only the outermost close flushes.
Max entities per entityAppended dispatch
OptionalonChunk: (flushed: number, total: number) => void | Promise<void>Called after each chunk with (flushed, total)
Gets the value of the specified attribute.
This method will throw an exception if the specified attribute doesn't exist. Use getAttrWithoutException() if you want to handle missing attributes gracefully.
The name of the attribute to retrieve
The value of the specified attribute
Gets the value of the specified attribute without throwing an exception.
This method returns undefined if the specified attribute doesn't exist, making it safer for optional attributes.
The name of the attribute to retrieve
The value of the specified attribute, or undefined if it doesn't exist
Looks up a database-resident object by its object ID.
Uses the global handle registry maintained by registerObjectHandle.
Object identifier to resolve
Reserved for erased-object support
The matching object, or undefined if not found
Returns the top-level named object dictionaries owned by this database.
Retrieves the XData associated with this object for a given application ID.
Extended Entity Data (XData) allows applications to attach arbitrary, application-specific data to an AcDbObject. Each XData entry is identified by a registered application name (AppId) and stored as an AcDbResultBuffer.
This method is conceptually equivalent to AcDbObject::xData() in ObjectARX,
but simplified to return the entire result buffer for the specified AppId.
The application ID (registered AppId name) that owns the XData
The AcDbResultBuffer associated with the AppId, or undefined
if no XData exists for that AppId
Initializes generateHandle from a DXF/DWG $HANDSEED value.
$HANDSEED is the next handle AutoCAD would assign; internal _maxHandle
is kept one below that value.
Hexadecimal handle seed from the drawing header
Returns whether entities on the given layer should be drawn under the current drawNoPlotLayers setting.
Layer off/freeze visibility is handled separately by the viewer; this only reflects the no-plot policy.
Returns true when the transaction manager is actively recording changes.
Shortcut for AcDbDatabaseTransactionManager.isRecording.
Dispatches or queues a dictionary-object-erased notification.
Object removed from a named dictionary
Dictionary key that previously referenced the object
Dispatches or queues a dictionary-object-set notification.
Object inserted or replaced in a named dictionary
Dictionary key under which the object is stored
Dispatches or queues an entity-appended notification.
One entity or batch of entities added to model/paper space
Dispatches or queues an entity-erased notification.
One entity or batch of entities removed from model/paper space
Opens an entity for read through the active transaction when present.
Editor shortcut; see openObject.
Opens an entity for write through the active transaction when present.
Editor shortcut; see openObject.
Opens a database object for read through the active transaction when present.
Editor shortcut; see openObject.
Opens a database object for write through the active transaction when present.
Editor shortcut; see openObject.
Read AutoCAD DXF or DWG drawing specified by the URL into the database object. The method automatically detects the file type based on the URL extension:
Input the URL linked to one AutoCAD DXF or DWG file
Input options to read drawing data
Reads drawing data from a string or ArrayBuffer.
This method parses the provided data and populates the database with the resulting entities, tables, and objects. The method supports both DXF and DWG file formats.
The drawing data as a string or ArrayBuffer
Options for reading the database
The type of file being read (defaults to DXF)
Removes the XData associated with the specified application ID.
After removal, calls to getXData() for the same AppId will return undefined.
If no XData exists for the given AppId, this method has no effect.
This mirrors the behavior of clearing XData for a specific application in ObjectARX rather than removing all XData from the object.
The application ID whose XData should be removed
Restores internal state from a detached clone while preserving identity fields.
Clone produced by clone or clonePreservingIdentity.
Runs a database mutation as one undoable operation.
Editor shortcut: skips creating a new undo mark when the transaction manager
is already recording (nested editor operations). Otherwise wraps fn in
AcDbDatabaseTransactionManager.runUndoable.
Sets the value of an attribute.
The name of the attribute to set
Optionalval: AcDbObjectAttrs[A]The value to assign to the attribute
Attaches or replaces XData for this object.
If XData already exists for the given AppId, it is replaced by the provided AcDbResultBuffer. The caller is responsible for ensuring that:
This method is conceptually similar to AcDbObject::setXData() in ObjectARX.
The result buffer containing the XData to attach
The AcDbDatabase class represents an AutoCAD drawing file.
Each AcDbDatabase object contains the various header variables, symbol tables, table records, entities, and objects that make up the drawing. The AcDbDatabase class has member functions to allow access to all the symbol tables, to read and write to DWG files, to get or set database defaults, to execute various database-level operations, and to get or set all header variables.
Example