From cad-linux-bounce@freelists.org Thu Aug 28 01:25:54 2003 Return-Path: Received: from turing.freelists.org (freelists-180.iquest.net [206.53.239.180]) by mx1.hotpop.com (Postfix) with ESMTP id 809C6E81D3; Thu, 28 Aug 2003 01:25:54 +0000 (UTC) Received: from turing (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 6EFF23907F8; Wed, 27 Aug 2003 20:26:06 -0500 (EST) Received: with ECARTIS (v1.0.0; list cad-linux); Wed, 27 Aug 2003 20:26:03 -0500 (EST) Delivered-To: cad-linux@freelists.org Received: from covert.brown-ring.iadfw.net (covert.black-ring.iadfw.net [209.196.123.142]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id A2DEE390D57 for ; Wed, 27 Aug 2003 20:20:42 -0500 (EST) Received: from pppte03-182.ght.iadfw.net ([66.94.132.182] helo=pcdebian.artsapartment.org) by covert.iadfw.net with esmtp (Exim 4.10) id 19sBSf-000380-00 for cad-linux@freelists.org; Wed, 27 Aug 2003 20:20:30 -0500 Received: from arth by pcdebian.artsapartment.org with local (Exim 4.20) id 19sBS2-0004ga-9y for cad-linux@freelists.org; Wed, 27 Aug 2003 20:19:50 -0500 Date: Wed, 27 Aug 2003 20:19:49 -0500 From: Art Haas To: cad-linux@freelists.org Subject: [cad-linux] First hack at DWG reading for PythonCAD Message-ID: <20030828011949.GB17960@artsapartment.org> Mime-Version: 1.0 Content-type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.4i X-archive-position: 1634 X-Approved-By: pfrostie@yahoo.com X-ecartis-version: Ecartis v1.0.0 Sender: cad-linux-bounce@freelists.org Errors-To: cad-linux-bounce@freelists.org X-original-sender: ahaas@airmail.net Precedence: normal Reply-To: cad-linux@freelists.org X-list: cad-linux X-HotPOP-Delivered-To: guy_j_edwards@hotpop.com X-Evolution-Source: pop://guy_j_edwards@pop.hotpop.com Content-Transfer-Encoding: 8bit Hi. I've posted this to the PythonCAD mailing list and it was suggested to me to send this here as well. So, without any further ado ... ----- Begin forwarded message ----- I've finished up the first shot at reading DWG files. I downloaded the spec from the OpenDWG group and have coded up a beastly little thing that does nothing other than print out what it finds in the DWG file it is reading. The script will only work on R13/R14 version files as those versions are what the spec describes. I've run this thing on the sample files that people have mailed me (thanks!), and the script doesn't bomb out when looking at the data in the file. That's good, but this thing need much more testing as the files I have contain a limited number of entity types. It would be great of some people with lots of R13/R14 files could try and run the script on the files and see if it reads them without an error. So, where is this script you ask? I thought about mailing it with this posting, but it is 20K gzipped and there is no need to clutter up your mailbox with 20K of stuff if you can't test it. If only the wankers who write e-mail worms or generate spam mail would be so kind. If you can test this and would like to do so, write me and I'll mail it to you. The script will run like this ... $ python dwg.py /path/to/the/dwg/file/you/will/test.dwg If it is an R13/R14 file the script will print out _lots_ of stuff as it reads the data in the file. Hopefully there will not be any error messages. Earlier or later versions of the format will generate an 'unknown format' message. The script only reads the files and prints stuff out - it does _not_ modify the DWG file. I expect to have to make several iterations on this script before it reads the files people test it on work decently. The script reads nearly all the entities described in the OpenDWG spec, and nearly completely. There are a number of entities that not all the data is read and processed, and some entitles like 'OLE2FRAME' entities are not read at all. The entities that PythonCAD can deal with - lines, circles, points, etc. - all seem to be read well enough that the ability to import the data from DWG into PythonCAD looks like a very achievable goal. There is still much I don't understand about the DWG file format (and many other things) so documentation, references, and help in deciphering the format will be greatly appreciated. I've also sent some stuff up to the repo - the line clipping stuff I worked on a week or two ago, and I've added a change the the text.py file that should fix the Python-2.3 problem. Let me know if you want to have the dwg.py file and I'll send it along. Art ----- End forwarded message ----- For those who want to get the OpenDWG spec, go to http://www.opendwg.org Another valuable bit of info is the code here ... http://www.geocities.com/kuyunjik 'gaumata@hotmail.com' wrote that stuff, and his program was definitely valuable in generating output to compare against the output of my python script, as well as see how he handled some of the ambiguities and errors (really typos) in the spec. -- Man once surrendering his reason, has no remaining guard against absurdities the most monstrous, and like a ship without rudder, is the sport of every wind. -Thomas Jefferson to James Smith, 1822