1

I'm using ezdxf package in python to read the AutoCAD .dxf file. Can anyone tell me how to extract Line width, Transparency, and Color information of each entity present in modelspace?

I tried the below code:

doc = ezdxf.readfile('test.dxf') \
model_space = doc.modelspace() \
if entity in model_space:\
    print(entity.dxf.color)

The output will be either 0, 256, or 257 which is indicating, (0-BYBLOCK 256-BYLAYER 257-BYOBJECT)

I need to get the information about each entity. Can anyone help?

Andrew Truckle
  • 17,769
  • 16
  • 66
  • 164
Adithya
  • 25
  • 3

1 Answers1

1
# iterate over all entities in modelspace
for e in doc.modelspace():
    print(f"layer: {e.dxf.layer}\n")
    print(f"ACI: {e.dxf.color}\n")
    ...

See also: Tutorial for getting data from DXF files:

mozman
  • 2,001
  • 8
  • 23