Show / Hide Table of Contents

Class Block

Represents a block definition.

Inheritance
System.Object
DxfObject
TableObject
Block
Implements
IHasXData
System.ICloneable
System.IComparable
System.IComparable<TableObject>
System.IEquatable<TableObject>
Inherited Members
TableObject.NameChanged
TableObject.OnNameChangedEvent(String, String)
TableObject.XDataAddAppReg
TableObject.OnXDataAddAppRegEvent(ApplicationRegistry)
TableObject.XDataRemoveAppReg
TableObject.OnXDataRemoveAppRegEvent(ApplicationRegistry)
TableObject.IsReserved
TableObject.InvalidCharacters
TableObject.XData
TableObject.IsValidName(String)
TableObject.ToString()
TableObject.CompareTo(Object)
TableObject.CompareTo(TableObject)
TableObject.GetHashCode()
TableObject.Equals(Object)
TableObject.Equals(TableObject)
DxfObject.CodeName
DxfObject.Handle
DxfObject.Owner
System.Object.Equals(System.Object, System.Object)
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
Namespace: netDxf.Blocks
Assembly: CADability.dll
Syntax
public class Block : TableObject, IHasXData, ICloneable, IComparable, IComparable<TableObject>, IEquatable<TableObject>
Remarks

Avoid to add any kind of dimensions to the block's entities list, programs loading DXF files with them seems to behave in a weird fashion. This is not applicable when working in the Model and Paper space blocks.

Constructors

| Improve this Doc View Source

Block(String)

Initializes a new instance of the Block class.

Declaration
public Block(string name)
Parameters
Type Name Description
System.String name

Block name.

| Improve this Doc View Source

Block(String, IEnumerable<EntityObject>)

Initializes a new instance of the Block class.

Declaration
public Block(string name, IEnumerable<EntityObject> entities)
Parameters
Type Name Description
System.String name

Block name.

System.Collections.Generic.IEnumerable<EntityObject> entities

The list of entities that make the block.

| Improve this Doc View Source

Block(String, IEnumerable<EntityObject>, IEnumerable<AttributeDefinition>)

Initializes a new instance of the Block class.

Declaration
public Block(string name, IEnumerable<EntityObject> entities, IEnumerable<AttributeDefinition> attributes)
Parameters
Type Name Description
System.String name

Block name.

System.Collections.Generic.IEnumerable<EntityObject> entities

The list of entities that make the block.

System.Collections.Generic.IEnumerable<AttributeDefinition> attributes

The list of attribute definitions that make the block.

| Improve this Doc View Source

Block(String, String)

Initializes a new instance of the Block class as an external reference drawing.

Declaration
public Block(string name, string xrefFile)
Parameters
Type Name Description
System.String name

Block name.

System.String xrefFile

External reference path name.

Remarks

Only DWG files can be used as externally referenced blocks.

| Improve this Doc View Source

Block(String, String, Boolean)

Initializes a new instance of the Block class as an external reference drawing.

Declaration
public Block(string name, string xrefFile, bool overlay)
Parameters
Type Name Description
System.String name

Block name.

System.String xrefFile

External reference path name.

System.Boolean overlay

Specifies if the external reference is an overlay, by default it is set to false.

Remarks

Only DWG files can be used as externally referenced blocks.

Fields

| Improve this Doc View Source

DefaultModelSpaceName

Default ModelSpace block name.

Declaration
public const string DefaultModelSpaceName = "*Model_Space"
Field Value
Type Description
System.String
| Improve this Doc View Source

DefaultPaperSpaceName

Default PaperSpace block name.

Declaration
public const string DefaultPaperSpaceName = "*Paper_Space"
Field Value
Type Description
System.String

Properties

| Improve this Doc View Source

AttributeDefinitions

Gets the AttributeDefinition list of the block.

Declaration
public AttributeDefinitionDictionary AttributeDefinitions { get; }
Property Value
Type Description
AttributeDefinitionDictionary
Remarks

Null or attribute definitions already owned by another block or document cannot be added to the list. Additionally Paper Space blocks do not contain attribute definitions.

| Improve this Doc View Source

Description

Gets or sets the block description.

Declaration
public string Description { get; set; }
Property Value
Type Description
System.String
Remarks

