Table of Contents

Class DxfBlockTableRecord

Namespace
GeometryHelper.Dxf
Assembly
GeometryHelper.dll

A block of a DXF file, as AutoCAD's BlockTableRecord: model space, paper space or a block; its name, its origin, what kind it is, and its entities, enumerated, appended to and erased.

public sealed class DxfBlockTableRecord : DxfSymbolTableRecord, IEnumerable<DxfEntity>, IEnumerable
Inheritance
DxfBlockTableRecord
Implements
Inherited Members
Extension Methods

Remarks

db.ModelSpace.AppendEntity(new DxfLine(a, b)) adds a line to model space: its record is written at the end of the ENTITIES section, a block's before its ENDBLK, in the file's own style, with a handle of its own above every handle of the file and the block as its owner, as AutoCAD writes one. An entity is erased by its own Erase().

The entities are enumerated in the order of the file, those appended after them, each the same object every time; a POLYLINE is one entity with its vertices and an INSERT one with its attributes, as AutoCAD keeps them together. An enumeration walks the entities the block holds when it begins: those erased on the way are passed over, those appended on the way are not reached, and nothing throws, so a loop may erase or append as it goes.

Constructors

DxfBlockTableRecord()

Initializes a block made in code, to be added to a DxfBlockTable with its Name and Origin given.

Fields

ModelSpace

The name AutoCAD gives the block of model space, as AutoCAD's BlockTableRecord.ModelSpace.

PaperSpace

The name AutoCAD gives the block of paper space, as AutoCAD's BlockTableRecord.PaperSpace.

Properties

BlockPropertiesTable

Gets the block properties table of the dynamic block, as the drawing keeps it: the name of its property, the name of each column and the rows (DxfBlockPropertiesTable), read anew on each call; null where the block has none, or one the library cannot read whole (a cell of a kind other than a real or a text).

BlockScaling

Gets or sets how the INSERTs of the block may scale it (group 281 of its BLOCK_RECORD), as AutoCAD's BlockScaling; Any where it gives none.

Comments

Gets or sets the description of the block (group 4 of its BLOCK), as AutoCAD's Comments; empty where it gives none.

Count

Gets how many entities the block holds, a POLYLINE with its vertices one, an MTEXT with its linked columns one, as GetEnumerator() walks them.

DrawOrderTable

Gets the draw order of the block, as AutoCAD's DrawOrderTableId names it: the SORTENTSTABLE under ACAD_SORTENTS in the block's extension dictionary; null where the block has none, its entities then drawn in the order of the block.

Explodable

Gets or sets whether the INSERTs of the block may be exploded (group 280 of its BLOCK_RECORD), as AutoCAD's Explodable; true where it gives none.

HasAttributeDefinitions

Gets whether the block has attribute definitions (flag 2), as AutoCAD's HasAttributeDefinitions: set when one is appended (AppendEntity(DxfEntity)), constant or not, in model space too, and kept when it is erased, as AutoCAD 2021 sets and saves it; a block read from a file says what its file says.

HasPreviewIcon

Gets whether the block has a preview picture (groups 310 of its BLOCK_RECORD), as AutoCAD's HasPreviewIcon.

Hyperlinks

Gets the hyperlinks of the block, as AutoCAD's Hyperlinks: those of the extended data of the application PE_URL of its BLOCK_RECORD, as DxfHyperLinkCollection says.

IsAnonymous

Gets whether the block is one AutoCAD names itself, as a dimension's *D1 (flag 1 of its BLOCK's group 70), as AutoCAD's IsAnonymous: true of a block added named *D, *U or *T, which the table names *D1, *U1 or *T1 and on.

IsDynamicBlock

Gets whether the block is a dynamic block, as AutoCAD's IsDynamicBlock: its extension dictionary holds the evaluation graph of its parameters and actions (the entry ACAD_ENHANCEDBLOCK). The extended data AcDbDynamicBlockGUID does not make it one: AutoCAD 2021 read the Bore, PVI, Station and Valve blocks of its Dynamic Blocks samples, which keep the GUID over an empty extension dictionary, as not dynamic, and a block whose GUID was taken out and its graph kept as dynamic (plugin D26b).

IsFromExternalReference

Gets whether the block is an external reference (flag 4), as AutoCAD's IsFromExternalReference.

IsFromOverlayReference

Gets whether the block is an external reference overlaid (flag 8), as AutoCAD's IsFromOverlayReference.

IsLayout

