[PythonCAD] Updated DWG reading program

Eric Wilhelm ewilhelm at sbcglobal.net
Fri Aug 29 13:17:07 EDT 2003


> The following was supposedly scribed by
> Art Haas
> on Friday 29 August 2003 12:05 pm:

>Hi.
>
>I've fixed the fix found bug in the 'dwg.py' file - decoding the class
>data info did not handing padding bits correctly. I've also changed the
>way handles are stored in the file. Now they are tuples of integers.

That works on my little test file, but crashes with this on the huge one:

name: DIMASSOC
reading from bit offset 170
bit short type: 0x1
name: SORTENTS
reading from bit offset 244
bit short type: 0x1
name: XCLIPFRAME
parent handle: (4, 1, 12)
reactor handle 0: (4, 1, 12)
xdicobjhandle: (3, 0)
item handle 0: (2, 3, '\x03', '\xb5', '\xbf')
item handle 1: (2, 2, '\x02', '\xfd')
item handle 2: (2, 3, '\x04', '9', '\xed')
reading object 33
reading at 3063830 [2ec016]
size: 21
object data after size at 3063832
reading from bit offset 0
bit short type: 0x0
type: 502
bitpos: 18
handle: (0, 2, '\x02', '\xfd')
bitpos: 42
reading from bit offset 42
bit short type: 0x2
extended data size: 0
object data size in bits: 128
bitpos: 76
type: 502 => DICTIONARYVAR
dictionaryvar_reader() ...
numreactors: 1
intval: 0x0
reading from bit offset 94
bit short type: 0x1
string: 0x3
parent handle: (3, 1, 50)
Traceback (most recent call last):
  File "dwg.py", line 4360, in ?
    dump_info(_fh)
  File "dwg.py", line 148, in dump_info
    _objects = read_objects(handle, _objmap, _cmap)
  File "dwg.py", line 3888, in read_objects
    _vobjmap[_stype](_data, _bitpos)
  File "dwg.py", line 3143, in dictionaryvar_reader
    _bitpos, _handle = get_handle(data, _bitpos)
  File "dwg.py", line 4181, in get_handle
    _handle = get_bits(data, _hlen, (offset + 8))
  File "dwg.py", line 4318, in get_bits
    _b2 = (data[_idx] & _mask2)
IndexError: array index out of range

I'm afraid that I can't give you this file, but if I can find a way to cause 
this with another file, I'll get you one of those.

Any clues to what kind of object this is?  XCLIPFRAME?

--Eric



More information about the PythonCAD mailing list