Functions¶
DXF Unicode Decoder¶
The DXF format uses a special form of unicode encoding: “\U+xxxx”.
To avoid a speed penalty such encoded characters are not decoded
automatically by the regular loading function:func:ezdxf.readfile,
only the recover
module does the decoding
automatically, because this loading mode is already slow.
This kind of encoding is most likely used only in older DXF versions, because
since DXF R2007 the whole DXF file is encoded in utf8
and a special unicode
encoding is not necessary.
The ezdxf.has_dxf_unicode()
and ezdxf.decode_dxf_unicode()
are
new support functions to decode unicode characters “\U+xxxx” manually.
- ezdxf.has_dxf_unicode(s: str) bool ¶
Returns
True
if string s contains\U+xxxx
encoded characters.
- ezdxf.decode_dxf_unicode(s: str) str ¶
Decode
\U+xxxx
encoded characters.
Tools¶
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
state –
True
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