Wednesday, November 8, 2023

List all layers in AutoCAD file using python

 The code snippet below will get all layers in a .dxf AutoCAD file and print them on the console. It use the ezdxf module which you can install using pip.

import ezdxf

dwg = ezdxf.readfile('file_name.dxf')

for layer in dwg.layers:
    print (layer.dxf.name)




Happy coding.