Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dxf format for drawing arcs

Status
Not open for further replies.

GPerk

Programmer
Jul 6, 2002
161
US
I have written a VB6 program to read and plot dxf files.
However, I have a problem with interpreting the format for an ARC. For example:
An arc is given in a dxf file as having these properties:
X=3, Y=11, Radius=0.25, start angle = 83 degrees, end angle = 175 degrees.
$ANGBASE is set to 0.0, meaning 0 degrees is to the east or right.
$ANGDIR is set to 0, meaning drawing is counter-clockwise.
(These 2 items are set to match Microsoft's drawing convention.)

All this indicates that this arc should start at the top of the circle and draw down and to the left, i.e., in the upper-LEFT quadrant.
But when this file is run through AutoCAD it is drawn in the upper-RIGHT quadrant.
Another arc has startangle = -6, endangle = 89 which seems to me it should be in the upper-RIGHT quadrant, but AutoCad puts it in the upper-LEFT quadrant.

Can anyone explain where I am misinterpreting the specifications?
Or am I missing some other preset variable, similar to $ANGDIR?
 
I would have thought angles in a dxf file would be in radians, between 0 and 2pi. I assume you converted to degrees for your examples - are you sure of your conversion? If conversion OK, only other thing I can think of is the extrusion direction (dxf code 210), if arc was drawn in other than World UCS.
 
CarlAK,
The specs for dxf says all angles are in degrees. To convert to radians I am multiplying degrees by PI/180.

What I should have pointed out is this:

Ten of the 12 arcs in the file have a negative number for the value of X (location of the center of the arc).
If I remove the minus - it plots in the correct place but in the wrong quadrant.
If I leave the minus there - it plots in the correct quadrant but off to the side of the drawing.

Perhaps the arcs must be drawn RELATIVE to some reference point ???
There are numbers under codes 50 and 51 in each record. What are they?
 
Forget that last line in my last post!
50 and 51 are, of course, the start angle and the end angle of the arc.
 
Gperk,

Are you writing the DXF files and then importing them through AutoCAD's DXFIN command or are you importing the file with code you've written?

And what portion of either chunk of code is giving you negative angles?

We might be able to help better if we had just a little more details.

Todd
 
I am in the process of writing a VB6 program to read DXF files and draw and print the data.
For testing the program I am using various dxf files found on the internet.
The problems appeared while using the file Slowflyer.dxf from the internet:
---1. some x values were negative - if changed to positive they plot correctly
---2. arcs appear to be in the wrong quadrant of the circle or are drawn outside the bounds of the main drawing.

I suspect some of the dxf file was created using BLOCKs, but there are no Blocks in the file that contain ENTITIES.
Using AcmeCAD, the file plots correctly, but another program called DXFbrowser has the same problem as I have.

Right now, I think Slowflyer.dxf is flakey. Other files I have used do not have this problem.
I'm just beginning to understand the DXF file layout - when I get farther along I will post my conclusions.
 
Hi GPerk:

I'm starting an App in VB6 that try to read the lines in DXF format and then use this information.

I dont know how can you read the end point,start point,the type of line...betwen all the data in DXF.

Can you help me with that?

I apreciatte your help.

Regards..
 
Plopez,
First you need to print a copy of the DXF file specifications for AutoCAD Release 14 at:
To give you a start, a "stripped-down" Line will look like:
0
LINE
10
2.4
20
6.3
11
5.1
21
9.7
This will translate to the VB as:
Line (2.4,6.3)-(5.1,9.7)
Also there is a lot of stuff in the HEADER section, most of which you can ignore for now, but the following is important:
9
$EXTMIN
10
-8.319336
20
23.945801
30
0.0
9
$EXTMAX
10
13.291992
20
46.268555
30
0.0
This defines the rectangle that includes all objects to be drawn (10 precedes the X value, 20 the Y value, 30 is for 3D or Z value, not used in this sample).

This is a major project - Good Luck!
 
Hi GPerk:

Thanks for your help...that was the hint that I needed.

I'm working in my App with your code and it works so well!

Regards...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top