Table of Contents

Class DxfEntity

Namespace
GeometryHelper.Dxf
Assembly
GeometryHelper.dll

An entity of a DXF file, as AutoCAD's Entity is one of a drawing: what it is drawn on and with (its layer, colour, linetype, lineweight and whether it is shown), the block it is in, and its geometry as the library's shapes.

public abstract class DxfEntity : DxfDBObject
Inheritance
DxfEntity
Derived
Inherited Members

Remarks

Each type of entity is a class of its own, named as AutoCAD names its own with Dxf in front: a LINE is a DxfLine; a type the library has no class for is a DxfUnknownEntity, kept as the file has it. An entity of a DxfDatabase is changed by setting its properties: its record is written anew, every group the change is not about kept as it was, and a property given the value it has changes nothing.

An entity made in code, new DxfLine(start, end) { Layer = "steel", ColorIndex = 1 }, is added to a drawing by AppendEntity(DxfEntity), which gives it its handle and owner: the same object is the entity of the drawing from then on.

The look is as AutoCAD reads it: an entity with no colour is ColorIndex 256, BYLAYER; with no linetype, ByLayer; with no lineweight, ByLayer. Nothing is taken from a block: a LINE of a block on layer 0 is on layer 0.

Properties

BlockName

Gets the name of the block the entity is in, as AutoCAD's BlockName: *Model_Space for an entity of model space and *Paper_Space for one of paper space, whatever the file calls them; that of the entity it follows for a VERTEX or an ATTRIB; null where Owner is null.

Color

Gets or sets the colour of the entity, as AutoCAD's Color: its true colour (group 420, its book's name 430) where it has one, else its colour index (62), BYLAYER where it gives none. It agrees with ColorIndex and TrueColor, which read the same groups; a true colour carries the index nearest it, as FromRgb(byte, byte, byte) gives it: orange, 0xFF8000, the index 30, whatever index the record writes beside it.

ColorIndex

Gets or sets the colour of the entity (group 62), as AutoCAD's ColorIndex: 1 to 255 for a colour of AutoCAD's index, 0 for BYBLOCK and 256 for BYLAYER, which an entity that gives none has.

DxfName

Gets the type of the entity as the file names it in its group 0, as AutoCAD's class names its DxfName: LINE, LWPOLYLINE, INSERT, DIMENSION, ACAD_TABLE, REGION.

Ecs

Gets the system of the entity's own coordinates, as AutoCAD's Ecs: the one the arbitrary axis algorithm of the DXF reference makes of its extrusion (group 210), taking a point of it to the world; the world's own where the extrusion is (0, 0, 1) or the record gives none.

GeometricExtents

Gets the box the entity's shapes fill, as AutoCAD's GeometricExtents: the least and greatest x, y and z the shapes of GetGeometry() reach as DxfWriter writes them, its thickness not counted. An INSERT's are those of what it places; one whose block would place more than MaxPlacedEntities by its default, 2 000 000 entities, places nothing, as the reader leaves it, and so has no extents, as an INSERT of a block the drawing does not define has none. A class of a type the reader gives no shapes for gives its own, as a HATCH the box of its loops.

Hyperlinks

Gets the hyperlinks of the entity, as AutoCAD's Hyperlinks: those of its extended data of the application PE_URL, read and written as DxfHyperLinkCollection says.

IsPlanar

Gets whether the entity lies in one plane, as AutoCAD's IsPlanar: whether GetPlane() finds one, to Default. A line, and a polyline whose vertices run along one line, lie in one; a 3D polyline with a corner 0.002 off the plane of the others does not. A DxfSpline gives what its record says, the flag 8 of its group 70.

Layer

Gets or sets the layer the entity is on (group 8), as AutoCAD's Layer: the name as the layer table names it, the spaces around it taken off and its escapes (\U+00E9) read as letters; 0 where the record gives none.

LineWeight

Gets or sets the lineweight of the entity (group 370), as AutoCAD's LineWeight: LineWeight025 is a line 0.25 mm wide; ByLayer where the record gives none.

Linetype

Gets or sets the name of the linetype of the entity (group 6), as AutoCAD's Linetype: DASHED, ByBlock; ByLayer where the record gives none. The name is as the record spells it, the spaces around it taken off.

LinetypeScale

Gets or sets the scale of the entity's linetype (group 48), as AutoCAD's LinetypeScale: 2 draws its dashes twice as long; 1 where the record gives none.

Owner

