Header Section

The drawing settings are stored in the HEADER section, which is accessible by the header attribute of the Drawing object. See the online documentation from Autodesk for available header variables.

See also

DXF Internals: HEADER Section

class ezdxf.sections.header.HeaderSection
custom_vars

Stores the custom drawing properties in a CustomVars object.

__len__() int

Returns count of header variables.

__contains__(key) bool

Returns True if header variable key exist.

varnames() KeysView

Returns an iterable of all header variable names.

get(key: str, default: Any = None) Any

Returns value of header variable key if exist, else the default value.

__getitem__(key: str) Any

Get header variable key by index operator like: drawing.header['$ACADVER']

__setitem__(key: str, value: Any) None

Set header variable key to value by index operator like: drawing.header['$ANGDIR'] = 1

__delitem__(key: str) None

Delete header variable key by index operator like: del drawing.header['$ANGDIR']

reset_wcs()

Reset the current UCS settings to the WCS.

class ezdxf.sections.header.CustomVars

The CustomVars class stores custom properties in the DXF header as $CUSTOMPROPERTYTAG and $CUSTOMPROPERTY values. Custom properties require DXF R2004 or later, ezdxf can create custom properties for older DXF versions as well, but AutoCAD will not show that properties.

properties

A list of custom header properties, stored as string tuples (tag, value). Multiple occurrence of the same custom tag is allowed, but not well supported by the interface. This is a standard Python list and it’s safe to modify this list as long as you just use tuples of strings.

__len__() int

Count of custom properties.

__iter__() Iterator[tuple[str, str]]

Iterate over all custom properties as (tag, value) tuples.

clear() None

Remove all custom properties.

get(tag: str, default: str | None = None)

Returns the value of the first custom property tag.

has_tag(tag: str) bool

Returns True if custom property tag exist.

append(tag: str, value: str) None

Add custom property as (tag, value) tuple.

replace(tag: str, value: str) None

Replaces the value of the first custom property tag by a new value.

Raises DXFValueError if tag does not exist.

remove(tag: str, all: bool = False) None

Removes the first occurrence of custom property tag, removes all occurrences if all is True.

Raises :class:`DXFValueError if tag does not exist.