Table of Contents

Method AppendEntity

Namespace
GeometryHelper.Dxf
Assembly
GeometryHelper.dll

AppendEntity(DxfEntity)

Appends an entity made in code to the block, as AutoCAD's AppendEntity: written at the end of the ENTITIES section for model space and paper space, before the block's ENDBLK for a block, in the file's own style. The same object is the entity of the block from then on, with its handle and its owner.

public void AppendEntity(DxfEntity entity)

Parameters

entity DxfEntity

The entity, made in code and in no file yet.

Remarks

Its handle is the next above every handle of the file and above $HANDSEED less one, $HANDSEED set above it, and its owner the block's BLOCK_RECORD from R13 on; an entity of paper space, or of the block of another layout of it (*Paper_Space0 and on), is written with its group 67 of 1, as AutoCAD and ezdxf write it. A file whose records have no handles, as many writers leave them, gives it none. Its layer is added to the layer table where the table does not list it, and the applications of its extended data to the table of applications. The extents of the header grow to hold an entity of model or paper space.

A file of R12 has no SPLINE, ELLIPSE, RAY, XLINE nor LWPOLYLINE, which are refused, nor lineweights or true colours. Nor has it MTEXT: an MTEXT is written there as one TEXT for each paragraph (\P, a column break \N taken as one), its formatting and the heights of its codes left out, not wrapped at its width, which AutoCAD's SAVEAS to R12 wraps by the letters of the font, which the library does not read; and so is each MTEXT of a block copied there with an entity of another drawing, a dimension's *D among them. Each TEXT is in the MTEXT's text style where the drawing has it or is given it by name with the copy, else in Standard; a line of more than 255 letters is written whole, not split, a length older readers of R12 may not take. The TEXTs are appended in the MTEXT's place, and the MTEXT stays in no file: an MTEXT of two lines, 2.5 high and held at its top left at (10, 20), comes out as two TEXTs on the baselines 17.5 and 13.33 high. An entity of R13 or later is written in it in the forms of R12, as AutoCAD saves a drawing as R12: each record keeps the groups R12 has for its type, each read from the part of the record it belongs to (a centred ATTRIB's 72 from its AcDbText, not the 72 its AcDbAttribute writes again), its markers, owner and an object embedded after a group 101 left out; a type with no form of R12 the library writes, as a HATCH, is refused. An entity of R12 in a file of R13 or later is given AutoCAD's subclass markers in their order.

An entity copied from another drawing (Clone(), GetTransformedCopy(GeoTransform3)) has its pointers taken to this drawing as AutoCAD's deep clone between databases takes them: a material, plot style or visual style to the one of the same dictionary and entry names, a record of a table to the one of its name; a pointer to an object this drawing has no namesake of is left out, so that its default holds, but the IMAGEDEF of an IMAGE, which comes with it under its name in the dictionary of images (ACAD_IMAGE_DICT, made where this drawing has none), one IMAGEDEF brought for all the images that show it, as AutoCAD 2021's WblockCloneObjects brings it, with the CLASS rows of IMAGE and IMAGEDEF, or of WIPEOUT, where the drawing lists none, each counted 1, and a row of them counted 0 counted 1, without which AutoCAD 2021 ignores them; an IMAGE that AssociateRasterDef(DxfRasterImageDef) gave an IMAGEDEF of this drawing shows that one, given an IMAGEDEF_REACTOR of its own, nothing brought for it; and a handle of extended data (1005) is left out, as AutoCAD's mapping leaves it null, but for the records the overrides of a dimension style name (ACAD DSTYLE), which name those of the same name here. The records of the tables a copy names that this drawing has not (its layers, linetypes, text styles and dimension styles, and their arrow blocks) are copied with it by name, and a block AutoCAD names itself it draws by (a dimension's *D, an INSERT's *U) under a name of its own, as AutoCAD's deep clone does: one no INSERT, dimension or table of this drawing gives of a block it has not, so that a DIMENSION here naming a *D1 the drawing has not does not come to draw by the copy, which comes as *D2; an INSERT's named block where this drawing has none of its name, under that name, with the blocks it inserts, as AutoCAD's WblockCloneObjects brings it, and every block a copy points to by a hard pointer so too (a MULTILEADER's block and arrow blocks, the block of an ACAD_TABLE's cell), as AutoCAD's deep clone follows its pointers to them. What the entities of the blocks copied point to among themselves (a LEADER to its MTEXT, a HATCH to its boundary) is kept between their copies, whichever comes first in its block, as AutoCAD's deep clone translates its map of ids once every object is copied, and so is every pointer to a block copied with it after its own (a MULTILEADER's block and arrow blocks, an ACAD_TABLE's picture and the blocks of its cells, the arrow block an override of a dimension style names). A copy appended to its own drawing keeps its pointers, but for the value a MULTILEADER gives an attribute definition erased since, which is left out with the definition's handle. A copy of an annotative entity appended is given the contexts it carries, and its ATTRIBs theirs, each under an extension dictionary as AutoCAD writes its copy's (check D35c). Appended to another drawing, each context is put on the scale of its scale's name there, as AutoCAD 2021's WblockCloneObjects and Insert put it: one of the same units taken as it is, one the drawing's list has not added to it, and one of the name of other units added as the name and _1 (or _2 and on, the first the list has not): a context of S7 of 1:3 copied into a drawing whose S7 is 1:7 stands on an S7_1 of 1:3 added for it (check D35d). A drawing that holds no list of scales, older than R2007, takes the copy without them, given the placing it is read at. The extents of the header are not grown by what is appended to a block.

A drawing of an older version than the entity's is given what it can hold, as AutoCAD's SAVEAS to that version gives it: the overrides of a dimension style (ACAD DSTYLE) of a variable the version has not are left out, as DIMLTYPE of R2007 on a dimension added to a drawing of R2000, and so are the groups the version has not of the records of the tables copied by name with it, as a DIMSTYLE's DIMFXLEN (49) and a LAYER's material (347). A table's block cell keeps the values it gives the attributes of a block that comes with it, its pointers (331) naming the copies of their definitions; a LEADER whose annotation does not come with it points to none. An INSERT in a block brought that names a block its drawing has not, as a drawing read from a file may hold, is copied as it is, naming it, and said in one Debug line of GeometryHelperLog: the other drawing's M holding INSERTs of Z and K, which it has not, an INSERT of M copied in says that two INSERTs name a block their drawing has not, K and Z. WblockCloneObjects(IEnumerable<DxfEntity>, DxfBlockTableRecord) copies entities together, what points from one to another kept.

Exceptions

ArgumentNullException

Thrown when the entity is null.

ArgumentException

Thrown when the file's version cannot hold the entity's type or look, or its linetype is not in the file's linetype table; or when it is an INSERT that would make this block insert itself at any depth; or when it is a copy of another drawing's entity whose blocks would, once brought, insert themselves or this block, an INSERT here of a block this drawing has not placing the one brought of that name: an INSERT, or a dimension whose *D holds an INSERT that closes such a round. Nothing is written then.

InvalidOperationException

Thrown when the entity is in a file already, or this block is not; or it is a DxfWipeout made in code and given no polygon by SetFrom(IReadOnlyList<GeoPoint2>, GeoVector3), or a copy of one of no boundary, as AutoCAD 2021 cannot open a drawing that holds one.