Gets what owns the entity, as AutoCAD's OwnerId names it: the block it is in, ModelSpace for an entity of model space; for a record that follows an entity, as a VERTEX of a POLYLINE or an ATTRIB of an INSERT, that entity. Null for one made in code and not yet added, or erased.

Transparency

Gets or sets how much the entity lets show through it (group 440), as AutoCAD's Transparency: BYLAYER where the record gives none, BYBLOCK, or an alpha from 0, clear, to 255, solid, as DxfTransparency says.

TrueColor

Gets or sets the colour of the entity as red, green and blue (group 420), 0xRRGGBB, which a CAD program draws in place of ColorIndex: 0xFF8000 is orange; null where it has none.

Visible

Gets or sets whether the entity is drawn (group 60), as AutoCAD's Visible: false where the record writes it invisible, 1; true where it gives none.

Methods

BoundingBoxIntersectWith(DxfEntity, DxfIntersect)

Gets the points where the boxes of the entity and another meet, as AutoCAD's BoundingBoxIntersectWith: where an edge of the one box of GeometricExtents enters or leaves the other box, each way, to Default. Two flat boxes in one plane meet where their outlines cross: the box of the line from (0, 0, 0) to (10, 10, 0) and that of the line from (5, 5, 0) to (15, 15, 0) meet at (10, 5, 0) and (5, 10, 0). A box is never extended, whatever the type of intersection.

Clone()

Gets a copy of the entity as it is, as AutoCAD's Clone gives one of an object: an entity of the same class and look in no file, a DxfUnknownEntity among them, its records as the file has them but its handle, owner, space, reactors and extension dictionary; a VERTEX the vertex class it is, an ATTRIB an attribute. It is added to a drawing by AppendEntity(DxfEntity), as a copy from another drawing is: see that method for the pointers it carries.

Erase()

Erases the entity from its block, as AutoCAD's Erase does: every record of it goes, a POLYLINE's vertices and end and an INSERT's attributes with it, its handle is not given again, and what pointed at it is seen to when the file is saved: a GROUP no longer lists it, a list of reactors no longer holds it, and the objects it owned, such as its extension dictionary, go with it; any other pointer at it, as a table cell's at an attribute definition (331) or an XRECORD's data, stays where it stands, named in the log once. A record that follows an entity, a VERTEX of a POLYLINE or an ATTRIB of an INSERT, is taken out of it alone, every other record keeping its handle.

Explode()

Gets the entities the entity breaks into, as AutoCAD's Explode: new entities in no file. A DxfBlockReference gives the entities of its block placed where it puts them, a MINSERT those of every cell; a polyline its lines and arcs; a polyface and a polygon mesh a 3DFACE for each face; an MTEXT a TEXT for each line; a dimension and a table the entities of the block they are drawn with, placed; a LEADER its lines, or its spline, and its arrowhead; a MULTILEADER its words or block, its leader lines and arrows; an MLINE its lines and caps; a HATCH of a pattern the dashes of its pattern cut by its loops. Any other entity refuses, as AutoCAD answers eNotApplicable for one that does not break, a LINE or a CIRCLE; and so do a HATCH filled solid or with a gradient, a MESH, and a REGION, a 3DSOLID and a BODY, which AutoCAD breaks with its solid modeler, each saying why.

GetGeometry()

Gets the library's shapes for the entity, as DxfReader reads it with its default options: a GeoLine3 for a LINE, two GeoTriangle3 for a 3DFACE whose corners are not in one plane, the shapes of its block placed for an INSERT; none for a type the reader does not read, as a HATCH, or an entity with no shape to it, as a LINE of no length. A LEADER gives its curve, as the reader reads it and AutoCAD intersects a leader on it: a GeoPolyline3 through its vertices, a vertex on the one before it left out, so that the leader from (0, 0, 0) to (10, 5, 0) meets the line x = 5 at (5, 2.5, 0); splined, the GeoSpline3 of the spline Explode() fits through them; none where fewer than two of its vertices are apart. A MULTILEADER gives the lines of its leaders, as DxfMLeader says, and not its words or block. An IMAGE and a WIPEOUT, which the reader does not read, give the closed GeoPolyline3 of their GetVertices(), the frame of the image or its boundary where it is clipped; an OLE2FRAME the closed GeoPolyline3 of the four corners of its Position3d.

GetPlane()

