# # Copyright (c) 2003 Art Haas # # This file is part of PythonCAD. # # PythonCAD is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # PythonCAD is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with PythonCAD; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # read autocad r12 file format # import struct import array import sys r13 = False # ugh - global variable def dump_info(handle): global r13 handle.seek(0, 0) _version = handle.read(6) if _version != 'AC1009': if _version == 'AC1010': r13 = True else: print "unknown version" return handle.seek(6, 1) # skip rest of version (_b1, _w1, _w2, _w3, _b2) = struct.unpack(" 0): _xval = struct.unpack('B', handle.read(1))[0] _xlen = _xlen - 1 if _xval == 0: if _xlen < 1: break _val = struct.unpack('B', handle.read(1))[0] _xlen = _xlen - 1 if r13: # ugh if _xlen < 1: break _cp = struct.unpack('B', handle.read(1))[0] # code page? _xlen = _xlen - 1 if _xlen < _val: break _string = handle.read(_val) _data.append(_string) _xlen = _xlen - _val elif (_xval == 1 or _xval == 3 or _xval == 70): if _xlen < 2: break _val = struct.unpack(' 2) and (_kind != 22)): _z = struct.unpack(' _crcpos): print "at > crcpos" else: print "at == crcpos" _crc = struct.unpack('