Replies: 1 comment
-
This doesn't work that way. Copying is much more complicated, because of the required resource management. This script uses the import ezdxf
from ezdxf import xref
path = r"D:/Wechatfile/WeChat Files/wxid_gfwt3ta1c2g622/FileStorage/File/2023-11/B.dxf"
# Read the file where my blocks live
source_doc = ezdxf.readfile(path)
# Create a new DXF document.
target_doc = ezdxf.new(dxfversion=source_doc.dxfversion, units=source_doc.units)
# Load blocks by the xref module
block_loader = xref.Loader(source_doc, target_doc)
# Load blocks by the xref module
block_loader = xref.Loader(source_doc, target_doc)
for block_name in ["BB"]:
block = source_doc.blocks.get(block_name)
block_loader.load_block_layout(block)
# execute import process
block_loader.execute()
msp = target_doc.modelspace()
msp.add_blockref('BB', (0,0))
target_doc.saveas("blockref_tutorial5.dxf") See also docs for: |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I tried to read a block from one dxf file and insert it into another dxf file, but for some reason it kept failing. My code is as follows,which is simple. May I ask why it doesn't work?
Beta Was this translation helpful? Give feedback.
All reactions