Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/314.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 使用ezdxf描述图层特性描述时出错_Python_Python 3.x_Autocad_Dxf_Ezdxf - Fatal编程技术网

Python 使用ezdxf描述图层特性描述时出错

Python 使用ezdxf描述图层特性描述时出错,python,python-3.x,autocad,dxf,ezdxf,Python,Python 3.x,Autocad,Dxf,Ezdxf,使用ezdxf描述图层特性描述时出错。 有些图层名会导致错误,有些图层名不会导致错误。我不知道原因 我试着使用下面的代码 lay=dwg.layers.get('MyLayerHere')) app=‘AcaeLayerStandard’ dsc='MyDescriptionHere' 如果lay.tags.具有扩展数据(应用程序): lay.tags.set_扩展数据(应用程序,[(1000,),(1000,dsc)]) 其他: dwg.appids.new(应用程序) lay.tags.ne

使用ezdxf描述图层特性描述时出错。 有些图层名会导致错误,有些图层名不会导致错误。我不知道原因

我试着使用下面的代码

lay=dwg.layers.get('MyLayerHere'))
app=‘AcaeLayerStandard’
dsc='MyDescriptionHere'
如果lay.tags.具有扩展数据(应用程序):
lay.tags.set_扩展数据(应用程序,[(1000,),(1000,dsc)])
其他:
dwg.appids.new(应用程序)
lay.tags.new_xdata(应用程序,[(1000,),(1000,dsc)])
错误内容

Traceback (most recent call last): File "file.py", line 777, in dwg.appids.new(app) File "C:\・・・\table.py", line 63, in new raise DXFTableEntryError('%s %s already exists!' % (self._dxfname, name)) ezdxf.lldxf.const.DXFTableEntryError: APPID AcAecLayerStandard already exists!

如果试图将说明指定给没有现有说明的图层,但在包含其他带有说明的图层的图形中(即,在已注册了
AcAecLayerStandard
应用程序ID的图形中),则代码中将出现此错误

为了避免这种情况,只需在将应用程序ID添加到
APPID
符号表之前测试
acaeclayersstandard
应用程序ID是否已注册,例如:

lay = dwg.layers.get('MyLayerHere')
app = 'AcAecLayerStandard'
dsc = 'MyDescriptionHere'

if lay.tags.has_xdata(app):
    lay.tags.set_xdata(app, [(1000, ''), (1000, dsc)])
else:
    if app not in dwg.appids:
        dwg.appids.new(app)
    lay.tags.new_xdata(app, [(1000, ''), (1000, dsc)])