Creates a new AcDbViewport instance.
Initializes all properties with default values:
Ambient light color index (DXF group 63).
Ambient light color (true color, DXF group 421).
Ambient light color name (DXF group 431).
Gets the attributes object for this AcDbObject.
The AcCmObject instance containing all attributes
Back clip plane Z value (DXF group 44).
Background soft-pointer ID (DXF group 332).
Gets or sets the center point of the viewport entity in WCS coordinates (within Paper Space).
This point represents the geometric center of the viewport's rectangular boundary in paper space coordinates, not the center of the model space view within the viewport.
The center point of the viewport entity
Circle zoom percent (DXF group 72).
Clipping boundary hard-pointer ID (DXF group 340).
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
Default lighting type (DXF group 282).
Gets the DXF entity type name written to the file.
This value is the literal DXF record type emitted for the entity during
DXF export, such as LINE, INSERT, or DIMENSION.
Every concrete entity class must explicitly define this property so the DXF export contract stays local to the entity implementation rather than being inferred by the base class.
The DXF entity type name used during export
Elevation (DXF group 146).
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
Front clip plane Z value (DXF group 43).
Frozen layer soft-pointer IDs (DXF group 331).
Grid spacing (DXF group 15).
Gets or sets the height of the viewport entity's window in drawing units.
This represents the height of the viewport's rectangular boundary in paper space, measured in the current drawing units. It defines the vertical extent of the viewport border, not the height of the model space view within it.
The height of the viewport entity in drawing units
UCSICON display flag (DXF group 74).
Whether default lighting is on (DXF group 292).
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.
Gets the name of the layer referenced by this entity.
The layer name
Sets the name of the layer for this entity.
The new layer name
Gets the line style for this entity.
This method returns the line style based on the entity's linetype and other properties.
The line style object
Gets the name of the line type referenced by this entity.
The linetype name
Sets the name of the line type for this entity.
The new linetype name
Gets the line type scale factor of this entity.
When an entity is first instantiated, its line type scale is initialized to an invalid value. When the entity is added to the database, if a linetype scale has not been specified for the entity, it is set to the database's current line type scale value.
The linetype scale factor
Sets the line type scale factor for this entity.
The new linetype scale factor
Gets the line weight used by this entity.
The line weight value
Sets the line weight for this entity.
The new line weight value
Major grid-line frequency (DXF group 61).
Gets or sets the viewport ID number.
This is the number that is reported by the AutoCAD CVPORT system variable when the viewport is the current viewport in the AutoCAD editor. If the viewport is inactive, -1 is returned.
Important notes:
The viewport ID number
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
Orthographic type of UCS (DXF group 79).
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
Perspective lens length (DXF group 42).
Returns the full property definition for this entity, including all property groups and runtime accessors.
This getter is used by the property inspector UI to:
The returned structure contains:
Note: The groups array contains AcDbEntityPropertyGroup objects whose
properties entries are runtime-resolved property descriptors that include
AcDbPropertyAccessor objects. Each property object therefore
conforms to AcDbEntityRuntimeProperty.
Render mode (DXF group 281).
Shade plot soft-pointer ID (DXF group 333).
Shade plot mode (DXF group 170).
Paper space sheet name (DXF group 1).
Snap angle in radians (DXF group 50).
Snap base point (DXF group 13).
Snap spacing (DXF group 14).
Soft-pointer IDs from groups 91 / 335 / 343 / 344.
Viewport status field (DXF group 68).
Status bit flags (DXF group 90).
Sun soft-pointer ID (DXF group 361).
Gets the transparency level of this entity.
The transparency value.
Sets the transparency level of this entity.
The transparency value.
Gets the type name of this entity.
This method returns the entity type by removing the "AcDb" prefix from the constructor name.
The entity type name
UCS base soft-pointer ID (DXF group 346).
UCS soft-pointer ID (DXF group 345).
UCS origin (DXF group 110).
UCS per-viewport flag (DXF group 71).
UCS X axis (DXF group 111).
UCS Y axis (DXF group 112).
Gets or sets the view center in display coordinate system coordinates.
This point represents the center of the model space view that is displayed within the viewport. It is specified in the display coordinate system and determines what portion of the model space drawing is visible in the viewport.
The center point of the model space view within the viewport
View direction from target (DXF group 16).
Gets or sets the height of the Model Space view within the viewport.
This value represents the height of the model space view that is displayed within the viewport, specified in display coordinate system coordinates.
Zoom behavior:
The height of the model space view in display coordinates
Brightness (DXF group 141).
Contrast (DXF group 142).
Gets or sets the view target in WCS coordinates (DXF group 17).
The model view center stored in viewCenter is in DCS; the WCS
center shown through the viewport is viewTarget + rotate(viewCenter, viewTwistAngle).
Gets or sets the view twist angle in radians (DXF group 51).
Gets whether this entity is visible.
True if the entity is visible, false otherwise
Sets whether this entity is visible.
True to make the entity visible, false to hide it
Visual style soft-pointer ID (DXF group 348).
Gets or sets the width of the viewport entity's window in drawing units.
This represents the width of the viewport's rectangular boundary in paper space, measured in the current drawing units. It defines the horizontal extent of the viewport border, not the width of the model space view within the viewport.
Note: This is the width in Paper Space of the viewport itself, not the width of the Model Space view within the viewport.
The width of the viewport entity in drawing units
ProtectedassignAssociates this object with a database. Subclasses may override database
and call this helper to avoid super setter restrictions.
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 AcDbEntity common fields until the next subclass marker or object end.
ProtecteddxfConsume XData pairs starting at group 1001 until end of object.
Writes DXF fields for this object.
DXF output writer.
The instance (for chaining).
ProtecteddxfEmit all attached XData buffers (DXF groups 1000–1071).
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
ProtectedgetProtectedgetCreates the "General" property group for this entity.
This group contains common metadata attributes shared by all CAD entities (e.g., handle, layer). Each property includes a runtime AcDbPropertyAccessor allowing the property inspector to read and update live values.
Subclasses may override this method to append additional general-purpose properties while still preserving this base set.
A fully resolved property group containing runtime-accessible properties.
ProtectedgetRetrieves 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
ProtectedhasProtectedhasProtectedhasFinds intersection points between this entity and another entity.
This method mirrors ObjectARX AcDbEntity::intersectWith. Intersection
points are returned in WCS. The optional projPlane argument corresponds
to the ObjectARX overload that intersects the projections of both
entities onto a plane (apparent intersection). gsMarker subentity
filtering is not implemented.
Subclasses should override subGetIntersectCurves instead of this method.
The other entity
Whether to extend this entity, the other entity, both, or neither
OptionalprojPlane: AcGePlaneOptional projection plane for apparent intersection
Intersection points in WCS; empty when the entities do not intersect
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
Resolves the effective properties of this entity.
This method determines the final, usable values for entity properties such as layer, linetype, lineweight, color, and other display-related attributes. If a property is not explicitly set on the entity (for example, it is undefined or specified as ByLayer / ByBlock), the value is resolved according to the current AutoCAD system variables and drawing context.
Typical system variables involved in the resolution process include, but are not limited to:
CLAYER – Current layerCELTYPE – Current linetypeCELWEIGHT – Current lineweightCECOLOR – Current colorThe resolution follows AutoCAD semantics:
This method does not change user-defined property settings; it only computes and applies the final effective values used for display, selection, and downstream processing.
ProtectedresolveRestores internal state from a detached clone while preserving identity fields.
Clone produced by clone or clonePreservingIdentity.
Sets the value of an attribute.
The name of the attribute to set
Optionalval: AcDbObjectAttrs[A]The value to assign to the attribute
ProtectedsetAttaches 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
ProtectedshouldGets the grip points for this viewport.
Grip points are the center point and the four corners of the viewport boundary in paper space, matching AutoCAD viewport grip behavior.
Array of grip points as 3D points
Returns the WCS curve primitives used by intersectWith.
Default implementation returns [] (no intersections). Subclasses with
drawable curve geometry override this; callers should use intersectWith.
Entities without curve primitives (text, points, attributes) keep this
empty default, matching ObjectARX.
Gets the object snap points for this entity.
Object snap points are the points that can be used for precise positioning when drawing or editing. This method should be overridden by subclasses to provide entity-specific snap points.
The object snap mode
The pick point
The last point
Array to populate with snap points
OptionalgsMark: anyThe object id of subentity. For now, it is used by INSERT entity only. In AutoCAD, it uses AcGiSubEntityTraits::setSelectionMarkerInput to set GS marker of the subentity involved in the object snap operation. For now, we don't provide such a GS marker mechanism yet. So passed id of subentity as GS marker. Maybe this behavior will change in the future.
OptionalinsertionMat: AcGeMatrix3dCumulative insertion transform matrix from nested block references. This parameter is primarily used by INSERT entities.
Moves the grip points at the specified indices by the given offset.
This method should be overridden by subclasses to provide entity-specific
grip editing behavior, matching AutoCAD AcDbEntity::subMoveGripPointsAt.
Zero-based indexes into the array returned by subGetGripPoints
WCS translation offset applied to the selected grips
This entity after the grip edit
Renders the viewport entity using the specified renderer.
The viewport is drawn as a rectangular border when the following conditions are met:
In paper space layouts, there is always a system-defined "default" viewport that exists as the bottom-most item. This viewport doesn't show any entities and is mainly for internal AutoCAD purposes. The viewport ID number of this system-defined "default" viewport is 1.
The renderer to use for drawing the viewport
A render group containing the viewport border lines, or undefined if not drawn
Converts this AcDbViewport to an AcGiViewport for rendering purposes.
This method creates a graphic interface viewport object that contains all the necessary properties for rendering the viewport in the graphics system.
An AcGiViewport instance with all viewport properties copied
Transforms this viewport entity by the specified matrix.
Called by cad application when it wants the entity to draw itself in WCS (World Coordinate System) and acts as a wrapper / dispatcher around subWorldDraw(). The children class should never overidde this method.
It executes the following logic:
The renderer to use for drawing
Optionaldelay: booleanThe flag to delay creating one rendered entity and just create one dummy entity. Renderer can delay heavy calculation operation to avoid blocking UI when this flag is true. For now, text and mtext entity supports this flag only. Other types of entities just ignore this flag.
The rendered entity, or undefined if drawing failed
Represents a viewport entity in AutoCAD drawings.
A viewport is a rectangular window that displays a portion of the drawing model space within paper space layouts. Viewports allow users to create multiple views of the same drawing at different scales and orientations on a single sheet.
Key characteristics:
Example