Lisp/README.md als Doku der LispFunktionen erneuert. set_attr.py baut jetzt einen einzigen Block der alle Geometrie und die Attribute enthält.

This commit is contained in:
2026-06-12 17:25:22 +02:00
parent 7a13171714
commit 2f583a96cb
3 changed files with 230 additions and 57 deletions
+6 -5
View File
@@ -222,11 +222,12 @@ def import_element_as_block(source_doc, target_doc, block_name):
importer = Importer(source_doc, target_doc)
importer.import_tables()
blk = target_doc.blocks.new(name=block_name)
if block_name in source_doc.blocks:
source_layout = source_doc.blocks[block_name]
else:
source_layout = source_doc.modelspace()
for entity in source_layout:
# if block_name in source_doc.blocks:
# source_layout = source_doc.blocks[block_name]
# else:
# source_layout = source_doc.modelspace()
# for entity in source_layout:
for entity in source_doc.modelspace():
importer.import_entity(entity, blk)
importer.finalize()
return block_name
+19 -2
View File
@@ -160,7 +160,11 @@ ATTDEF_LAYER = "ATTRIB"
def wrap_entities_in_block(doc, block_name):
"""
Verschiebt alle Entities aus dem Modelspace in eine Blockdefinition
mit dem Namen block_name und fuegt eine Blockreferenz bei (0, 0) ein.
mit dem Namen block_name.
Im Modelspace wird ein INSERT erzeugt, dem ATTRIB-Entities hinzugefuegt
werden - mit den Standardwerten aus den ATTDEFs der Blockdefinition.
Dadurch zeigt BricsCAD beim Klick auf den Block die Attributwerte an.
Vorhandene Blockdefinition mit gleichem Namen wird ersetzt (fuer Re-Runs).
"""
msp = doc.modelspace()
@@ -174,7 +178,20 @@ def wrap_entities_in_block(doc, block_name):
for entity in list(msp):
msp.move_to_layout(entity, blk)
msp.add_blockref(block_name, (0, 0))
# INSERT im Modelspace
blkref = msp.add_blockref(block_name, (0, 0))
# ATTRIB-Entities aus ATTDEFs befuellen (Werte aus ATTDEF-Standardtext)
for attdef in (e for e in blk if e.dxftype() == "ATTDEF"):
blkref.add_attrib(
tag=attdef.dxf.tag,
text=attdef.dxf.text,
insert=attdef.dxf.insert,
dxfattribs={
"layer": attdef.dxf.layer,
"height": attdef.dxf.height,
},
)
def add_attdefs_to_dxf(dxf_path, output_path, attr_defs, json_entry, sivasnr,