|
Description
|
Returns a reference to a collection of "Block" objects. Each object corresponds to an entry of the Blocks section (BLOCKS) of the DXF file.
|
Syntax Visual Basic
|
[form.]DXFReader.Blocks
|
|
Visual C++
|
C_Collection DXFReader.GetBlocks();
|
|
Delphi
|
property Blocks: _Collection;
|
|
C#
|
VBA.Collection DXFReader.Blocks;
|
|
Remarks
|
Use the Blocks collection to retrieve or remove an individual Block object.
The methods of the Blocks collection are:
| Count | Counts the defined Blocks | | Remove | Removes a Block object from the Blocks collection |
To count all the objects of the Blocks collection use the following code:
Dim NBlocks As Long
NBlocks = DXFReader1.Blocks.Count
To remove a Block object, for example the first, from the Blocks collection use the following code:
DXFReader1.Blocks.Remove (1)
All of the properties for the Block object are listed in the following table:
| Property | Data Type | Description |
| | LayerName | String | Layer name | | BlockName | String | Block name | | Flag | Integer | Block-type flags | | EndBlockHandle | String | End Block Handle | | Handle | String | Handle | | X0 | Single | X value of base point | | Y0 | Single | Y value of base point | | Z0 | Single | Z value of base point | | Xref | String | Xref path name (optional; present only if the block is an xref) |
Together with the properties listed before, the Blocks property has encapsulated the reference to a collection of "Entities" objects. This collection lists all the entities contained in the block and has got the same properties of the Entities property. It is possible to read or change every information in a block. To access a specific one use its progressive number or its name as key. For example to read the base point of the third block of a drawing called "TESTLINE" you can use the following code:
With DXFReader
x = .Blocks.Item("TESTLINE").X0 y = .Blocks.Item("TESTLINE").Y0
End With
equivalent to:
With DXFReader
x = .Blocks.Item(3).X0 y = .Blocks.Item(3).Y0
End With
The following code will add to the drawing a new block containg only one line with base point at (0,0):
With DXFReader
.AddBlock "TESTLINE"
.Blocks.Item("TESTLINE").X0 = 0 .Blocks.Item("TESTLINE").Y0 = 0
.AddBlockEntity "TESTLINE" .Blocks.Item("TESTLINE").Entities.Item(1).EntityType = "LINE" .Blocks.Item("TESTLINE").Entities.Item(1).X0 = 0 .Blocks.Item("TESTLINE").Entities.Item(1).Y0 = 0 .Blocks.Item("TESTLINE").Entities.Item(1).X1 = 200 .Blocks.Item("TESTLINE").Entities.Item(1).Y1 = 200
End With
See the Entities property, the AddBlock, the AddBlockEntity and the AddEntity methods, and the Autodesk DXF Reference for more information.
|
|
Data Type
|
Collection
|