Search code examples
pythoncaddxf

Removing superfluos layers from DXFwrite


I use the python package DXFwrite to construct solar cell grids. Unfortunately my simulation program is confused by additional layers introduced by DXFwrite. Their names are:

  • DIMENSIONS
  • TABLECONTENT
  • TABLEGRID
  • TABLEBACKGROUND
  • VIEWPORTS

Is there a simple way to prevent DXFwrite from creating these layers? I have not found any command to remove layers.

Best Regards,

Thorsten Rissom


Solution

  • after skimming through the source - there is a possibility.

    DXFEngine.layers is an intern _Table structure, which has a clear() function. Haven't tested for unwanted side-effects but you can do the following:

    from dxfwrite import DXFEngine as mydxfwrite
    mydxfdrawing = mydxfwrite.drawing('Filename.dxf')
    mydxfdrawing.layers.clear() #clears the layers
    mydxfdrawing.add_layer("JUSTASINGLELAYER",color=1) #add your layer with for example a specific color
    mydxfdrawing.save()
    

    LibreCad, however, still shows a layer called "0" apart from the layer "JUSTASINGLELAYER".

    Best wishes, Martin