Community
AutoCAD Forum
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to find whether an arc is clockwise or counter-clockwise in DXF file?

14 REPLIES 14
SOLVED
Reply
Message 1 of 15
Anonymous
7984 Views, 14 Replies

How to find whether an arc is clockwise or counter-clockwise in DXF file?

As you all know DXF file can be opened in text viewer also. In that, ENTITIES section consists of details about the drawing. In particular I want information about the entity ARC. If an arc is drawn in the AutoCAD its data will be generated in DXF file which will be in text format. But it consists of ARC radius, centre points, start angle and end angles. It does not give whether the arc is clockwise or counter-clockwise. How to determine it please somebody help me. I have attached a screenshot also.

 

-Vinay

14 REPLIES 14
Message 2 of 15
imadHabash
in reply to: Anonymous

HI,

 

i just want to remind that in AutoCAD Arcs are drawn in a counterclockwise direction by default. and by holding down the Ctrl key as you drag to draw in a clockwise direction. hope that help . 

 

Regards,




Message 3 of 15
tramber
in reply to: Anonymous

The way it is drawn doesn't matter.

Forever, the arc is written in mathematical direction (counterclockwise) in any DXF file.

The only way to know would be to know the previous attached (point to point) line or object in the database.

Maybe a use of polyline instead of arc and lines (I guess)

Sorry for you

Message 4 of 15
Kent1Cooper
in reply to: Anonymous

All Arcs are counterclockwise.  It doesn't matter in which direction or under which options it was drawn -- the data for it is always stored with the curve of it progressing counterclockwise from the stored start angle to the end angle.

Kent Cooper, AIA
Message 5 of 15
leeminardi
in reply to: Kent1Cooper

I'd like to add that DXF does not store how the arc was drawn.  It stores just enough information to recreate the arc.  For example, if you drew an arc using 3 points along its circumference in either  clockwise or counterclockwise direction, DXF will not store the 3 points you used but will store the 3D center point of the arc and its radius.  If the arc lies on the XY plane then the normal vector will assumed to be 0,0,1.  If the arc does not lie parallel to the XY plane then the normal vector will be include (DXF codes 210, 220, 230) and the x axis used for measuring the angle will be defined via the rules of the arbitrary axis algortithm.  https://www.autodesk.com/techpubs/autocad/acadr14/dxf/arbitrary_axis_algorithm_al_u05_c.htm

lee.minardi
Message 6 of 15
BeKirra
in reply to: Anonymous

It is interesting.

IMO the following is a true statement:

Arcs are drawn in a counterclockwise direction in AutoCAD by default.

 

However if checking an existing arc I found something different. Here is my experiment.

 

I drawn an arc starting at lower-right corner and ending at upper-left corner in 1st quadrant on "X-Y" plane.

Then use "3drotate" command rotate it 180 degrees by selecting "Y" axis as rotation axis.

Now the arc is in 2nd quadrant.

When I use "pEdit" command to check the vertexes of the arc (actually it is converted to a polyline segment), I found the arc now is in clockwise direction.

 

Here is the DFX data.

 

- - - - - - - - - - - - - - - -

Arc in 1st quadrant

 

ARC
  5
8D28
330
1E
100
AcDbEntity
  8
0
100
AcDbCircle
 10
684.0251252695512
 20
201.2135767275527
 30
0.0
 40
190.9610975440021
100
AcDbArc
 50
11.72219891656158
 51
83.73151582609727
  0

 

- - - - - - - - - - - - - - - -

Arc in 2nd quadrant before using "pEdit"

 

ARC
  5
8D28
330
1E
100
AcDbEntity
  8
0
100
AcDbCircle
 10
-684.0251252695512
 20
201.2135767275527
 30
-0.0000000000001264
 40
190.9610975440021
210
-0.0000000000000001
220
-0.0000000000000004
230
-1.0
100
AcDbArc
 50
11.72219891656071
 51
83.73151582609114
  0

- - - - - - - - - - - - - - - -

 

It is also noticeable that start angle and end angle of 2 arcs are about the same shown above.

The group codes of extrusion direction "210", "220" and "230" are only shown in data of the 2nd quadrant arc. This may verify a clockwise arc.

Please mark "Accept as Solution" and "Like" if my reply resolves the issue and it will help when others need helps.
= ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ =
A circle is the locus of a cursor, starting and ending at the same point on a plane in model space or in layout such that its distance from a given coordinates (X,Y) is always constant.
X² + Y² = C²
Message 7 of 15
leeminardi
in reply to: BeKirra

@BeKirra states "IMO the following is a true statement:

