haplokuon / netDxf

.net dxf Reader-Writer
MIT License
1.01k stars 410 forks source link

Reading MLeaders and OLE objects #444

Closed JankowskiKamil closed 1 year ago

JankowskiKamil commented 1 year ago

Hi! I'm using this code and I was missing the ability to load OleFrame and MLeader objects from dxf file. So I tried to implement it. It's far from perfect, but it allows you to "somehow" load data. In order to implement it I used:

MLeader structure is very hard to understand and its very ugly. I was inspired mainly by the ezdxf code and this page.

Unfortunately, I do not fully understand the entire code and have not found the time to create WriteFunctions / Tests. I hope this code will be useful to someone, or you will be able to improve it :)

JankowskiKamil commented 1 year ago

@haplokuon what do you think about it?

BWangIsYouri commented 1 year ago

@JankowskiKamil @luoyumofa1 好兄弟 好兄弟 妖次元网站挂了 有没有新网站 邮箱回复了没有补链接 有的话回复我Q1219120145 V信同号 邮箱1219120145@qq.com 急需学习资料!!!

haplokuon commented 1 year ago

Since you ask about my opinion. Sorry I am not able to review something that I cannot test and as you said "somehow" works. It is too bare bones, it just looks as a huge container of the raw data stored in the DXF:

  1. There is no way to save the entity.
  2. Class properties that are stored as a generic type and not its actual type, like colors stored as ints and not as an AciColor or styles stored as string handles and not as its table object.
  3. No checks for the validity of the values stored in the properties, possible null or out of range values.
  4. Modifying the classes ICodeValueReader, BinaryCodeValueReader, and TextCodeValueReader when their sole purpose is to write and check the validity of the DXF Code-Value pair. These classes shouldn't know anything about how a particular object is stored in the DXF this is the purpose of the DxfReader.
  5. EntityObjects that holds information on how they are stored in the DXF. I have avoided that at all cost, I do not want them to know how they are saved in a DXF or any other file format for this matter; even if, it requires to create a huge DxfReader and DxfWriter that could be compartmentalized as partial classes.
  6. Where are you reading the MLeaderStyle?
  7. ... If I have to learn first what all those codes in the MLeader and MLeaderStyle do, I would do it myself.

Reading an OLE2Frame or the OLEFrame is pretty straight forward, if all you do is to read the byte data it contains. The OLE2Frame can serve many purposes, OLE objects has been around since the dawn of Windows, they are complex and I have no plans of studying its guts. I only have found them useful to be able to embed an Image instead of externally linking it as an Image entity. If there is someone who has use them for something else please let me know.