(root)/
libredwg-0.13/
examples/
load_dwg.py
       1  #! /usr/bin/env python3
       2  
       3  #import libredwg
       4  from libredwg import *
       5  
       6  import sys
       7  
       8  if (len(sys.argv) != 2):
       9          print("Usage: load_dwg.py <filename>")
      10          exit()
      11  
      12  filename = sys.argv[1]
      13  a = Dwg_Data()
      14  a.object = new_Dwg_Object_Array(1000)
      15  error = dwg_read_file(filename, a)
      16  
      17  if (error > 0): # critical errors
      18      print("Error: ", error)
      19      if (error > 127):
      20          exit()
      21  
      22  print(".dwg version: %s" % a.header.version)
      23  print("Num objects: %d " % a.num_objects)
      24  
      25  #XXX TODO Error: Dwg_Object_LAYER_CONTROL object has no attribute 'tio'
      26  #print "Num layers: %d" % a.layer_control.tio.object.tio.LAYER_CONTROL.num_entries
      27  
      28  #XXX ugly, but works
      29  for i in range(0, a.num_objects):
      30      obj = Dwg_Object_Array_getitem(a.object, i)
      31      print(" Supertype: " ,   obj.supertype)
      32      print("      Type: " ,   obj.type)