AutoCAD has an unknown limit on the number of characters for the description when loading an external DXF, while, on the other hand is perfectly capable of saving a Block description that surpasses such limit.
Keep in mind that when saving a DXF prior to the AutoCad2007 version, non-ASCII characters will be encoded, therefore a single letter might consume more characters when saved into the DXF.
New line characters are not allowed.

| Improve this Doc View Source

Entities

Gets the EntityObject list of the block.

Declaration
public EntityCollection Entities { get; }
Property Value
Type Description
EntityCollection
Remarks

Null entities, attribute definitions or entities already owned by another block or document cannot be added to the list.

| Improve this Doc View Source

Flags

Gets the block-type flags (bit-coded values, may be combined).

Declaration
public BlockTypeFlags Flags { get; }
Property Value
Type Description
BlockTypeFlags
| Improve this Doc View Source

IsForInternalUseOnly

All blocks that starts with "*" are for internal use only.

Declaration
public bool IsForInternalUseOnly { get; }
Property Value
Type Description
System.Boolean
| Improve this Doc View Source

IsXRef

Gets if the block is an external reference.

Declaration
public bool IsXRef { get; }
Property Value
Type Description
System.Boolean
| Improve this Doc View Source

Layer

Gets or sets the block Layer.

Declaration
public Layer Layer { get; set; }
Property Value
Type Description
Layer
Remarks

It seems that the block layer is always the default "0" regardless of what is defined here, so it is pointless to change this value.

| Improve this Doc View Source

ModelSpace

Gets the default *Model_Space block.

Declaration
public static Block ModelSpace { get; }
Property Value
Type Description
Block
| Improve this Doc View Source

Name

Gets the name of the table object.

Declaration
public string Name { get; set; }
Property Value
Type Description
System.String
Remarks

Table object names are case insensitive.

| Improve this Doc View Source

Origin

Gets or sets the block origin in world coordinates, it is recommended to always keep this value to the default Vector3.Zero.

Declaration
public Vector3 Origin { get; set; }
Property Value
Type Description
Vector3
| Improve this Doc View Source

PaperSpace

Gets the default *Paper_Space block.

Declaration
public static Block PaperSpace { get; }
Property Value
Type Description
Block
| Improve this Doc View Source

Record

Gets the block record associated with this block.

Declaration
public BlockRecord Record { get; }
Property Value
Type Description
BlockRecord
Remarks

It returns the same object as the owner property.

| Improve this Doc View Source

XrefFile

Gets the external reference path name.

Declaration
public string XrefFile { get; }
Property Value
Type Description
System.String
Remarks

This property is only applicable to externally referenced blocks.

Methods

| Improve this Doc View Source

Clone()

Creates a new Block that is a copy of the current instance.

Declaration
public override object Clone()
Returns
Type Description
System.Object

A new Block that is a copy of this instance.

Overrides
TableObject.Clone()
| Improve this Doc View Source

Clone(String)

Creates a new Block that is a copy of the current instance.

Declaration
public override TableObject Clone(string newName)
Parameters
Type Name Description
System.String newName

Block name of the copy.

Returns
Type Description
TableObject

A new Block that is a copy of this instance.

Overrides
TableObject.Clone(String)
| Improve this Doc View Source

Create(DxfDocument, String)

Creates a block from the content of a DxfDocument.

Declaration
public static Block Create(DxfDocument doc, string name)
Parameters
Type Name Description
DxfDocument doc

A DxfDocument instance.

System.String name

Name of the new block.

Returns
Type Description
Block

The block build from the DxfDocument content.

Remarks

Only the entities contained in ModelSpace will make part of the block.

| Improve this Doc View Source

Load(String)

Creates a block from an external DXF file.

Declaration
public static Block Load(string file)
Parameters
Type Name Description
System.String file

DXF file name.

Returns
Type Description
Block

The block build from the DXF file content. It will return null if the file has not been able to load.

Remarks

The name of the block will be the file name without extension, and only the entities contained in ModelSpace will make part of the block.

| Improve this Doc View Source

Load(String, IEnumerable<String>)

Creates a block from an external DXF file.

Declaration
public static Block Load(string file, IEnumerable<string> supportFolders)
Parameters
Type Name Description
System.String file

DXF file name.

System.Collections.Generic.IEnumerable<System.String> supportFolders

List of the document support folders.

Returns
Type Description
Block

