FIXDWG - Fix AutoCad® import rounding errors


AutoCad® allows import of drawings using DXF format (a text based graphics format).  Normally this works well, with some tweaking, but a subtle problem may exist depending on the import file.

The PROBLEM

Drawings imported from other programs (usually by DXF) often have insufficient decimals to satisfy some AutoCad® requirements.  If 2 lines, for example, are present, it is possible that - although the lines are drawn using only 3 discrete points - the two lines do not touch as intended.  This rounding error is usually around 1x10-7 in drawings that come from certain programs which restrict the number of decimals output to DXF.  Usually, the rounding error is not noticeable in lines, but almost always occurs in arcs.

The result of the problem is that some AutoCad® tools, PEDIT and boundary tools such as BPOLY (release 12) or BOUNDARY (later versions), fail, since the figure is considered to be an open rather than a closed figure.  By experimentation, the threshold seems to be at 1x10E-10 as in the following data:


The PROPOSAL

  1. Identify all discrete points associated with LINEs.  A "fudge" factor should be used to test for discreteness (eg. 0.0001 or 10E-4) - any points within the discrete point tolerance should be counted as the same point.  This means one point only should be adopted to represent all points within the discrete point tolerance .  Line entities contain both the starting and ending points.
  2. Remake all lines using the new discrete point list.
  3. Identify all discrete points associated with ARCs.  Arc entities only contain the centre point - the end points are calculated from the centre point using the radius and the start/end angles.  The discrete points should also be checked against the LINE list, since a line and arc may "touch" (hold the LINE).
  4. Remake all curves using the discrete points.  This will undoubtedly mean recalculating some components of the arc - the likely candidates are the start/end angles and centre point - (hold the end points and radius).  If new curves are non- tangential or "broken back", the amount will be negligable - undetectable by most programs.

The above method should guarantee that all (?) arcs and lines now touch, where expected.  A further issue may be present where a line (usually, rather than an arc) touches another line or arc, but not at the end point, as in a T intersection.  This issue may be addressed in any future versions of FIXDWG.  The magic distance (perpendicular) of 1x10E-10 seems to hold true for this situation as well.

The FIXDWG routine does not use elevations (Z component)! The Z value for each entity's data should be preserved.


DOWNLOAD FIXDWG

Current version: 1.0 (August, 2005)

Download FIXDWG here, along with a brief help file (FIXDWG.TXT) explaining usage, etc.

FIXDWG (protected lisp file, help file) fixdwg.zip (6,458 bytes)

 Back to SRS Home