haplokuon / netDxf

.net dxf Reader-Writer
MIT License
995 stars 405 forks source link

AcDbCircle with extrusion direction #292

Open HaraldHoerst opened 3 years ago

HaraldHoerst commented 3 years ago

Hello Daniel,

I have received two versions of an AcDbCircle Object. When using the Arc.ToPolyline() Function, I get a proper Polyline for the first version. Using the second version, I get a Polyline with negative X coordinates. I must manually multiply them with Arc.Normal.Z to get the correct X Value.

Isn't the Arc.Normal taken into calculation on DxfDocument.Load()

Regards,

Harald Hörst

working version 1:----------- 100 AcDbCircle 10 298505.2428 20 108748.5544 30 0.0 40 1000.0 100 AcDbArc 50 270.0 51 320.5857633 0 ARC 5 31 330 13

failing version 2:-------------- 100 AcDbCircle 10 -298505.2375 20 108748.548 30 0.0 40 1000.0 210 0.0 220 0.0 230 -1.0 100 AcDbArc 50 219.4140517 51 270.1987283 0 LINE 5 25 330 13

haplokuon commented 3 years ago

Do not post pieces of a DXF, I need the whole file, and a way to reproduce what are you doing.

HaraldHoerst commented 3 years ago

Hi,

please find attached the two relevant files: Ver2_ARC_neg_NormalZ.dxf.txt Ver1_ARC_pos_NormalZ.dxf.txt

After loading the files with DxfDocument.Load(Filename), I determine the Coordinates of the Document.Entities.Arcs using the Entity.ToPolyline(NumPoints).Vertexes property. Whereas most other Coordinates are in the positive X range, three ARCS result in negative X range and has to be manually inverted using a negative Normal.Z as criterion.

Maybe it is a more philosophical question, if this inversion should be done on loading or on processing...

haplokuon commented 3 years ago

I do not see any issues converting the arcs in your drawing into LwPolylines. My guess is that you are reading the LwPolyline vertexes as if they were in world coordinates, they are in local/object coordinates, it is in the documentation. In the MathHelper class there are several methods to handle the transformation of vertexes to and from WCS and OCS. Also check the MathHelper method "public static Matrix3 ArbitraryAxis(Vector3 zAxis)".