The block build from the DXF file content. It will return null if the file has not been able to load.

Remarks

The name of the block will be the file name without extension, and only the entities contained in ModelSpace will make part of the block.

| Improve this Doc View Source

Load(String, String)

Creates a block from an external DXF file.

Declaration
public static Block Load(string file, string name)
Parameters
Type Name Description
System.String file

DXF file name.

System.String name

Name of the new block.

Returns
Type Description
Block

The block build from the DXF file content. It will return null if the file has not been able to load.

Remarks

Only the entities contained in ModelSpace will make part of the block.

| Improve this Doc View Source

Load(String, String, IEnumerable<String>)

Creates a block from an external DXF file.

Declaration
public static Block Load(string file, string name, IEnumerable<string> supportFolders)
Parameters
Type Name Description
System.String file

DXF file name.

System.String name

Name of the new block.

System.Collections.Generic.IEnumerable<System.String> supportFolders

List of the document support folders.

Returns
Type Description
Block

The block build from the DXF file content. It will return null if the file has not been able to load.

Remarks

Only the entities contained in ModelSpace will make part of the block.

| Improve this Doc View Source

OnAttributeDefinitionAddedEvent(AttributeDefinition)

Declaration
protected virtual void OnAttributeDefinitionAddedEvent(AttributeDefinition item)
Parameters
Type Name Description
AttributeDefinition item
| Improve this Doc View Source

OnAttributeDefinitionRemovedEvent(AttributeDefinition)

Declaration
protected virtual void OnAttributeDefinitionRemovedEvent(AttributeDefinition item)
Parameters
Type Name Description
AttributeDefinition item
| Improve this Doc View Source

OnEntityAddedEvent(EntityObject)

Declaration
protected virtual void OnEntityAddedEvent(EntityObject item)
Parameters
Type Name Description
EntityObject item
| Improve this Doc View Source

OnEntityRemovedEvent(EntityObject)

Declaration
protected virtual void OnEntityRemovedEvent(EntityObject item)
Parameters
Type Name Description
EntityObject item
| Improve this Doc View Source

OnLayerChangedEvent(Layer, Layer)

Declaration
protected virtual Layer OnLayerChangedEvent(Layer oldLayer, Layer newLayer)
Parameters
Type Name Description
Layer oldLayer
Layer newLayer
Returns
Type Description
Layer
| Improve this Doc View Source

Save(String, DxfVersion)

Saves a block to a text DXF file.

Declaration
public bool Save(string file, DxfVersion version)
Parameters
Type Name Description
System.String file

DXF file name.

DxfVersion version

Version of the DXF database version.

Returns
Type Description
System.Boolean

Return true if the file has been successfully save, false otherwise.

| Improve this Doc View Source

Save(String, DxfVersion, Boolean)

Saves a block to a DXF file.

Declaration
public bool Save(string file, DxfVersion version, bool isBinary)
Parameters
Type Name Description
System.String file

DXF file name.

DxfVersion version

Version of the DXF database version.

System.Boolean isBinary

Defines if the file will be saved as binary.

Returns
Type Description
System.Boolean

Return true if the file has been successfully save, false otherwise.

Events

| Improve this Doc View Source

AttributeDefinitionAdded

Declaration
public event Block.AttributeDefinitionAddedEventHandler AttributeDefinitionAdded
Event Type
Type Description
Block.AttributeDefinitionAddedEventHandler
| Improve this Doc View Source

AttributeDefinitionRemoved

Declaration
public event Block.AttributeDefinitionRemovedEventHandler AttributeDefinitionRemoved
Event Type
Type Description
Block.AttributeDefinitionRemovedEventHandler
| Improve this Doc View Source

EntityAdded

Declaration
public event Block.EntityAddedEventHandler EntityAdded
Event Type
Type Description
Block.EntityAddedEventHandler
| Improve this Doc View Source

EntityRemoved

Declaration
public event Block.EntityRemovedEventHandler EntityRemoved
Event Type
Type Description
Block.EntityRemovedEventHandler
| Improve this Doc View Source

LayerChanged

Declaration
public event Block.LayerChangedEventHandler LayerChanged
Event Type
Type Description
Block.LayerChangedEventHandler

Implements

IHasXData
System.ICloneable
System.IComparable
System.IComparable<T>
System.IEquatable<T>
  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX