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
-
static
Layer Table¶
-
class
ezdxf.sections.table.
LayerTable
¶ Subclass of
Table
.Collection of
Layer
objects.-
add
(name: str, *, color: int = 256, true_color: Optional[int] = None, linetype: str = 'Continuous', lineweight: int = -1, plot: bool = True, transparency: Optional[float] = None, dxfattribs=None) → ezdxf.entities.layer.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 createint
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: Union[Sequence[float], str], *, description: str = '', length: float = 0.0, dxfattribs=None) → ezdxf.entities.ltype.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) → ezdxf.entities.textstyle.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) → ezdxf.entities.textstyle.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) → ezdxf.entities.textstyle.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) → Optional[ezdxf.entities.textstyle.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_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¶
AppID Table¶
UCS Table¶
-
class
ezdxf.sections.table.
UCSTable
¶ Subclass of
Table
.Collection of
UCSTableEntry
objects.-
add
(name: str, *, dxfattribs=None) → ezdxf.entities.ucs.UCSTableEntry¶ Add a new UCS table entry.
Parameters: - name (str) – UCS name
- dxfattribs (dict) – DXF attributes
-
View Table¶
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()
raisesNotImplementedError
-
add
(name: str, *, dxfattribs=None) → ezdxf.entities.vport.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
-
Block Record Table¶
-
class
ezdxf.sections.table.
BlockRecordTable
¶ Subclass of
Table
.Collection of
BlockRecord
objects.-
add
(name: str, *, dxfattribs=None) → ezdxf.entities.blockrecord.BlockRecord¶ Add a new block record table entry.
Parameters: - name (str) – block record name
- dxfattribs (dict) – DXF attributes
-