Gets whether the block is that of a layout, as AutoCAD's IsLayout: model space, paper space, or the block of another layout, *Paper_Space0 and on, or one whose BLOCK_RECORD names a layout (group 340).

Name

Gets or sets the name of the block, as Name: AutoCAD's *Model_Space and *Paper_Space for model space and paper space, whatever the file calls them, as a file of R12 calls them $Model_Space and $Paper_Space.

Origin

Gets or sets the origin of the block (groups 10, 20, 30 of its BLOCK), as AutoCAD's Origin: the point of the block an INSERT puts at its insertion point; the origin of the world for model and paper space.

PathName

Gets or sets the path of the drawing an external reference comes from (group 1 of its BLOCK), as AutoCAD's PathName; empty for a block that is none.

PreviewIcon

Gets or sets the preview picture of the block, as AutoCAD's PreviewIcon gives it as a bitmap: here the bytes its BLOCK_RECORD keeps, the groups 310 one after another, a bitmap of Windows without the file's header, as AutoCAD writes it; null where it has none.

Units

Gets or sets the unit the block is drawn in (group 70 of its BLOCK_RECORD), as AutoCAD's Units: an INSERT of a block in millimetres into a drawing in metres scales it by a thousandth; Undefined where it gives none.

XrefStatus

Gets where the external reference stands, as AutoCAD's XrefStatus, from its BLOCK's flags and its path: NotAnXref for a block that is none (flag 4 clear); Unreferenced where no INSERT places it; FileNotFound where its PathName is no file, as written or from the folder of the drawing's Filename; Resolved where AutoCAD saved it resolved (flag 32); Unresolved otherwise, as one attached here stands until AutoCAD opens the drawing and resolves it. Unloaded is never given: no group of a DXF file says an external reference is unloaded.

Methods

AddAlignmentParameter(GeoPoint3, GeoPoint3)

Makes the block dynamic, where it is not, and gives it an alignment parameter, AutoCAD's Alignment parameter as its Block Editor makes one: a grip at the base point that turns an INSERT dragged by it in AutoCAD to lie along the entity it is dragged over, along the line from the base point to the end point. It gives no property.

AddArrayAction(DxfBlockLinearParameter, IEnumerable<DxfEntity>, double)

Gives the block an array action tied to a linear parameter of it, AutoCAD's Array action as its Block Editor makes one: as the parameter's distance grows, the entities are copied along the line from the parameter's base point to its end point, a copy at each column spacing, as many in all as the spacing goes whole into the distance.

AddArrayAction(DxfBlockXYParameter, IEnumerable<DxfEntity>, double, double)

Gives the block an array action tied to an XY parameter of it, AutoCAD's Array action as its Block Editor makes one: as the parameter's end point moves, the entities are copied in rows and columns from the base point the way the end point lies, a column at each column spacing along x and a row at each row spacing along y.

AddBasePointParameter(GeoPoint3)

Makes the block dynamic, where it is not, and gives it a base point parameter, AutoCAD's Base Point parameter as its Block Editor makes one: a base point for the INSERTs of the block apart from its origin. It gives no property.

AddBlockPropertiesTable(GeoPoint3, IEnumerable<DxfBlockPropertiesTableColumn>, IEnumerable<DxfBlockPropertiesTableRow>)

Makes the block dynamic, where it is not, and gives it a block properties table: rows of values, each setting several properties of the block's parameters and attributes at once, which each INSERT of the block shows as the dynamic property Block Table1, the index of its row, AutoCAD's Block Properties Table as its Block Editor makes one. Set to a row's index, the property sets each column to the row's value; it reads the index of the first row of the values the INSERT shows, else -1.

AddFlipAction(DxfBlockFlipParameter, IEnumerable<DxfEntity>)

Gives the block a flip action tied to a flip parameter of it, AutoCAD's Flip action as its Block Editor makes one: the entities are mirrored about the parameter's reflection line where the parameter's state is 1, flipped.

AddFlipParameter(string, string, GeoPoint3, GeoPoint3)

Makes the block dynamic, where it is not, and gives it a flip parameter: a reflection line that each INSERT of the block flips about as the dynamic property of its name says, 0 not flipped and 1 flipped, AutoCAD's Flip parameter as its Block Editor makes one. Tie the parameter to the entities it flips with AddFlipAction(DxfBlockFlipParameter, IEnumerable<DxfEntity>).

