[PythonCAD] Updated DWG reading program

Art Haas ahaas at airmail.net
Fri Aug 29 13:32:25 EDT 2003


On Fri, Aug 29, 2003 at 12:17:07PM -0500, Eric Wilhelm wrote:
> > The following was supposedly scribed by
> >Hi.
> >
> >I've fixed the fix found bug in the 'dwg.py' file - decoding the class

This should read "I've fixed the first found bug ..."

> >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.
> 

This is objectype 502 - a DICTIONARYVAR object. The type is printed out
in the midst of the many things that get printed. It looks like the
program is bombing out where it is reading the number of reactors, which
in this case is 1. I'll take a look.

Thanks.

Art

-- 
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



More information about the PythonCAD mailing list