Table of Contents

Class DxfBlockReference

Namespace
GeometryHelper.Dxf
Assembly
GeometryHelper.dll

An INSERT of a DXF file, as AutoCAD's BlockReference: a block placed at Position, turned by Rotation and scaled by ScaleFactors in the plane of its Normal, with the values of its attributes in AttributeCollection.

public class DxfBlockReference : DxfEntity
Inheritance
DxfBlockReference
Derived
Inherited Members

Remarks

The INSERT of the block BOLT at (0, -60, 0), turned by nought and scaled by 1, whose block's origin is (5, 5, 0), has the BlockTransform that moves by (-5, -65, 0): a point of the block at its origin lands on the insertion point. Name is the name of the block it places, BOLT; BlockName is that of the block it is in, *Model_Space, as AutoCAD names them.

Its points are in world coordinates, as AutoCAD gives them, though the file writes the insertion point in the system of the normal's plane. Moved, turned, scaled or given a new normal, by a setter or by TransformBy(GeoTransform3), an INSERT carries its ATTRIBs with it, each by the same change of placement, their values untouched. GetGeometry() gives the shapes of its block placed as DxfReader places them; Explode() gives its block's entities placed, in no file.

new DxfBlockReference(new GeoPoint3(10, 20, 0), db.BlockTable["BOLT"]) makes one in code, to be added by AppendEntity(DxfEntity) to a block of the same drawing; a block that would come to insert itself is refused. A copy of an INSERT, GetTransformedCopy(GeoTransform3)'s, added to another drawing places the block of its name there, whatever that drawing's block of the name holds, as AutoCAD binds a block by its name; where that drawing has no block of the name, it brings a copy of its own block, under its name, with the blocks that block inserts that the drawing has not, as AutoCAD's WblockCloneObjects brings them.

GetGeometry() places the block anew on each call, a new list each time; where what it would place passes MaxPlacedEntities it places nothing, and gives no shapes.

Constructors

DxfBlockReference(GeoPoint3, DxfBlockTableRecord)

Initializes an INSERT of a block at a point, as AutoCAD's new BlockReference(position, blockTableRecord): not turned, scaled by 1, on layer 0, in no file until it is added to a block of the drawing the block is of.

Properties

AnonymousBlockTableRecord

Gets the anonymous block that stands for the dynamic block the INSERT places, as AutoCAD's AnonymousBlockTableRecord: its own block where that is such a copy, *U7 of the dynamic block BOLT; null where it places the dynamic block itself, or no dynamic block.

AttributeCollection

Gets the ATTRIBs of the INSERT, as AutoCAD's AttributeCollection: the values it gives its block's attributes, in the order of the file, read as they stand; empty where it has none. Each ATTRIB is the same object while its record is there; AppendAttribute(DxfAttributeReference) adds one.

BlockTableRecord

Gets or sets the block the INSERT places, as AutoCAD's BlockTableRecord gives its id: the record of the block table named by Name; null where the drawing has no block of that name. A copy in no file yet, as Explode() gives a nested INSERT, places the block of the drawing it was copied from, as AutoCAD's copy keeps its block's id, until it is added to a drawing: a copy in no file gives the block of the drawing it was copied from while that block is there, renamed or not.

BlockTransform

Gets or sets the transformation that places the block, as AutoCAD's BlockTransform: from the coordinates of the block to the world, the block's origin taken to Position, its axes scaled by ScaleFactors, turned by Rotation and stood in the plane of Normal. The origin of the block is taken as (0, 0, 0) where the drawing has no block of the INSERT's name.

BlockUnit

Gets the units the block is drawn in (group 70 of its BLOCK_RECORD), as AutoCAD's BlockUnit; Undefined where the drawing gives none, as one older than R2007 does not.

ClipOutline

Gets the clip boundary as a ring of points in the coordinates of the block the reference places, those its entities have in the block, so that BlockTransform carries the ring to where the clip stands in the world: a block whose origin is (10, 20) clipped to the rectangle that, as the reference stands, covers its lower left corner 40 by 30 is the ring (10, 20), (50, 20), (50, 50), (10, 50), whatever the reference is moved, turned or scaled to afterwards. A rectangle's two corners are given as the four of a ring. Null where the reference is not clipped; given whether the clip is on (IsEnabled) or off. Of an external reference the ring is in the drawing's own coordinates, base point and all, as AutoCAD 2021 keeps it: a boundary of a drawing whose base point is (70, 0, 0), attached at (100, 0, 0), that stands at x 130 to 190 of the world is the ring x 100 to 160.

DynamicBlockReferencePropertyCollection

