-
Notifications
You must be signed in to change notification settings - Fork 400
How to import and merge dxf files without mixing them up? #324
Comments
All named objects, all classes that derive from TableObject, must be unique, there cannot be two with the same name. This is the case of layers, line types, styles,..., and what seems to be the case giving you problems, blocks. Two TableObjects are considered equal if they have the same name, regardless of any other of its internal properties. When you copy an entity into another document, the named objects in the destination document will have preference over the ones on the original drawing, so any duplicates will have to be solved manually if necessary. In your post you are talking about a block named "*U9", that corresponds to a dynamic block. There are three kind of blocks that AutoCad internally creates to handle three kinds of entities. Dimensions are represented by the blocks that starts with "*D", Dynamic Blocks starts with "*U", and tables starts with "*T". From those three only Dimensions are fully supported and they shouldn't give you problems when merging documents, but dynamic blocks and tables are not, any incompatibilities with them will have to be sorted manually. You will have to rename the blocks giving you conflicts, you can use the Clone method that takes a new name as an argument, since internal used blocks cannot be renamed; and with this new block recreate the Insert entities that used that block. From your Questions section:
|
Hi @haplokuon, Thanks for you kindly comprehensive reply! Now I see your suggustion, it should be a better one, but I cannot see any overload of Note, I already tried giving a unique name in |
Now, the internal blocks that start with "*U" or "*T" can be safely renamed. They are internally created to represent dynamic blocks, arrays, and tables; although the information of those objects is lost when importing the DXF, the block that represent its graphical appearance is imported. |
thanks, the block name set is very useful! |
This lib is great and with it I can successfully do read write entity operations.
My goal is to merge multiple dxf files's entities into single one new dxf file, of course each input file's entities should be placed into a seperate location to avoid overlapping.
I couldn't find built in functions to do merge. So after some experiments I came up with such solution:
This code works for most of my dxf files. But a few files got mixed up result.
For example, I have two dxf files:
After merge, I got:
The order of input file also affects the result. I have checked the two files both contain a
INSERT
entity named*U9
, and thouoght it could possibly be the reason but as a beginner of dxf I don't know what to do with it.Questions
ezdxf
and it can import entities without mix up, maybe because it has built in importer. Is there any similar function in netdxf? Of course, there are many benifits to use netdxf than ezdxf.doc.Entities
, so I included latest source instead. Did I used the lib in the wrong way?Environment
The text was updated successfully, but these errors were encountered: