简体   繁体   English

从DXFwrite删除超级流层

[英]Removing superfluos layers from DXFwrite

I use the python package DXFwrite to construct solar cell grids. 我使用python包DXFwrite构建太阳能电池网格。 Unfortunately my simulation program is confused by additional layers introduced by DXFwrite. 不幸的是,我的仿真程序被DXFwrite引入的其他层所迷惑。 Their names are: 他们的名字是:

  • DIMENSIONS 尺寸图
  • TABLECONTENT 表格内容
  • TABLEGRID 桌面网格
  • TABLEBACKGROUND 桌面背景
  • VIEWPORTS 视口

Is there a simple way to prevent DXFwrite from creating these layers? 有没有一种简单的方法可以防止DXFwrite创建这些层? 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. 没有没有删除层的方法,您不能阻止dxfwrite创建此层。

Alternative 1: 选择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. 使用ezdxf( https://pypi.python.org/pypi/ezdxf/ ),但是也有一些预定义的图层(DEFPOINTS,VIEW_PORT),但是您可以从图层表中删除条目: dwg.layers.remove('layername') ,这只会删除图层表条目,如果没有实体引用该图层,则仅删除该图层。 And maybe there are some unexpected side effects. 也许还有一些意想不到的副作用。

Alternative 2: 选择2:

Use ezdxf.r12writer: this module can be used without the ezdxf package, just copy r12writer.py into your project. 使用ezdxf.r12writer:此模块无需ezdxf包即可使用,只需将r12writer.py复制到您的项目中即可。 The module writes very basic DXF12 files, see docs: http://pythonhosted.org/ezdxf/r12writer.html . 该模块可编写非常基本的DXF12文件,请参见docs: http ://pythonhosted.org/ezdxf/r12writer.html。

  • Supported entities: LINE, CIRCLE, ARC, TEXT, POINT, SOLID, 3DFACE and POLYLINE 支持的实体:LINE,CIRCLE,ARC,TEXT,POINT,SOLID,3DFACE和POLYLINE
  • Block references are not supported! 不支持块引用!
  • additional advantage: r12writer is very fast 额外的优势:r12writer非常快

after skimming through the source - there is a possibility. 浏览源代码后 -有可能。

DXFEngine.layers is an intern _Table structure, which has a clear() function. DXFEngine.layers是一个内部_Table结构,它具有clear()函数。 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". 但是, LibreCad仍然显示“ JUSTASINGLELAYER”层之外的“ 0”层。

Best wishes, Martin 马丁的祝福

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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