def add_shx(self, shx_file: str, *, dxfattribs: Dict = None) -> "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 :class:`DXFTableEntryError` exception will be raised. Finding the SHX files is the task of the DXF viewer and each viewer is different (hint: support files). Args: shx_file (str): shape file name like "gdt.shx" dxfattribs (dict): additional DXF attributes .. versionadded:: 0.17 """ if self.find_shx(shx_file) is not None: raise const.DXFTableEntryError( f"{self._head.dxf.name} shape file entry for " f"'{shx_file}' already exists!" ) dxfattribs = dict(dxfattribs or {}) dxfattribs.update( { "name": "", # shape file entry has no name "flags": 1, # shape file flag "font": shx_file, "last_height": 2.5, # maybe required by AutoCAD } ) return self.new_entry(dxfattribs)
def get_config(self, name: str) -> List['DXFEntity']: """ Returns a list of :class:`~ezdxf.entities.Viewport` objects, for the multi-viewport configuration `name`. """ try: return self.entries[self.key(name)] except KeyError: raise const.DXFTableEntryError(name)
def get(self, name: str) -> 'DXFEntity': """ Get table entry `name` (case insensitive). Raises :class:`DXFValueError` if table entry does not exist. """ key = self.key(name) entry = self.entries.get(key, None) if entry: return entry else: raise const.DXFTableEntryError(name)
def add_entry(self, entry: 'DXFEntity') -> None: """ Add a table `entry`, created by other object than this table. (internal API) """ if entry.dxftype() != self._head.dxf.name: raise const.DXFTypeError( f'Invalid table entry type {entry.dxftype()} ' f'for table {self.name}') name = entry.dxf.name if self.has_entry(name): raise const.DXFTableEntryError( f'{self._head.dxf.name} {name} already exists!') entry.doc = self.doc entry.owner = self._head.dxf.handle self._append(entry)
def new(self, name: str, dxfattribs: dict = None) -> 'DXFEntity': """ Create a new table entry `name`. Args: name: name of table entry, case insensitive dxfattribs: additional DXF attributes for table entry """ if self.has_entry(name): raise const.DXFTableEntryError( f'{self._head.dxf.name} {name} already exists!') dxfattribs = dxfattribs or {} dxfattribs['name'] = name dxfattribs['owner'] = self._head.dxf.handle return self.new_entry(dxfattribs)
def new(self, name: str, dxfattribs: dict = None) -> T: """Create a new table entry `name`. Args: name: name of table entry, case insensitive dxfattribs: additional DXF attributes for table entry """ if self.has_entry(name): raise const.DXFTableEntryError( f"{self.TABLE_TYPE} '{name}' already exists!" ) dxfattribs = dxfattribs or {} dxfattribs["name"] = name dxfattribs["owner"] = self._head.dxf.handle return self.new_entry(dxfattribs)
def add_entry(self, entry: T) -> None: """Add a table `entry`, created by other object than this table. (internal API) """ if entry.dxftype() != self.TABLE_TYPE: raise const.DXFTypeError( f"Invalid table entry type {entry.dxftype()} " f"for table {self.TABLE_TYPE}" ) name = entry.dxf.name if self.has_entry(name): raise const.DXFTableEntryError( f"{self._head.dxf.name} {name} already exists!" ) entry.doc = self.doc entry.dxf.owner = self._head.dxf.handle self._append(entry)