Table Classes

Generic Table Class

class ezdxf.sections.table.Table

Generic collection of table entries. Table entry names are case insensitive: “Test” == “TEST”.

static key(name: str) str

Unified table entry key.

has_entry(name: str) bool

Returns True if a table entry name exist.

__contains__(name: str) bool

Returns True if a table entry name exist.

__len__() int

Count of table entries.

__iter__() Iterator[T]

Iterable of all table entries.

new(name: str, dxfattribs=None) T

Create a new table entry name.

Parameters:
  • name – name of table entry

  • dxfattribs – additional DXF attributes for table entry

get(name: str) T

Returns table entry name.

Parameters:

name – name of table entry, case-insensitive

Raises:

DXFTableEntryError – table entry does not exist

remove(name: str) None

Removes table entry name.

Parameters:

name – name of table entry, case-insensitive

Raises:

DXFTableEntryError – table entry does not exist

duplicate_entry(name: str, new_name: str) T

Returns a new table entry new_name as copy of name, replaces entry new_name if already exist.

Parameters:
  • name – name of table entry, case-insensitive

  • new_name – name of duplicated table entry

Raises:

DXFTableEntryError – table entry does not exist

Layer Table

class ezdxf.sections.table.LayerTable

Subclass of Table.

Collection of Layer objects.

add(name: str, *, color: int = const.BYLAYER, true_color: int | None = None, linetype: str = 'Continuous', lineweight: int = const.LINEWEIGHT_BYLAYER, plot: bool = True, transparency: float | None = None, dxfattribs=None) Layer

Add a new Layer.

Parameters:
  • name (str) – layer name

  • color (int) – AutoCAD Color Index (ACI) value, default is BYLAYER

  • true_color (int) – true color value, use ezdxf.rgb2int() to create int values from RGB values

  • linetype (str) – line type name, default is “Continuous”

  • lineweight (int) – line weight, default is BYLAYER

  • plot (bool) – plot layer as bool, default is True

  • transparency – transparency value in the range [0, 1], where 1 is 100% transparent and 0 is opaque

  • dxfattribs (dict) – additional DXF attributes

Linetype Table

class ezdxf.sections.table.LinetypeTable

Subclass of Table.

Collection of Linetype objects.

add(name: str, pattern: Sequence[float] | str, *, description: str = '', length: float = 0.0, dxfattribs=None) Linetype

Add a new line type entry. The simple line type pattern is a list of floats [total_pattern_length, elem1, elem2, ...] where an element > 0 is a line, an element < 0 is a gap and an element == 0.0 is a dot. The definition for complex line types are strings, like: 'A,.5,-.2,["GAS",STANDARD,S=.1,U=0.0,X=-0.1,Y=-.05],-.25' similar to the line type definitions stored in the line definition .lin files, for more information see the tutorial about complex line types. Be aware that not many CAD applications and DXF viewers support complex linetypes.

Parameters:
  • name (str) – line type name

  • pattern – line type pattern as list of floats or as a string

  • description (str) – line type description, optional

  • length (float) – total pattern length, only for complex line types required

  • dxfattribs (dict) – additional DXF attributes

Style Table

class ezdxf.sections.table.TextstyleTable

Subclass of Table.

Collection of Textstyle objects.

add(name: str, *, font: str, dxfattribs=None) Textstyle

Add a new text style entry for TTF fonts. The entry must not yet exist, otherwise an DXFTableEntryError exception will be raised.

Finding the TTF font files is the task of the DXF viewer and each viewer is different (hint: support files).

Parameters:
  • name (str) – text style name

  • font (str) – TTF font file name like “Arial.ttf”, the real font file name from the file system is required and only the Windows filesystem is case-insensitive.

  • dxfattribs (dict) – additional DXF attributes

add_shx(shx_file_name: str, *, dxfattribs=None) Textstyle

Add a new shape font (SHX file) entry. These are special text style entries and have no name. The entry must not yet exist, otherwise an DXFTableEntryError exception will be raised.

Locating the SHX files in the filesystem is the task of the DXF viewer and each viewer is different (hint: support files).

Parameters:
  • shx_file_name (str) – shape file name like “gdt.shx”

  • dxfattribs (dict) – additional DXF attributes

get_shx(shx_file_name: str) Textstyle

Get existing entry for a shape file (SHX file), or create a new entry.

Locating the SHX files in the filesystem is the task of the DXF viewer and each viewer is different (hint: support files).

Parameters:

shx_file_name (str) – shape file name like “gdt.shx”

find_shx(shx_file_name: str) Textstyle | None

Find the shape file (SHX file) text style table entry, by a case-insensitive search.

A shape file table entry has no name, so you have to search by the font attribute.

Parameters:

shx_file_name (str) – shape file name like “gdt.shx”

discard_shx(shx_file_name: str) None

Discard the shape file (SHX file) text style table entry. Does not raise an exception if the entry does not exist.

Parameters:

shx_file_name (str) – shape file name like “gdt.shx”

DimStyle Table

class ezdxf.sections.table.DimStyleTable

Subclass of Table.

Collection of DimStyle objects.

add(name: str, *, dxfattribs=None) DimStyle

Add a new dimension style table entry.

Parameters:
  • name (str) – dimension style name

  • dxfattribs (dict) – DXF attributes

AppID Table

class ezdxf.sections.table.AppIDTable

Subclass of Table.

Collection of AppID objects.

add(name: str, *, dxfattribs=None) AppID

Add a new appid table entry.

Parameters:
  • name (str) – appid name

  • dxfattribs (dict) – DXF attributes

UCS Table

class ezdxf.sections.table.UCSTable

Subclass of Table.

Collection of UCSTableEntry objects.

add(name: str, *, dxfattribs=None) UCSTableEntry

Add a new UCS table entry.

Parameters:
  • name (str) – UCS name

  • dxfattribs (dict) – DXF attributes

View Table

class ezdxf.sections.table.ViewTable

Subclass of Table.

Collection of View objects.

add(name: str, *, dxfattribs=None) View

Add a new view table entry.

Parameters:
  • name (str) – view name

  • dxfattribs (dict) – DXF attributes

Viewport Table

class ezdxf.sections.table.ViewportTable

The viewport table stores the modelspace viewport configurations. A viewport configuration is a tiled view of multiple viewports or just one viewport. In contrast to other tables the viewport table can have multiple entries with the same name, because all viewport entries of a multi-viewport configuration are having the same name - the viewport configuration name.

The name of the actual displayed viewport configuration is “*ACTIVE”.

Duplication of table entries is not supported: duplicate_entry() raises NotImplementedError

add(name: str, *, dxfattribs=None) VPort

Add a new modelspace viewport entry. A modelspace viewport configuration can consist of multiple viewport entries with the same name.

Parameters:
  • name (str) – viewport name, multiple entries possible

  • dxfattribs (dict) – additional DXF attributes

get_config(self, name: str) List[VPort]

Returns a list of VPort objects, for the multi-viewport configuration name.

delete_config(name: str) None

Delete all VPort objects of the multi-viewport configuration name.

Block Record Table

class ezdxf.sections.table.BlockRecordTable

Subclass of Table.

Collection of BlockRecord objects.

add(name: str, *, dxfattribs=None) BlockRecord

Add a new block record table entry.

Parameters:
  • name (str) – block record name

  • dxfattribs (dict) – DXF attributes