Replies: 3 comments 1 reply
-
The DIMENSION entity doesn't work that way! I don't know where to start to explain the problem and I don't have the time now. I will come back in a few days to give more information about this topic. |
Beta Was this translation helpful? Give feedback.
-
The The content of that block is what a CAD application displays. This is the reason why editing the attributes of an exiting import ezdxf
from ezdxf.document import Drawing
def update_block(doc: Drawing, block_name: str, value: str):
block = doc.blocks.get(block_name)
if block is None:
return
mtext = block.query("MTEXT").first
if mtext is not None:
mtext.dxf.text = value
def main():
doc = ezdxf.readfile("dim.dxf") # see attached zip-file
msp = doc.modelspace()
# Just modifying the text doesn't anything
dim_linear = msp.query("DIMENSION").first
assert dim_linear is not None
dim_linear.dxf.text = "200"
dim_arc = msp.query("ARC_DIMENSION").first
assert dim_arc is not None
dim_arc.dxf.text = "90"
doc.saveas("dim0.dxf")
# Edit the MTEXT content of the associated BLOCK
update_block(doc, dim_linear.dxf.geometry, "200")
update_block(doc, dim_arc.dxf.geometry, "90")
doc.saveas("dim1.dxf")
if __name__ == '__main__':
main() Original
|
Beta Was this translation helpful? Give feedback.
-
I hava a new questhion, I add some text in DIMENSION . For example ,when I add text "test" in autoCAD, the data shown 'test <>' I try update it , but it can't Normal display update_block(doc, dim_linear.dxf.geometry, "200 <>") I'm not sure if there's a way to do this,let it Normal display in autoCAD |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
my code:
import ezdxf
f = 'Before Modification.dxf'
doc = ezdxf.readfile(f)
msp =doc.modelspace()
for e in msp:
if e.dxftype() in ("DIMENSION", "ARC_DIMENSION", "LARGE_RADIAL_DIMENSION"):
e.dxf.text = '6666'
doc.saveas('Modification After.dxf')
————————————————
Hello,I want to modify DIMENSION’s text,when I open new file in autoCAD,The texts is still Before Modification。
As shown below, only one , at bottom left corner is changed.
Modification Before


Modification After
files:
dxf.zip
Beta Was this translation helpful? Give feedback.
All reactions