Modify DXF Attributes of Entities

All DXF attributes of an entity are grouped in the namespace attribute dxf. You can modify/set a DXF attribute by assignment:

e.dxf.layer = "MyLayer"
e.dxf.color = 9

… or by the set() method:

e.dxf.set('color', 9)

The attribute has to be supported by the DXF type otherwise a DXFAttributeError will be raised. You can check if an DXF attribute is supported by the method dxf.is_supported():

line = msp.add_line((0, 0), (1, 0))
assert line.dxf.is_supported("text") is False