ACadSharp icon indicating copy to clipboard operation
ACadSharp copied to clipboard

Angle Differences DXF & DWG

Open DJGosnell opened this issue 2 years ago • 4 comments

While working on DXF & DWG files in which the content is the same, I've noticed that the DWG reader reads angle values in radians (as documented) I have a branch which shows these differences in MText, TextEntities, Arcs & Ellipses.

TextEntities show degrees on the DXF & Arc start and end angles. All others are radians. I was just going to make a PR, but I thought it would be worth discussing. the DWG documentation rightfully states that the angle values will be in radians but the DXF is a little less explicit by stating "angle" for several types.

netDXF handles this by ensuring all the angles are in degrees, but it seems that most of the angles in the files are actually in radians. Do we want to just convert everything to make sure it's in radians during the reading process?

Angle DXF & DWG written in AutoCAD 2010 formats. angles.zip

A side note is that the MText rotation is not being read by either. I'll open a separate issue for this.

Output of the dwg-dxf-angles branch:

DXF TextEntity Rotation: 45
DWG TextEntity Rotation: 0.7853981633974483
DXF Ellipse StartParameter: 1.020388469764473
DWG Ellipse StartParameter: 1.0203884697644738
DXF Ellipse StartParameter: 1.570796326794896
DWG Ellipse StartParameter: 1.5707963267948966
DXF Arc StartAngle: 45
DWG Arc StartAngle: 0.7853981633974483
DXF Arc EndAngle: 90
DWG Arc EndAngle: 1.5707963267948966
DXF MText Rotation: 0
DWG MText Rotation: 0

image

DJGosnell avatar Dec 08 '22 23:12 DJGosnell

I'll keep them as radians, C# works with them so it's easier to work with System.Math functions if the angles are in radians.

So the work here I think is to modify the reader or the template to set the angles in radians for the DXF files.

DomCR avatar Dec 09 '22 13:12 DomCR

Agreed about radians. I can addressed this, or do you already have this in the works?

DJGosnell avatar Dec 09 '22 14:12 DJGosnell

My priority right now is to finish the first alpha for the DwgWriter I can open a branch dedicated to this issue but I'll not addressed for a while.

DomCR avatar Dec 09 '22 15:12 DomCR

Excellent. I'll issue a PR for this.

DJGosnell avatar Dec 09 '22 15:12 DJGosnell