haplokuon / netDxf

.net dxf Reader-Writer
MIT License
986 stars 400 forks source link

Vertices coordinates in UCS (not WCS) #334

Open pmorshed opened 2 years ago

pmorshed commented 2 years ago

I have a dxf file that WCS and UCS* are not in the same position/direction. So, how can in get vertices coordinates of entity in UCS (user coordinate system) of DXF file?

*UCS is unnamed unnamed ucs

haplokuon commented 2 years ago

If you need to convert WCS coordinates to UCS you will have to do it manually. It has been a long time since I look into the UCS table, and I may add, in a future update, some kind of Transform method for the UCS object to convert coordinates.

pmorshed commented 2 years ago

But UCS table needs "name" for finding a ucs. what about "unnamed" ucs?!

haplokuon commented 2 years ago

If you are looking for the current UCS (the last UCS when the drawing was saved) the basic information is stored in the DrawingVariables.

DxfDocument doc = DxfDocument.Load("Drawing1.dxf");
Vector3 ucsOrigen = doc.DrawingVariables.UcsOrg;
Vector3 ucsXDir = doc.DrawingVariables.UcsXDir;
Vector3 ucsYDir = doc.DrawingVariables.UcsYDir;

With that information you will have to manually build your transformation matrix to convert your coordinates from WCS to UCS or vice versa.

pmorshed commented 2 years ago

Thanks so much