Gets the dynamic properties of the INSERT, as AutoCAD's DynamicBlockReferencePropertyCollection: a new list on each call, each property's value the one AutoCAD saved for this INSERT, or the dynamic block's own where it saved none, as for an INSERT of the dynamic block itself. Empty where the INSERT places no dynamic block. The value of a linear, XY, polar, point, rotation, flip, visibility, lookup, user parameter or block properties table property is set as AutoCAD sets it, where the block is one the library works out (Value); the others are read only.

DynamicBlockTableRecord

Gets the dynamic block the INSERT places, as AutoCAD's DynamicBlockTableRecord: the block whose anonymous copy it places, or its own block where that is the dynamic one; the INSERT's BlockTableRecord where it places no dynamic block, as AutoCAD gives it.

IsDynamicBlock

Gets whether the INSERT places a dynamic block, as AutoCAD's IsDynamicBlock: its block is one (its extension dictionary holds an evaluation graph, IsDynamicBlock), or is the anonymous block that stands for one, whose extended data AcDbBlockRepBTag names the dynamic block's BLOCK_RECORD by its handle (1005), as AutoCAD writes them and ezdxf reads them. An INSERT of a block of the extended data AcDbDynamicBlockGUID and no graph is not, nor one of its anonymous copy, though it keeps its DynamicBlockTableRecord and AnonymousBlockTableRecord, as AutoCAD 2021 read the INSERTs of Bore, PVI, Station and Valve of its samples (plugin D26b). An anonymous block whose tag names no block of the drawing is not, nor is an INSERT scaled unlike along its axes (by more than 1E-9 of the largest, a mirror alike), as AutoCAD 2021 read its INSERTs scaled (2, 3, 2) and (2, 2, 1) as not dynamic though they keep their DynamicBlockTableRecord and their DynamicBlockReferencePropertyCollection.

Name

Gets the name of the block the INSERT places (group 2), as AutoCAD's Name: as the block table names it, its escapes read as letters, such as BOLT or *U1.

Normal

Gets or sets the normal of the plane the INSERT turns its block in (groups 210, 220, 230), as AutoCAD's Normal; of unit length, (0, 0, 1) where the record gives none.

Position

Gets or sets where the INSERT puts its block's origin (groups 10, 20, 30), as AutoCAD's Position: in world coordinates, the file's point taken from the system of the Normal's plane; the origin where the record gives none. An INSERT of an annotative block stands where its context of the scale 1:1 says, else its default context, as AutoCAD 2021 reads one whatever CANNOSCALE says, and as Position reads a text: the INSERT of Valve - Metric of AutoCAD's sample, its record at (13.883, 279.776) unturned and unscaled, its context of 1:1 at (113.883, 279.776) turned 45 degrees and scaled by 2, stands there, turned and scaled so (check D35b). Its Rotation, ScaleFactors and so BlockTransform are that context's too.

Rotation

Gets or sets how far the INSERT turns its block (group 50, in degrees), as AutoCAD's Rotation: in radians, counter-clockwise about its normal; nought where the record gives none. An annotative one's is that of the context it is read at, as Position says.

ScaleFactors

Gets or sets how the INSERT scales its block along its x, y and z (groups 41, 42, 43), as AutoCAD's ScaleFactors; 1 for each the record gives none of. A factor below nought mirrors the block. An annotative one's are those of the context it is read at, as Position says.

SpatialFilter

Gets the clip boundary of the reference, as AutoCAD's XCLIP keeps it: the SPATIAL_FILTER under the name SPATIAL in the dictionary ACAD_FILTER of its extension dictionary; null where it has none, as one not clipped.

TreatAsBlockRefForExplode

Gets whether the INSERT is exploded as a block reference, as AutoCAD's TreatAsBlockRefForExplode: true for every INSERT, which Explode() breaks into its block's entities; false for a MINSERT, of one cell or more, which it refuses, as AutoCAD 2021 gave false for its MINSERTs of 3 by 2 cells and of one.

UnitFactor

Gets how a length of the block is scaled to the drawing by their units, as AutoCAD's UnitFactor: the block's BlockUnit against the drawing's $INSUNITS; 1 where either is Undefined. A block drawn in inches inserted in a drawing of millimetres has 25.4; in one of metres, 0.0254. It is read from the file alone: the INSERT's ScaleFactors and BlockTransform do not take it in.

Methods

ClipTo(IReadOnlyList<GeoPoint2>, GeoTransform3)

Clips the block the reference places to a boundary, as AutoCAD's XCLIP New boundary does: the part of the block outside the boundary is no longer shown, and the part inside is. A SPATIAL_FILTER is written into the dictionary ACAD_FILTER of the reference's extension dictionary, each made as AutoCAD makes it, with the boundary as given, the matrix that carries the world into the clip coordinate system, and the inverse of the reference's placing as it stands now. A clip the reference has is replaced. The clip is on, with no clipping planes.

