Low Level Functions

Some handy tool functions used internally by ezdxf.

ezdxf.tools.juliandate(date: datetime) float
ezdxf.tools.calendardate(juliandate: float) datetime
ezdxf.tools.set_flag_state(flags: int, flag: int, state: bool = True) int

Set/clear binary flag in data flags.

Parameters:
  • flags – data value

  • flag – flag to set/clear

  • stateTrue for setting, False for clearing

ezdxf.tools.guid() str

Returns a general unique ID, based on uuid.uuid4().

This function creates a GUID for the header variables $VERSIONGUID and $FINGERPRINTGUID, which matches the AutoCAD pattern {XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}.

ezdxf.tools.bytes_to_hexstr(data: bytes) str

Returns data bytes as plain hex string.

ezdxf.tools.suppress_zeros(s: str, leading: bool = False, trailing: bool = True)

Suppress trailing and/or leading 0 of string s.

Parameters:
  • s – data string

  • leading – suppress leading 0

  • trailing – suppress trailing 0

ezdxf.tools.normalize_text_angle(angle: float, fix_upside_down=True) float

Normalizes text angle to the range from 0 to 360 degrees and fixes upside down text angles.

Parameters:
  • angle – text angle in degrees

  • fix_upside_down – rotate upside down text angle about 180 degree