def test_default_constructor(): entity = DXFEntity() assert entity.dxftype() == 'DXFENTITY' assert entity.dxf.handle is None assert entity.dxf.owner is None assert entity == entity assert entity != DXFEntity()
def add(self, entity: DXFEntity) -> None: """ Add `entity` to database, assigns a new handle to the `entity` if :attr:`entity.dxf.handle` is ``None``. Adding the same entity multiple times is possible, but creates only a single entry. """ if entity.dxftype() in DATABASE_EXCLUDE: if entity.dxf.handle is not None: # store entities with handles (TABLE, maybe others) to avoid # reassigning of its handle self[entity.dxf.handle] = entity return handle: str = entity.dxf.handle if handle is None: handle = self.next_handle() # update_handle() requires the objects section to update the owner # handle of the extension dictionary, but this is no problem at # file loading, all entities have handles, and DXF R12 (without handles) # have no extension dictionaries. entity.update_handle(handle) self[handle] = entity # add sub entities like ATTRIB, VERTEX and SEQEND to database if isinstance(entity, LinkedEntities): entity.add_sub_entities_to_entitydb(self)
def add(self, entity: DXFEntity) -> None: """ Add `entity` to database, assigns a new handle to the `entity` if :attr:`entity.dxf.handle` is ``None``. """ if entity.dxftype() in DATABASE_EXCLUDE: if entity.dxf.handle is not None: # store entities with handles (TABLE, maybe others) to avoid reassigning of its handle self[entity.dxf.handle] = entity return handle = entity.dxf.handle # type: str if handle is None: handle = self.next_handle() # update_handle() requires the objects section to update the owner handle of the extension dictionary, # but this is no problem at file loading, all entities have handles, and DXF R12 (without handles) have no # extension dictionaries. entity.update_handle(handle) self[handle] = entity # add sub entities like ATTRIB, VERTEX and SEQEND to database # only INSERT and POLYLINE using this feature if hasattr(entity, 'add_sub_entities_to_entitydb'): entity.add_sub_entities_to_entitydb()
def add(self, entity: DXFEntity) -> None: """ Add `entity` to database, assigns a new handle to the `entity` if :attr:`entity.dxf.handle` is ``None``. Adding the same entity multiple times is possible and creates only a single database entry. """ if entity.dxftype() in DATABASE_EXCLUDE: if entity.dxf.handle is not None: # Mark existing entity handle as used to avoid # reassigning the same handle again. self[entity.dxf.handle] = entity return handle: str = entity.dxf.handle if handle is None: handle = self.next_handle() entity.update_handle(handle) self[handle] = entity # Add sub entities ATTRIB, VERTEX and SEQEND to database. if isinstance(entity, LinkedEntities): entity.add_sub_entities_to_entitydb(self)
def match(e: DXFEntity) -> bool: return _match(e.dxftype())