简体   繁体   中英

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

No there is no method to delete layers and you can not prevent dxfwrite from creating this layers.

Alternative 1:

Use ezdxf ( https://pypi.python.org/pypi/ezdxf/ ), but there are also some predefined layers (DEFPOINTS, VIEW_PORT), but you can delete entries from the layer table: dwg.layers.remove('layername') , this removes only the layer table entry, a layer is only deleted if not entity references this layer. And maybe there are some unexpected side effects.

Alternative 2:

Use ezdxf.r12writer: this module can be used without the ezdxf package, just copy r12writer.py into your project. The module writes very basic DXF12 files, see docs: http://pythonhosted.org/ezdxf/r12writer.html .

  • Supported entities: LINE, CIRCLE, ARC, TEXT, POINT, SOLID, 3DFACE and POLYLINE
  • Block references are not supported!
  • additional advantage: r12writer is very fast

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM