cad viewer now shows parent dxf attributes as well
@@ -19,6 +19,7 @@ from ezdxf.addons.drawing.properties import is_dark_color
from ezdxf.addons.drawing.pyqt import _get_x_scale, PyQtBackend, CorrespondingDXFEntity, \
CorrespondingDXFEntityStack
from ezdxf.drawing import Drawing
+from ezdxf.entities import DXFGraphic
from ezdxf.lldxf.const import DXFStructureError
@@ -314,18 +315,25 @@ class CadViewer(qw.QMainWindow):
text += 'No data'
else:
text += f'Selected Entity: {dxf_entity}\nLayer: {dxf_entity.dxf.layer}\n\nDXF Attributes:\n'
- for key, value in dxf_entity.dxf.all_existing_dxf_attribs().items():
- text += f'- {key}: {value}\n'
+ text += _entity_attribs_string(dxf_entity)
dxf_entity_stack = element.data(CorrespondingDXFEntityStack)
if dxf_entity_stack:
text += '\nParents:\n'
for entity in reversed(dxf_entity_stack):
text += f'- {entity}\n'
+ text += _entity_attribs_string(entity, indent=' ')
self.selected_info.setPlainText(text)
+def _entity_attribs_string(dxf_entity: DXFGraphic, indent: str = '') -> str:
+ text = ''
+ for key, value in dxf_entity.dxf.all_existing_dxf_attribs().items():
+ text += f'{indent}- {key}: {value}\n'
+ return text
+
+
def _main():
parser = argparse.ArgumentParser()
parser.add_argument('--cad_file')