AddLinearParameter(string, string, GeoPoint3, GeoPoint3, double, DxfBlockParameterValueSet)

Makes the block dynamic, where it is not, and gives it a linear parameter: a distance from a base point to an end point that each INSERT of the block shows as the dynamic property of its name, AutoCAD's Linear parameter of two grips as its Block Editor makes one. Tie the parameter to the entities it moves with AddStretchAction(DxfBlockLinearParameter, GeoPoint2, GeoPoint2, IEnumerable<DxfEntity>), AddMoveAction(DxfBlockLinearParameter, IEnumerable<DxfEntity>) and AddScaleAction(DxfBlockLinearParameter, IEnumerable<DxfEntity>).

AddLookupParameter(string, string, GeoPoint3, IEnumerable<DxfBlockLookupInput>, IEnumerable<DxfBlockLookupRow>)

Makes the block dynamic, where it is not, and gives it a lookup parameter with its lookup action: a table of rows, each a label and the values it gives other parameters' properties, which each INSERT of the block shows as the dynamic property of the parameter's name, AutoCAD's Lookup parameter and Lookup action as its Block Editor makes them. Set to a row's label, the property sets the other properties to the row's values; any of those set, it shows the label of the row of their values, or Custom where no row holds them.

AddMoveAction(DxfBlockLinearParameter, IEnumerable<DxfEntity>)

Gives the block a move action tied to a linear parameter of it, AutoCAD's Move action as its Block Editor makes one: as the parameter's distance grows by an amount, the entities move whole by that amount along the line from the parameter's base point to its end point, following the end point.

AddMoveAction(DxfBlockLinearParameter, IEnumerable<DxfEntity>, double, double)

Gives the block a move action tied to a linear parameter of it, as AddMoveAction(DxfBlockLinearParameter, IEnumerable<DxfEntity>) does, of a distance multiplier and an angle offset, AutoCAD's Distance Multiplier and Angle Offset of the action: the entities move by the change of the parameter's end point times the multiplier, turned by the offset.

AddMoveAction(DxfBlockPointParameter, IEnumerable<DxfEntity>)

Gives the block a move action tied to a point parameter of it, AutoCAD's Move action as its Block Editor makes one: the entities move whole as the parameter's position moves.

AddMoveAction(DxfBlockPointParameter, IEnumerable<DxfEntity>, double, double)

Gives the block a move action tied to a point parameter of it, as AddMoveAction(DxfBlockPointParameter, IEnumerable<DxfEntity>) does, of a distance multiplier and an angle offset: the entities move by the move of the parameter's position times the multiplier, turned by the offset.

AddMoveAction(DxfBlockPolarParameter, IEnumerable<DxfEntity>)

Gives the block a move action tied to a polar parameter of it, AutoCAD's Move action as its Block Editor makes one on a polar parameter: the entities move whole with the parameter's end point, along x and along y, unturned.

AddMoveAction(DxfBlockPolarParameter, IEnumerable<DxfEntity>, double, double)

Gives the block a move action tied to a polar parameter of it, as AddMoveAction(DxfBlockPolarParameter, IEnumerable<DxfEntity>) does, of a distance multiplier and an angle offset: the entities move by the move of the parameter's end point times the multiplier, turned by the offset.

AddMoveAction(DxfBlockXYParameter, IEnumerable<DxfEntity>)

Gives the block a move action tied to an XY parameter of it, AutoCAD's Move action of the XY type as its Block Editor makes one: the entities move whole with the parameter's end point, along x and along y.

AddMoveAction(DxfBlockXYParameter, IEnumerable<DxfEntity>, double, double)

Gives the block a move action tied to an XY parameter of it, as AddMoveAction(DxfBlockXYParameter, IEnumerable<DxfEntity>) does, of a distance multiplier and an angle offset: the entities move by the move of the parameter's end point times the multiplier, turned by the offset.

AddPointParameter(string, string, GeoPoint3)

Makes the block dynamic, where it is not, and gives it a point parameter: a position that each INSERT of the block shows as two dynamic properties, the parameter's name with " X" and " Y" after it, AutoCAD's Point parameter as its Block Editor makes one. Tie the parameter to the entities it moves with AddMoveAction(DxfBlockPointParameter, IEnumerable<DxfEntity>).

AddPolarParameter(string, string, string, string, GeoPoint3, GeoPoint3, double, DxfBlockParameterValueSet, DxfBlockParameterValueSet)

