Creates a new empty polyline entity.
This constructor initializes an empty polyline with no vertices. Vertices can be added using the addVertexAt method.
The area enclosed by this curve. Returns 0 when the curve does not form a
closed region.
Gets the attributes object for this AcDbObject.
The AcCmObject instance containing all attributes
Gets whether this polyline is closed.
A closed polyline has a segment drawn from the last vertex to the first vertex, forming a complete loop.
True if the polyline is closed, false otherwise
Sets whether this polyline is closed.
True to close the polyline, false to open it
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
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
Gets the elevation of this polyline.
The elevation is the distance of the polyline's plane from the WCS origin along the Z-axis.
The elevation value
Sets the elevation of this polyline.
The new elevation value
End parameter: the number of segments (closing segment included).
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
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
Extrusion direction / plane normal (DXF group 210).
Gets the number of vertices in this polyline.
The number of vertices
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 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
Returns the full property definition for this polyline entity, including general group and geometry group.
The geometry group exposes properties via AcDbPropertyAccessor so the property palette can update the polyline in real-time.
Each property is an AcDbEntityRuntimeProperty.
Start parameter (0). The parameter of a polyline is
vertexIndex + fraction, where the fraction is measured along the arc
length (bulge arcs: angle fraction) of that segment.
Thickness along the entity normal (DXF group 39).
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
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
Adds a vertex to this polyline at the specified index.
This method inserts a vertex at the specified position. If the index is 0, the vertex becomes the first vertex. If the index equals the number of vertices, the vertex becomes the last vertex. Otherwise, the vertex is inserted before the specified index.
The index (0-based) before which to insert the vertex
The vertex location point
The bulge value for the vertex (0 for straight line, >0 for arc)
The starting width for the vertex (-1 for default)
The ending width for the vertex (-1 for default)
ProtectedapplyPaints traits with a color taken from a style (DIMCLRD, MLEADER style
colors) instead of this entity's own color.
worldDraw records on the traits whether the entity color was ByLayer. A substituted color carries its own provenance: leaving the entity's flag in place makes renderers treat an explicit style color as layer-bound and repaint it with the layer color.
Renderer traits to update.
Color to draw with.
Whether color follows the layer. Defaults to
color.isByLayer; pass true for a layer color already resolved to a
concrete value.
A callback restoring the previous color and provenance.
ProtectedassignAssociates this object with a database. Subclasses may override database
and call this helper to avoid super setter restrictions.
Adds the layer and linetype this entity references.
Dependency collector.
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
Clones this object for AcDbDatabase.deepCloneObjects.
Mirrors AcDbObject::deepClone() in ObjectARX. The returned object is a
detached copy with a temporary id; the caller appends it to its owner,
which assigns the real handle. The pair this.objectId -> clone.objectId
is recorded in idMap, and is updated by the clone engine once the clone
has a committed handle.
The clone does not share this object's extension dictionary: AutoCAD would clone it too, but extension dictionaries are not cloned yet, so the clone simply drops it instead of pointing into the source database.
Subclasses that own other objects override this to clone them as well.
The object that will own the clone, if known.
Id mapping of the current clone operation.
True when this object was explicitly asked to be cloned.
The detached clone.
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 this LWPOLYLINE as a legacy R12 POLYLINE + VERTEX + SEQEND sequence.
Used when the target DXF version does not support LWPOLYLINE.
ProtecteddxfWrites the extension-dictionary pointer; see AcDbDxfFiler.writeExtensionDictionary.
Writes DXF fields for this object.
DXF output writer.
The instance (for chaining).
ProtecteddxfWrites the 102 {ACAD_REACTORS group. AutoCAD puts it before the
extension dictionary group. Only reactors that are OBJECTS-section
records of the current export are written, so no handle dangles.
ProtecteddxfEmit all attached XData buffers (DXF groups 1000–1071).
Breaks this entity into a set of simpler entities, mirroring ObjectARX
AcDbEntity::explode().
The returned entities are new, non-database-resident objects expressed in WCS. This entity is not modified: as in ObjectARX, it is up to the caller (for example the EXPLODE command) to append the returned entities to a block table record and to erase the original entity.
An empty array means the entity cannot be exploded (ObjectARX returns
Acad::eNotApplicable in that case), e.g. lines, arcs, circles, single
line text, MINSERT block references or blocks whose definition disallows
exploding.
This method is non-virtual: subclasses customize the behavior by overriding subExplode.
The entities this entity breaks into, or an empty array when it cannot be exploded.
Extends the start or end of the curve in place to a point, like
ObjectARX AcDbCurve::extend(Adesk::Boolean, const AcGePoint3d&).
The point must lie on the natural extension of the curve beyond that end (within tolerance); otherwise false is returned and the curve is left unchanged.
True to extend the start, false to extend the end
Target point in WCS
True when the curve was modified
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
Gets the bulge of the segment starting at the vertex with the specified
index, mirroring ObjectARX AcDbPolyline::getBulgeAt().
The bulge is tan(θ / 4) where θ is the included angle of the arc
segment; 0 means a straight segment and a negative value a clockwise
arc.
The index (0-based) of the vertex
The bulge value, or 0 when the index is out of range
Returns the point on the curve closest to point, like ObjectARX
AcDbCurve::getClosestPointTo.
Query point in WCS
When true, the natural extension of the curve (infinite line, full circle, full ellipse, open polyline end segments) is considered as well
The closest point in WCS, or undefined when unsupported
Returns the curve length from startParam to param, like
ObjectARX AcDbCurve::getDistAtParam. Rays and xlines measure the signed
distance from their base point. Parameters on the natural extension of
analytic curves give a signed (possibly negative) distance.
Curve parameter
The distance, or undefined when unsupported
ProtectedgetReturns the first derivative (tangent) at param, like ObjectARX
AcDbCurve::getFirstDeriv. Default uses a finite difference.
Returns the first derivative at a distance from startParam.
ProtectedgetCreates 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.
Returns ids of objects hard-owned by this object through a pointer other
than a dictionary entry or the extension dictionary (DXF group 360), e.g.
the action body and dependencies of an AcDbAssocAction.
DXF export follows these ids so owned objects are written with their owner. Defaults to none.
ProtectedgetCreates offset curves at the given signed distance, similar to ObjectARX
AcDbCurve::getOffsetCurves.
The sign of offsetDist determines the offset side relative to the curve
direction in the curve plane. Returns an empty array when offsetting fails.
Signed offset distance in drawing units
Offset curve entities (equivalent to AcDbVoidPtrArray)
Determines which side of this curve a point lies on for offset operations.
Test point in WCS
1 for the positive offset side, -1 for the negative side
Returns the parameter at a distance measured from startParam, like
ObjectARX AcDbCurve::getParamAtDist.
Default implementation binary-searches getDistAtParam over
[startParam, endParam].
Returns the parameter of a point on the polyline. For open polylines a
point on the natural extension of the first segment (param < 0) or the
last segment (param > endParam) is accepted as well.
Gets the 2D location of a vertex at the specified index.
The point is returned in the polyline's own object coordinate system (OCS).
The index (0-based) of the vertex
The 2D point location of the vertex
Gets the 3D location of a vertex at the specified index.
The point is returned in World Coordinates, with the Z-coordinate set to the polyline's elevation.
The index (0-based) of the vertex
The 3D point location of the vertex
Returns the point at a distance measured from startParam, like
ObjectARX AcDbCurve::getPointAtDist.
Returns the point at a parameter, like ObjectARX
AcDbCurve::getPointAtParam. Parameters returned by
getParamAtPoint for points on the natural extension are accepted
as well.
Curve parameter
The point in WCS, or undefined when unsupported
Splits into AcDbPolyline pieces. Bulges of partial arc segments and start / end widths at the cut points are recomputed; elevation, normal and thickness are kept.
Splits the curve at the given points, like ObjectARX
AcDbCurve::getSplitCurves(const AcGePoint3dArray&, ...).
Each point is mapped through getParamAtPoint; points that are not on the curve are ignored. See getSplitCurves for the rules.
Split points in WCS
The pieces, or an empty array when nothing is split
Returns a new entity that is a clone of this entity transformed by
matrix, mirroring ObjectARX AcDbEntity::getTransformedCopy().
The default implementation clones this entity and calls
transformBy on the clone. Subclasses that need database-context
during the transform (for example TEXT/MIRRTEXT) may override this.
Transformation matrix to apply to the copy.
A non-database-resident transformed copy.
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
Imported XData stays compact until the first call for that AppId. The call materializes an AcDbResultBuffer and keeps it, so later reads and in-place edits use that buffer. DXF output order does not change. Avoid calling this while importing when the compact form should be retained.
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
Iterates the XData of one application without materializing it.
Behaves like getXData for readers, but never converts the compact imported form into an AcDbResultBuffer. Use this on hot paths that only read XData (for example drawing dimension-style overrides), so a drawing keeps its lossless compact representation and pays no per-entity allocation. Use getXData when the returned values may be edited.
The application ID (registered AppId name) that owns the XData
The typed values of that AppId, or an empty iterable when absent
Joins others into a new entity with this as the primary, mirroring
ObjectARX AcDbEntity::joinEntities().
Same contract as joinEntity: returns a new entity and does not mutate or erase inputs. Subclasses that support batch rules (gapped collinear lines, concentric arcs, polyline chains) override subJoinEntities.
Secondary entities to join with this primary.
The joined entity, or undefined when join is not applicable.
Joins other into a new entity with this as the primary, mirroring
ObjectARX AcDbEntity::joinEntity().
The returned entity is a new, non-database-resident object. This entity and
other are not modified: the caller (for example the JOIN command) must
append the result and erase the sources.
Returns undefined when the two entities cannot be joined (ObjectARX
Acad::eNotApplicable), e.g. closed curves, non-collinear lines, or
unsupported types.
This method is non-virtual: subclasses customize behavior by overriding subJoinEntity.
Secondary entity to join with this primary.
The joined entity, or undefined when join is not applicable.
ProtectednotifyXDataProtectedonCalled when this object is re-associated with a different database.
Subclasses that cache database-derived state (for example a dimension style resolved from the style table) override this to drop that cache.
The database that this object now belongs to.
ProtectedonXDataCalled whenever XData for an AppId changes.
Subclasses that cache values derived from XData (for example the effective
dimension style assembled from ACAD/DSTYLE) override this to drop the
stale cache instead of re-parsing the stream on every read.
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
This function resets the polyline by optionally retaining some vertices. If reuse is true, the numVerts number of vertices are left intact and all vertices beyond that number are deleted. If reuse is false, numVerts is ignored and all existing vertex information will be deleted.
Input Boolean indicating whether or not to retain some vertices
OptionalnumVerts: numberInput number of vertices to retain (only used when reuse is true)
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
ProtectedsetLossless parser/import fast path.
Each 1001 group starts an AppId. That AppId stays in the compact list
until getXData, setXData, or removeXData touches it. Replacing an
AppId keeps its DXF position; a new AppId is appended.
getXData materializes that AppId into an AcDbResultBuffer and keeps
the buffer afterwards, so later reads observe in-place edits. Calling it
during import gives up the compact representation for that AppId.
Sets the 2D location of a vertex at the specified index in OCS,
mirroring ObjectARX AcDbPolyline::setPointAt().
The index (0-based) of the vertex
The new vertex location in the polyline OCS
Copies the general entity properties of source to this entity, mirroring
ObjectARX AcDbEntity::setPropertiesFrom().
The copied properties are layer, color, linetype, linetype scale, lineweight, transparency and visibility. Unset (lazily resolved) values stay unset so that database defaults still apply when this entity is appended to a database.
Entity whose properties are copied.
This entity.
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
ProtectedshouldProtectedsubExplodes this polyline into one AcDbLine or AcDbArc per segment, like AutoCAD EXPLODE.
The generated entities keep the elevation, normal, thickness and general properties of the polyline. Segment widths are discarded, as in AutoCAD. A polyline with fewer than two vertices cannot be exploded.
Gets the grip points for this polyline.
Grip points are control points that can be used to modify the polyline.
For a polyline, the grip points are all the vertices. When the GRIPS
system variable is 2, midpoint grips are also returned for each segment.
Array of grip points (vertices, then optional segment midpoints)
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 polyline.
Object snap points are precise points that can be used for positioning when drawing or editing. This method provides snap points based on the specified snap mode.
The object snap mode
The last point
Array to populate with snap points
Stretch points are vertices only (AutoCAD excludes segment midpoint grips).
ProtectedsubJoins contiguous lines, arcs, and open polylines in others into one
LWPOLYLINE.
ProtectedsubJoins a contiguous line, arc, or open polyline at a shared endpoint into one LWPOLYLINE, like AutoCAD JOIN with a polyline as the source object.
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
Moves the selected polyline vertices by the given offset.
Draws this polyline using the specified renderer.
This method renders the polyline as a series of connected line segments using the polyline's current style properties.
The renderer to use for drawing
The rendered polyline entity, or undefined if drawing failed
Transforms this polyline by the specified matrix.
The lightweight polyline stores 2D vertices plus a shared elevation, so we transform each vertex in 3D and then write the projected XY values back.
Translates the layer and linetype names of a cloned entity.
Id mapping of the current clone operation.
Clones this object for AcDbDatabase.wblockCloneObjects.
Mirrors AcDbObject::wblockClone() in ObjectARX. The default
implementation is the same as deepClone; the difference between
the two operations (cross-database record handling) lives in the clone
engine.
The object that will own the clone, if known.
Id mapping of the current clone operation.
True when this object was explicitly asked to be cloned.
The detached clone.
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
Staticfrom2dConstructs a temporary AcDbPolyline from a planar vertex list.
Other curve types use this factory when they need polyline offset or side-test behavior without persisting an intermediate entity in the database. Vertices are added in list order with zero bulge; arc segments are not represented.
2D vertices in WCS (XY), at least one point
Whether the path forms a closed loop for offset and side tests
A new lightweight polyline with the given topology
StaticfromCreates a polyline entity from AcGePolyline2d geometry.
Source polyline geometry
Polyline entity with matching vertices and closed flag
Represents a polyline entity in AutoCAD.
A polyline is a complex geometric object composed of connected line segments and/or arc segments. Polylines can have:
Polylines are commonly used for creating complex shapes, paths, and boundaries in drawings.
Example