ConvertToStaticBlock()

Makes the INSERT of a dynamic block place an anonymous block that draws what it draws now, as AutoCAD's ConvertToStaticBlock(): as ConvertToStaticBlock(string) does, the new block named as AutoCAD names one itself, the first of *U1, *U2 and on the drawing has no block of and no INSERT of it names, and flagged anonymous (70 of 1).

ConvertToStaticBlock(string)

Makes the INSERT of a dynamic block place a block of its own name that draws what it draws now, as AutoCAD's ConvertToStaticBlock(newBlockName): a new block of that name, its origin and units those of the block it places, the anonymous copy AutoCAD made for it (AnonymousBlockTableRecord) or the dynamic block itself, holding copies of that block's entities, as WblockCloneObjects(IEnumerable<DxfEntity>, DxfBlockTableRecord) copies them; the INSERT's 2 named it, and the entry AcDbBlockRepresentation of its extension dictionary, which ties it to the dynamic block, taken out. The INSERT is then no dynamic block's, its attributes kept as they are; the anonymous block stays for the other INSERTs that place it.

Explode()

Gets the entities of the block placed where the INSERT puts them, as AutoCAD's Explode gives them: new entities in no file, one level down, so that an INSERT in the block comes out an INSERT, and an ATTDEF of the block a DxfAttributeDefinition placed as the rest are. The INSERT's ATTRIBs are not among them: their values stay where they are, in AttributeCollection. A MINSERT of more than one cell is refused, as AutoCAD refuses one (see Explode()).

ExplodeToOwnerSpace()

Explodes the INSERT into the block it is in, as AutoCAD's ExplodeToOwnerSpace: the entities Explode() gives, an ATTDEF of the block among them, appended to the INSERT's owner, model space for one of model space, in the order of the block, with handles of their own. The INSERT itself is kept, with its ATTRIBs, as AutoCAD keeps it: insert.ExplodeToOwnerSpace(); insert.Erase(); explodes it as AutoCAD's EXPLODE does, the attributes turned back into their definitions. A MINSERT gives its first cell alone, as AutoCAD 2021's ExplodeToOwnerSpace did: its MINSERT of a circle of radius 3 in 3 columns by 2 rows made one circle, that at the MINSERT's insertion point.

GeometryExtentsBestFit()

Gets the box the shapes of the block take where the INSERT places them, as AutoCAD's GeometryExtentsBestFit: the least and greatest x, y and z of each shape placed, not of the block's box placed, so that a block turned by 45 degrees has the box of its shapes, not the larger one of its turned box; as GeometricExtents gives them.

GeometryExtentsBestFit(GeoTransform3)

Gets the box the shapes of the block take where the INSERT places them, then moved by a transformation, as AutoCAD's GeometryExtentsBestFit(parentTransform): the transformation that places the block the INSERT is in, an outer INSERT's BlockTransform, so that an INSERT of BOLT inside FRAME has the box of its bolt where the INSERT of FRAME puts it. The INSERT of a block of the line from (0, 0, 0) to (0, 1, 0), turned by 90 degrees at (5, 0, 0), has the box (4, 0, 0) to (5, 0, 0); moved by (0, 10, 0), the box (4, 10, 0) to (5, 10, 0).

GetDynamicGrips()

Gets the custom grips AutoCAD shows on the INSERT of a dynamic block selected, where its values put them: a new list on each call, in the order of the parameters of the block's graph. Empty where the INSERT places no dynamic block (IsDynamicBlock).

RemoveClip()

Takes the clip boundary off the reference, as AutoCAD's XCLIP Delete does: its SPATIAL_FILTER erased, and the dictionary ACAD_FILTER with it where that holds nothing else. The extension dictionary stays, as AutoCAD leaves it. Nothing where the reference is not clipped.

ResetBlock()

Puts every dynamic property of the INSERT back to the dynamic block's own value, as AutoCAD's ResetBlock and its RESETBLOCK command do: the INSERT places the dynamic block itself again, and its representation data (the entry AcDbBlockRepresentation of its extension dictionary, with the values saved and the history of grip edits) is removed, the dictionary kept, as AutoCAD 2021 left it (plugin GhDyn1). The INSERT keeps its place, rotation, scale and ATTRIBs where they are, as AutoCAD kept the door's DOOR_NO at (2 800, -450) reset from a Width of 1 000 to its own 900; the anonymous block it placed is left in the drawing, as AutoCAD left *U2. An INSERT that places the dynamic block itself already has its representation data removed where it keeps some, and is left as it is where it keeps none; one that places no dynamic block is left as it is.