Arcs are drawn in a counterclockwise direction in AutoCAD by default.

 

However if checking an existing arc I found something different. Here is my experiment...."

 

It is true that AutoCAD draws arcs in a counterclockwise direction but it could appear to a user that it is clockwise if the user is looking at the arc from the opposite direction!  AutoCAD uses a right hand rule for defining arc direction.  That is, if the thumb of your right hand points it the positive direction of the arc's z axis (its normal vector), the curled fingers of the right hand define the positive arc angle direction.  Thus if you are looking a the top view and the arc lies on the XY plane, the z direction is point to you and positive angles are measure in a CCW direction.  However, if you were to look at the same arc from the bottom view the Z axis is now pointing away from you and clockwise becomes the apparent positive direction although the arcs true angle direction is CCW when looking down (in the opposite direction) of the normal vector.

 

In your example, the second arc has a normal pointing in the negative Z direction as indicated by the DXF codes 210, 220, 230 which are 0,0,-1.  The angles are the same as the first arc (DXF codes 50 and 51) because the arc's angles still use a positive counter clockwise direction  but you are viewing it from the opposite direction.

 

The right hand rule is necessary to maintain a consistency for arcs that can freely rotated in 3D. 

 

lee.minardi
Message 8 of 15
Kent1Cooper
in reply to: BeKirra


@BeKirra wrote:

 

....

Arcs are drawn in a counterclockwise direction in AutoCAD by default.

.... 

I drawn an arc starting at lower-right corner and ending at upper-left corner in 1st quadrant on "X-Y" plane.

... "3drotate" ... 180 degrees ... "Y" axis as rotation axis.

Now the arc is in 2nd quadrant.

When I use "pEdit" command to check the vertexes of the arc (actually it is converted to a polyline segment), I found the arc now is in clockwise direction.

 

....

Arc in 2nd quadrant before using "pEdit"

....
210
-0.0000000000000001
220
-0.0000000000000004
230
-1.0

....

The group codes of extrusion direction "210", "220" and "230" are only shown in data of the 2nd quadrant arc. This may verify a clockwise arc.


I would word that first sentence quoted above differently -- the information about them is always stored as though  they were drawn counterclockwise, but they can be drawn  clockwise in several ways, at least in terms of the process of defining their geometry in a drawing.

 

