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(entity: Union[str, DXFEntity]) str

Unified table entry key.

has_entry(name: Union[str, DXFEntity]) bool

Returns True if an table entry name exist.

__contains__(name: Union[str, DXFEntity]) bool

Returns True if an table entry name exist.

__len__() int

Count of table entries.

__iter__() Iterable[DXFEntity]

Iterable of all table entries.

new(name: str, dxfattribs: dict = None) DXFEntity

Create a new table entry name.

Parameters
  • name – name of table entry, case insensitive

  • dxfattribs – additional DXF attributes for table entry

get(name: str) DXFEntity

Get table entry name (case insensitive). Raises DXFValueError if table entry does not exist.

remove(name: str) None

Removes table entry name. Raises DXFValueError if table-entry does not exist.

duplicate_entry(name: str, new_name: str) DXFEntity

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

Raises

DXFValueErrorname does not exist

Layer Table

class ezdxf.sections.table.LayerTable

Subclass of Table.

Collection of Layer objects.

add(name: str, *, color: int = 256, true_color: int = None, linetype: str = 'Continuous', lineweight: int = - 1, plot: bool = True, dxfattribs: Dict = 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

  • dxfattribs (dict) – additional DXF attributes

New in version 0.17.

Linetype Table

class ezdxf.sections.table.LineTypeTable

Subclass of Table.

Collection of Linetype objects.

add(name: str, pattern: Union[List[float], str], *, description: str = '', length: float = 0.0, dxfattribs: Dict = 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

New in version 0.17.

Style Table

class ezdxf.sections.table.StyleTable

Subclass of Table.

Collection of Textstyle objects.

add(name: str, *, font: str, dxfattribs: Dict = 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 remember only Windows is case insensitive.

  • dxfattribs (dict) – additional DXF attributes

New in version 0.17.

add_shx(shx_file: str, *, dxfattribs: Dict = 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.

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

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

  • dxfattribs (dict) – additional DXF attributes

New in version 0.17.

get_shx(shx_file: str) Textstyle

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

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

Parameters

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

find_shx(shx_file: str) Optional[Textstyle]

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 (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: Dict = None) DimStyle

Add a new dimension style table entry.

Parameters
  • name (str) – dimension style name

  • dxfattribs (dict) – DXF attributes

New in version 0.17.

AppID Table

class ezdxf.sections.table.AppIDTable

Subclass of Table.

Collection of AppID objects.

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

Add a new appid table entry.

Parameters
  • name (str) – appid name

  • dxfattribs (dict) – DXF attributes

New in version 0.17.

UCS Table

class ezdxf.sections.table.UCSTable

Subclass of Table.

Collection of UCSTableEntry objects.

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

Add a new UCS table entry.

Parameters
  • name (str) – UCS name

  • dxfattribs (dict) – DXF attributes

New in version 0.17.

View Table

class ezdxf.sections.table.ViewTable

Subclass of Table.

Collection of View objects.

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

Add a new view table entry.

Parameters
  • name (str) – view name

  • dxfattribs (dict) – DXF attributes

New in version 0.17.

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: Dict = 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

New in version 0.17.

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: Dict = None) BlockRecord

Add a new block record table entry.

Parameters
  • name (str) – block record name

  • dxfattribs (dict) – DXF attributes

New in version 0.17.