Gets the plane the entity lies in, as AutoCAD's GetPlane: that of its extrusion through its first point where all of it lies in that, as a circle, an arc, a polyline or a text does; else the plane its shapes span, as a 3DFACE's or a SPLINE's. An entity along one line, as a LINE, lies in the plane through it whose normal is nearest its extrusion, the extrusion itself where the line runs across it; a point, in the plane of its extrusion. Points and planes are compared to Default. A class of a type the reader gives no shapes for gives its own, as a HATCH the plane of its extrusion.

GetTransformedCopy(GeoTransform3)

Gets a copy of the entity moved by a transformation, as AutoCAD's GetTransformedCopy does: an entity of the same class and look in no file, to be added to one by AppendEntity(DxfEntity).

IntersectWith(DxfEntity, DxfIntersect)

Gets the points where the entity and another meet, as AutoCAD's IntersectWith: worked out by the library's shapes for both (GetGeometry()), each pair of a shape of this entity and one of the other, to Default. As AutoCAD's, it meets curves and edges, not areas: a closed polyline, a SOLID, a 3DFACE and a mesh by the segments and arcs of their edges, so that the square of side 4 about the origin meets the line from (-10, 0, 0) to (10, 0, 0) at (-2, 0, 0) and (2, 0, 0), and the line through its middle up the z axis nowhere. A chain the library has no intersection of with a shape is taken segment by segment and arc by arc, and a POINT meets a shape where it lies on it. An entity that is to run on past its ends, as the type of intersection says, is taken as its line or circle where it is a LINE or an ARC; any other is taken as it is.

JoinEntities(IReadOnlyList<DxfEntity>)

Joins other curves into the entity, as AutoCAD's JoinEntities does, by the rules JoinEntity(DxfEntity) says: those that join, in one writing of the entity, and the others left out, each left as it is for the caller to erase. Pieces joined end to end are chained on from the entity's end, then back from its start, each time the one of lowest index of those that meet the end reached, so that the lines of a square given in any order close a polyline of one of them; 10 000 lines in any order are chained in time along their count. Lines join whatever their order. Arcs and elliptical arcs are taken in the order of their starts counter-clockwise from the entity's end, the lower index first at one angle, each run on from the entity as it stands then, so that their order does not change what they make: the quarter from 0 to pi / 2 given the arcs from 3 pi / 2 to 7 pi / 4 and from 7 pi / 4 round to pi / 8, in either order, runs to 7 pi / 4 and leaves out the second, which would make it whole.

JoinEntity(DxfEntity)

Joins another curve into the entity, as AutoCAD's JoinEntity does by the rules of its JOIN: the entity's record is written anew to run over both, its look and every group the joining is not about kept, and the other is left as it is, for the caller to erase. Ends meet within the point tolerance of Default, 0.001, measured in space.

SetDatabaseDefaults()

Gives the entity the look of the drawing it is in, as AutoCAD's SetDatabaseDefaults() gives one that of its database, as SetDatabaseDefaults(DxfDatabase) says. AutoCAD gives an entity in no database the look of the drawing open in its window; an entity made in code is in no drawing until it is appended, so it is refused.

SetDatabaseDefaults(DxfDatabase)

Gives the entity the look a drawing gives new entities, as AutoCAD's SetDatabaseDefaults: the layer ($CLAYER), colour ($CECOLOR), linetype ($CELTYPE) and, in a drawing of R2000 or later, linetype scale ($CELTSCALE) and lineweight ($CELWEIGHT) of its header and, in a drawing of R2004 or later, the transparency of Cetransparency: a drawing whose CETRANSPARENCY is the alpha 100 gives a line the alpha 100, and one whose CETRANSPARENCY is by layer leaves it by layer. An R2000 drawing has no transparency to give, and leaves the entity as it was.

SetPropertiesFrom(DxfEntity)

Gives the entity the look of another, as AutoCAD's SetPropertiesFrom does: its layer, colour, true colour and the name of its colour book, linetype, linetype scale, lineweight and whether it is drawn. Everything is checked before anything is written: a look this entity's file cannot hold changes nothing.

ToString()

Gives the entity as a line for debugging: its type, its handle and its layer.

TransformBy(GeoTransform3)

Moves, turns, scales or mirrors the entity by a transformation, as AutoCAD's TransformBy does: its record is written anew with the new geometry, its look kept, and its extended data moved with it in the same writing, as XDataTransformBy(GeoTransform3) moves it: a world position (1011) moved, a displacement (1012) and a direction (1013) turned, a distance (1041) and a scale factor (1042) scaled. An entity with none of those keeps its extended data's bytes. Each class moves its own geometry as its page says.