The Polyline equivalent/conversion may "look" clockwise from your  point of view [assuming you haven't changed that since you drew the initial Arc], but not from its own.  Note the  -1.0  Z coordinate [code 230] of the extrusion direction for the second Arc -- that's downward.  Looking from "your" underneath  [which is its own point of view because of that extrusion direction], it's still counterclockwise.  The 210/220/230 codes are present only for the second one because when they are not  present, the extrusion direction is 0,0,(+)1 -- see the DXF Reference for an Arc and note the "optional" under codes 210/220/230 and the description under 210 that 0,0,1 is assumed if not present.

Kent Cooper, AIA
Message 9 of 15
Anonymous
in reply to: BeKirra

Thank you for your response. Actually what you have sais is correct. But group codes 210,220 and 230 are optional as per the DXF reference manual. It may be present or may not be present. I got another method to find out whether it is clockwise or anti-clockwise. At first you have to calculate bulge of the arc. It is nothing but the amount of curvature. if you got it as negative then arc is clockwise if it is positive then it is anti-clockwise. If it is a Poly Line ARC then DXF file itself will give you the value of the bulge. If it is a normal ARC that you have drawn then you need to calculate the value of the bulge using the formula. You can find the explanation and related formulae  in the below link.

http://www.afralisp.net/archive/lisp/Bulges1.htm

 

 

Thank You

-Vinay

Message 10 of 15
Kent1Cooper
in reply to: Anonymous


@Anonymous wrote:

.... But group codes 210,220 and 230 are optional as per the DXF reference manual. It may be present or may not be present

  ::: KC -- And if they are  not present, then the extrusion direction  is 0,0,1 -- their absence doesn't leave anything indeterminate.

I got another method to find out whether it is clockwise or anti-clockwise. .... If it is a normal ARC that you have drawn then you need to calculate the value of the bulge using the formula.

  ::: KC -- If it is a normal Arc, its direction is counterclockwise, always -- there is no other possibility.  If you want to know whether it's clockwise  from the perspective of the World Coordinate System, as in your example after 3DRotating one, you don't need to calculate anything.  Just look at its entity data --

(entget (car (entsel "\nSelect the Arc: ")))

will return a list that includes (210 0.0 0.0 -1.0) with the negative Z component.  But from its own point of view, it's still counterclockwise.

 

....

 

Kent Cooper, AIA
Message 11 of 15
BeKirra
in reply to: leeminardi


@leeminardi wrote:

...

However, if you were to look at the same arc from the bottom view the Z axis is now pointing away from you and clockwise becomes the apparent positive direction although the arcs true angle direction is CCW when looking down (in the opposite direction) of the normal vector.

...

The right hand rule

...


I know what you mean. However you probably misunderstood my reply to OP.

 

Let me restate OP's question:

"How to find whether an arc is clockwise or counter-clockwise in DXF file?"

There are 2 categories of arc in this question.

1. arc that user newly drawn

2. arc which is existing.

I focused on the latter and the example given in my post #6 is a situation that user may experience.

 

HTH

Please mark "Accept as Solution" and "Like" if my reply resolves the issue and it will help when others need helps.
= ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ =
A circle is the locus of a cursor, starting and ending at the same point on a plane in model space or in layout such that its distance from a given coordinates (X,Y) is always constant.
X² + Y² = C²
Message 12 of 15
BeKirra
in reply to: Anonymous

In my example, the only purpose that using "pEdit" on the drawing is to find 1st and 2nd vertex on the "arc", both in original position and rotated position.

And thanks for the link.

Please mark "Accept as Solution" and "Like" if my reply resolves the issue and it will help when others need helps.
= ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ =
A circle is the locus of a cursor, starting and ending at the same point on a plane in model space or in layout such that its distance from a given coordinates (X,Y) is always constant.
X² + Y² = C²
Message 13 of 15
Anonymous
in reply to: Kent1Cooper

I agree with you. But one does draw the arc in clockwise direction then what will be the situation? If I draw the arc in clockwise direction also group code did not appear in the DXF file. It may appear if you draw the arc using AutoCAD. But if you draw the arc using other software like AutoCAD then it will not appear for clockwise direction also. Since I am developing a software to read the DXF file and display the drawing I have to consider both clockwise and anti-clockwise. One other thing, I am considering only 2D drawings and not 3D drawings.

Message 14 of 15
cadffmx
in reply to: Anonymous

@Anonymous

 

Once again: Any software can write and interpret (read) DXF data as it pleases.
(if you only read in your own data and you never share these files with others/other software, you can also give an object CIRCLE the look like a rectangle and the definition of a polyline)
That's your thing - but not useful.

But there is only one "correct" definition for the DXF (per version) and that comes from the company AutoDesk.
These should be used as a benchmark, everyone should do so, and thus the probability of success
is the highest in terms of trouble-free data exchange.

DXF is not documented to 100% but for these simple things it is more than enought.


"But one does draw the arc in clockwise direction then what will be the situation? "
You can draw an ARC (in a Coordinatesystem parallel to WCS / with the same direction)
in all kind you want. Left to right from roof to bottom, the DXF-definition is
to store the ARC-data anti/counter-clockwise.

"If I draw the arc in clockwise direction also group code did not appear in the DXF file."
Because you don't understand coordinatesystems / what the normal vector is (210,220,230) ? http://mathworld.wolfram.com/NormalVector.html

 


"Since I am developing a software to read the DXF file and display"
"the drawing I have to consider both clockwise and anti-clockwise."
For WRITING a DXF (blank ascii text, without an DXF-wrapper/programming interface) you have to consider both,
because you have to calculate the User-input data for the ARC to counterclockwise informations for writing to the DXF file.
If you write DXF ARC-Data in clockwise order, the ARC appears in other Software wrong, because all well DXF-import interfaces assume that the data is counterclockwise.


"One other thing, I am considering only 2D drawings and not 3D drawings."
It is possible, perfect and simple for you, BUT if you import a DXF which is not wrote by your program, you have to consider the 3.dimension

and so you have consider the normal 210,220,230 by import DXF-Datas too.

It is what it is.

Sebastian

EESignature

Message 15 of 15
Kent1Cooper
in reply to: Anonymous


@Anonymous wrote:

.... one does draw the arc in clockwise direction then what will be the situation?.....


The situation will be the same as if it were drawn in some other way -- that the entity data stored about that Arc  will be a center point, a radius, starting and ending angles from the center to the ends, always  with the "start" and "end" defined as proceeding in a counterclockwise direction, and an extrusion direction [and Layer, and other properties that all entity types share].  How the Arc was drawn  is completely irrelevant after  it has been drawn.  And consider this:  what if you drew a Circle, and then used Trim or Break to remove part of it?  The resulting Arc wasn't drawn as an Arc, so how could one say in which "direction" it was drawn?  But its entity data will be stored in the same way.

Kent Cooper, AIA

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Customer Advisory Groups