Application Settings

This is a high-level module for working with CAD application settings and behaviors. None of these settings have any influence on the behavior of ezdxf, since ezdxf only takes care of the content of the DXF file and not of the way it is presented to the user.


You need to understand that these settings work at the application level, ezdxf cannot force an application to do something in a certain way! The functionality of this module has been tested with Autodesk TrueView and BricsCAD, other applications may show different results or ignore the settings.

Set Current Properties

The current properties are used by the CAD application to create new entities, these settings do not affect how ezdxf creates new entities.

The module ezdxf.gfxattribs provides the class GfxAttribs(), which can load the current graphical entity settings from the HEADER section for creating new entities by ezdxf: load_from_header()

ezdxf.appsettings.set_current_layer(doc: Drawing, name: str)

Set current layer.

ezdxf.appsettings.set_current_color(doc: Drawing, color: int)

Set current AutoCAD Color Index (ACI).

ezdxf.appsettings.set_current_linetype(doc: Drawing, name: str)

Set current linetype.

ezdxf.appsettings.set_current_lineweight(doc: Drawing, lineweight: int)

Set current lineweight, see Lineweights reference for valid values.

ezdxf.appsettings.set_current_linetype_scale(doc: Drawing, scale: float)

Set current linetype scale.

ezdxf.appsettings.set_current_textstyle(doc: Drawing, name: str)

Set current text style.

ezdxf.appsettings.set_current_dimstyle(doc: Drawing, name: str)

Set current dimstyle.

ezdxf.appsettings.set_current_dimstyle_attribs(doc: Drawing, name: str)

Set current dimstyle and copy all dimstyle attributes to the HEADER section.

ezdxf.appsettings.set_lineweight_display_style(doc: Drawing, end_caps: EndCaps, join_style: JoinStyle) None

Set the style of end caps and joints for linear entities when displaying line weights. These settings only affect objects created afterwards.

Restore the WCS

ezdxf.appsettings.restore_wcs(doc: Drawing)

Restore the UCS settings in the HEADER section to the WCS and reset all active viewports to the WCS.

Update Extents

ezdxf.appsettings.update_extents(doc: Drawing) BoundingBox

Calculate the extents of the model space, update the HEADER variables $EXTMIN and $EXTMAX and returns the result as ezdxf.math.BoundingBox. Note that this function uses the ezdxf.bbox module to calculate the extent of the model space. This module is not very fast and not very accurate for text and ignores all ACIS based entities.

The function updates only the values in the HEADER section, to zoom the active viewport to this extents, use this recipe:

import ezdxf
from ezdxf import zoom, appsettings

doc = ezdxf.readfile("your.dxf")
extents = appsettings.update_extents(doc),, extents.size)

See also

  • the ezdxf.bbox module to understand the limitations of the extent calculation

  • the ezdxf.zoom module

Show Lineweight

ezdxf.appsettings.show_lineweight(doc: Drawing, state=True) None

The CAD application or DXF viewer should show lines and curves with “thickness” (lineweight) if state is True.