【问题标题】:An error occurs when using ezdxf to describe the layer property description使用ezdxf描述图层属性描述时出错
【发布时间】:2020-01-27 12:11:21
【问题描述】:

使用ezdxf描述图层属性描述时出错。 有会导致错误的图层名称和不会导致错误的图层名称。我不知道原因。

我尝试使用下面的代码。

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

if lay.tags.has_xdata(app):
    lay.tags.set_xdata(app, [(1000, ''), (1000, dsc)])
else:
    dwg.appids.new(app)
    lay.tags.new_xdata(app, [(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!

【问题讨论】:

    标签: python python-3.x autocad dxf ezdxf


    【解决方案1】:

    当试图将描述分配给没有现有描述的层,但在包含其他层的图形中描述(即在 AcAecLayerStandard 应用程序 ID 已注册的图形中)。

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

    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)])
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-11-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-14
      • 2020-06-18
      • 2016-11-20
      • 2011-03-20
      相关资源
      最近更新 更多