I'm sort of a little further on on this. Debugging with GDB, I can list the contents of a dwg element: (gdb) p dwg.object[29730] $1 = {size = 85, address = 4890, type = 49, index = 29730, fixedtype = DWG_TYPE_BLOCK_HEADER, name = 0x7ffff7e4167c "BLOCK_HEADER", dxfname = 0x7ffff7e4167c "BLOCK_HEADER", supertype = DWG_SUPERTYPE_OBJECT, tio = {entity = 0x55555667c330, object = 0x55555667c330}, handle = { code = 0 '\000', size = 3 '\003', value = 2587925, is_global = 0 '\000'}, parent = 0x555555558040 <dwg>, klass = 0x0, bitsize = 314, bitsize_pos = 10, hdlpos = 314, was_bitsize_set = 0 '\000', has_strings = 1 '\001', stringstream_size = 206, handlestream_size = 366, common_size = 37, num_unknown_bits = 0, unknown_bits = 0x0} (gdb)
If I tab the BLOCK_HEADER object, I get these struct objects: (gdb) p dwg.object[29730].tio.object.tio.BLOCK_HEADER. __iterator block_scaling first_entity insert_units last_entity num_owned xref anonymous description flag inserts layout parent xref_pname base_pt endblk_entity flag2 is_xref_dep loaded_bit preview xrefoverlaid blkisxref entities flag3 is_xref_ref name preview_size block_entity explodable hasattrs is_xref_resolved num_inserts used (gdb) So, if I print the num_owned value, it tells me that there are 7 items in the block. (gdb) p dwg.object[29730].tio.object.tio.BLOCK_HEADER.num_owned $4 = 7 (gdb) So far so good. One of the struct elements is called "entities". And, if I tab this, it lists 3 further struct elements: (gdb) p dwg.object[29730].tio.object.tio.BLOCK_HEADER.entities. absolute_ref handleref obj (gdb) Now, if I treat the obj element as an array, it gives me the entities comprising the block. (gdb) p dwg.object[29730].tio.object.tio.BLOCK_HEADER.entities.obj[0] $6 = {size = 169, address = 227700, type = 34, index = 29951, fixedtype = DWG_TYPE_VIEWPORT, name = 0x7ffff7e414dd "VIEWPORT", dxfname = 0x7ffff7e414dd "VIEWPORT", supertype = DWG_SUPERTYPE_ENTITY, tio = {entity = 0x5555566efd60, object = 0x5555566efd60}, handle = { code = 0 '\000', size = 3 '\003', value = 2588152, is_global = 0 '\000'}, parent = 0x555555558040 <dwg>, klass = 0x0, bitsize = 1177, bitsize_pos = 10, hdlpos = 1177, was_bitsize_set = 0 '\000', has_strings = 1 '\001', stringstream_size = 2, handlestream_size = 175, common_size = 71, num_unknown_bits = 0, unknown_bits = 0x0} (gdb) Great! So the first item in the block (which is a Paperspace entity) is a VIEWPORT object which I should be able to access from this. But, it doesn't work that way. Dwg_Object_Ref * entities=dwg.object[ent].tio.object->tio.BLOCK_HEADER->entities; ← this generates errors which say"Member reference base type 'BITCODE_H' (aka 'struct _dwg_object_ref *') is not a structure or a union." Any help would be appreciated. ~ Dave On Tue, Nov 30, 2021 at 3:55 PM Dave Coventry <dgcoven...@gmail.com> wrote: > > For some reason, entities which shoud appear in Paperspace BLOCK areas > are in the ENTITIES area, which means that they are rendered in > Modelspace. > > How do I find the value of the 330 DXF code of an entity? > > The drawing has 3 Paperspace tabs in addition to Modelspace. > > *Paper_Space1 and *Paper_Space2 both have entries in the BLOCKS > SECTION and the entities which belong to these spaces appear before > the ENDBLK in each block portion. > > These entities display which Paperspace BLOCK_HEASER they belong to > using the structure > dwg.object[index]->tio.entity->ownerhandle->handleref.value; > > So far so good. > > However, *Paper_Space does not have a BLOCK entry in the BLOCKS > SECTION and they are simply listed in the ENTITIES SECTION, albeit > with a 330 DXF Code which references the *Paper_Space BLOCK_HEADER. > So dwg.object[index]->tio.entity->ownerhandle is zero and > dwg.object[index]->tio.entity->ownerhandle->handleref.value; is > inaccessible. > > Hence these entities (which includes VIEWPORT entities) appear in > model space when they should appear in *Paper_Space. > > If I examine the drawing converted to DXF, the 330 DXF code correctly > identifies the BLOCK_HEADER handle of the *Paper_Space block. > > How do I extract the 330 code? > > Many Thanks, > > ~Dave