Makes the block dynamic, where it is not, and gives it a polar parameter: the distance from a base point to an end point and the angle of that line from the block's x axis, which each INSERT of the block shows as two dynamic properties, AutoCAD's Polar parameter of two grips as its Block Editor makes one. Tie the parameter to the entities it turns and stretches with AddPolarStretchAction(DxfBlockPolarParameter, GeoPoint2, GeoPoint2, IEnumerable<DxfEntity>, IEnumerable<DxfEntity>), and those that follow its end point unturned with AddStretchAction(DxfBlockPolarParameter, GeoPoint2, GeoPoint2, IEnumerable<DxfEntity>) and AddMoveAction(DxfBlockPolarParameter, IEnumerable<DxfEntity>).

AddPolarStretchAction(DxfBlockPolarParameter, GeoPoint2, GeoPoint2, IEnumerable<DxfEntity>, IEnumerable<DxfEntity>)

Gives the block a polar stretch action tied to a polar parameter of it, AutoCAD's Polar Stretch action as its Block Editor makes one: as the parameter's angle turns and its distance grows, the entities turn about the parameter's base point by the change of the angle, and the points of the entities inside the frame move besides along the new line by the change of the distance, so an entity across the frame stretches as it turns; the entities to turn only turn whole about the base point.

AddRotateAction(DxfBlockRotationParameter, IEnumerable<DxfEntity>)

Gives the block a rotate action tied to a rotation parameter of it, AutoCAD's Rotate action as its Block Editor makes one: the entities turn about the parameter's base point by the parameter's angle less the block's own.

AddRotationParameter(string, string, GeoPoint3, double, double)

Makes the block dynamic, where it is not, and gives it a rotation parameter: an angle about a base point that each INSERT of the block shows as the dynamic property of its name, in radians, AutoCAD's Rotation parameter as its Block Editor makes one. Tie the parameter to the entities it turns with AddRotateAction(DxfBlockRotationParameter, IEnumerable<DxfEntity>).

AddRotationParameter(string, string, GeoPoint3, double, double, DxfBlockParameterValueSet)

Makes the block dynamic, where it is not, and gives it a rotation parameter, as AddRotationParameter(string, string, GeoPoint3, double, double) does, of the angles it may take, AutoCAD's Value Set of the parameter: from a minimum to a maximum in steps of an increment, or one of a list, in radians.

AddScaleAction(DxfBlockLinearParameter, IEnumerable<DxfEntity>)

Gives the block a scale action tied to a linear parameter of it, AutoCAD's Scale action as its Block Editor makes one: the entities are scaled alike in every direction about the parameter's base point, by the parameter's distance over the block's own.

AddStretchAction(DxfBlockLinearParameter, GeoPoint2, GeoPoint2, IEnumerable<DxfEntity>)

Gives the block a stretch action tied to a linear parameter of it, AutoCAD's Stretch action as its Block Editor makes one: as the parameter's distance grows by an amount, the points of the entities inside the frame move by that amount along the line from the parameter's base point to its end point and the points outside stay, so an entity across the frame stretches and one inside it moves whole.

AddStretchAction(DxfBlockLinearParameter, GeoPoint2, GeoPoint2, IEnumerable<DxfEntity>, double, double)

Gives the block a stretch action tied to a linear parameter of it, as AddStretchAction(DxfBlockLinearParameter, GeoPoint2, GeoPoint2, IEnumerable<DxfEntity>) does, of a distance multiplier and an angle offset, AutoCAD's Distance Multiplier and Angle Offset of the action: the points in the frame move by the change of the parameter's end point times the multiplier, turned by the offset.

AddStretchAction(DxfBlockPolarParameter, GeoPoint2, GeoPoint2, IEnumerable<DxfEntity>)

Gives the block a stretch action tied to a polar parameter of it, AutoCAD's Stretch action as its Block Editor makes one on a polar parameter: as the parameter's end point moves, by its distance and its angle, the points of the entities inside the frame move with it, along x and along y, unturned, and the points outside stay.

AddStretchAction(DxfBlockPolarParameter, GeoPoint2, GeoPoint2, IEnumerable<DxfEntity>, double, double)

Gives the block a stretch action tied to a polar parameter of it, as AddStretchAction(DxfBlockPolarParameter, GeoPoint2, GeoPoint2, IEnumerable<DxfEntity>) does, of a distance multiplier and an angle offset: the points in the frame move by the move of the parameter's end point times the multiplier, turned by the offset.

AddStretchAction(DxfBlockXYParameter, GeoPoint2, GeoPoint2, IEnumerable<DxfEntity>)

Gives the block a stretch action tied to an XY parameter of it, AutoCAD's Stretch action of the XY type as its Block Editor makes one: as the parameter's end point moves, by its distance along x and along y, the points of the entities inside the frame move with it both ways and the points outside stay.

AddStretchAction(DxfBlockXYParameter, GeoPoint2, GeoPoint2, IEnumerable<DxfEntity>, double, double)

Gives the block a stretch action tied to an XY parameter of it, as AddStretchAction(DxfBlockXYParameter, GeoPoint2, GeoPoint2, IEnumerable<DxfEntity>) does, of a distance multiplier and an angle offset: the points in the frame move by the move of the parameter's end point times the multiplier, turned by the offset.

AddVisibilityParameter(string, string, GeoPoint3, IEnumerable<DxfBlockVisibilityState>)

Makes the block dynamic, where it is not, and gives it a visibility parameter: named states, each showing some of the block's entities and hiding the others the states name, which each INSERT of the block shows as the dynamic property of the parameter's name, AutoCAD's Visibility parameter as its Block Editor makes one. Each INSERT shows the first state until its property is set (Value).

AddXYParameter(string, string, string, string, GeoPoint3, GeoPoint3)

Makes the block dynamic, where it is not, and gives it an XY parameter: the distances along x and along y from a base point to an end point, which each INSERT of the block shows as two dynamic properties, AutoCAD's XY parameter of four grips as its Block Editor makes one. Tie the parameter to the entities it moves with AddStretchAction(DxfBlockXYParameter, GeoPoint2, GeoPoint2, IEnumerable<DxfEntity>) and AddMoveAction(DxfBlockXYParameter, IEnumerable<DxfEntity>).

AddXYParameter(string, string, string, string, GeoPoint3, GeoPoint3, DxfBlockParameterValueSet, DxfBlockParameterValueSet)

Makes the block dynamic, where it is not, and gives it an XY parameter, as AddXYParameter(string, string, string, string, GeoPoint3, GeoPoint3) does, of the distances each of its properties may take, AutoCAD's Horizontal and Vertical Value Sets of the parameter.

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.

AssumeOwnershipOf(IEnumerable<DxfEntity>)

Moves entities of the drawing into the block, as AutoCAD's AssumeOwnershipOf: each taken out of the block it is in and written at the end of this one, before its ENDBLK, or at the end of the ENTITIES section for model and paper space, its handle kept, this block as its owner and its group 67, and that of each record that follows it (a VERTEX, an ATTRIB, its SEQEND), as the space has it; the same object stands for it.

CreateDrawOrderTable()

Gives the block a draw order where it has none, as AutoCAD makes one when its DrawOrderTableId is asked for: an empty SORTENTSTABLE under ACAD_SORTENTS in the block's extension dictionary, made where it has none, owned by that dictionary and naming the block (330). The table the block has, where it has one.

Erase()

Erases the block from the drawing, as AutoCAD's Erase of a block nothing inserts: its BLOCK, its entities and its ENDBLK taken out of the BLOCKS section and its BLOCK_RECORD out of the block table, each handle not given again and what they owned removed with them when the file is saved.

GetAnonymousBlocks()

Gets the blocks AutoCAD made of this dynamic block for its INSERTs, as its GetAnonymousBlockIds gives their ids: each block of the table that names this one as the block it represents, by the extended data of the application AcDbBlockRepBTag (its 1005) or by the object AcDbRepData of the dictionary AcDbBlockRepresentation of its extension dictionary (its 340), in the order of the block table.

GetBlockReferences(bool)

Gets the INSERTs of the block, as AutoCAD's GetBlockReferenceIds gives their ids: every DxfBlockReference of it, a MINSERT among them, in model space, paper space and every block, in the order of the block table and then of each block.

GetEnumerator()

Gets an enumerator over the entities, in the order of the file, those appended after them: over the entities the block holds when the walk begins, so that foreach (DxfEntity e in db.ModelSpace) e.Erase(); erases them all, as it does in AutoCAD. An entity erased during the walk is passed over, and one appended is not reached.

GetVisibilityStates()

Gets the visibility states of the dynamic block, as AutoCAD's Block Editor lists them in its Visibility State box: each by its name, in the order of the block's visibility parameter, with the entities of the block it shows, in the order the parameter lists them; read anew on each call.