Как добавить информацию об атрибутах в полилинию, используя ezdxf? - PullRequest
0 голосов
/ 07 февраля 2019

Я использую пакет ezdxf для записи файлов dxf.Мне нужна помощь для хранения информации об атрибутах для полилиний.Почему я не могу использовать функцию add_attrib в макете / пространстве модели?Ниже приведен код;dataObj - это строка геоджона:

dwg = ezdxf.new('R2010')
flag = dwg.blocks.new(name='FLAG')
msp = dwg.modelspace()

#add attribute definitions
x = 0.5
y = -1
for i in Attribs:
    property = i;
    flag.add_attdef(str(property), (x, y), {'height': 0.5, 'color': 3})
    y = y-1.5

for i in range(numFeats):
    msp.add_polyline3d(dataObj[u'features'][i][u'geometry'][u'coordinates'])
    att_info_dict = dataObj[u'features'][i][u'properties']
    print dataObj[u'features'][i][u'geometry'][u'coordinates']
    print att_info_dict
    msp.add_attrib('DIAMETER',99,dataObj[u'features'][i][u'geometry'][u'coordinates'])

Я получаю ошибку:

Traceback (most recent call last):
  File "crtLine_wAttribs.py", line 46, in <module>
    msp.add_attrib('DIAMETER',99,dataObj[u'features'][i][u'geometry'][u'coordinates'])
  File "C:\Python27\ArcGIS10.6\lib\site-packages\ezdxf\graphicsfactory.py", line 116, in add_attrib
    return self.build_and_add_entity('ATTRIB', dxfattribs)
  File "C:\Python27\ArcGIS10.6\lib\site-packages\ezdxf\legacy\layouts.py", line 98, in build_and_add_entity
    entity = self.build_entity(type_, dxfattribs)
  File "C:\Python27\ArcGIS10.6\lib\site-packages\ezdxf\legacy\layouts.py", line 113, in build_entity
    entity = self._dxffactory.create_db_entry(type_, dxfattribs)
  File "C:\Python27\ArcGIS10.6\lib\site-packages\ezdxf\legacy\factory.py", line 109, in create_db_entry
    dbentry = self.new_entity(type_, handle, dxfattribs)
  File "C:\Python27\ArcGIS10.6\lib\site-packages\ezdxf\legacy\factory.py", line 82, in new_entity
    entity = wrapper_class.new(handle, dxfattribs, self.drawing)
  File "C:\Python27\ArcGIS10.6\lib\site-packages\ezdxf\dxfentity.py", line 85, in new
    entity.update_dxf_attribs(dxfattribs)
  File "C:\Python27\ArcGIS10.6\lib\site-packages\ezdxf\dxfentity.py", line 248, in update_dxf_attribs
    self.set_dxf_attrib(key, value)
  File "C:\Python27\ArcGIS10.6\lib\site-packages\ezdxf\dxfentity.py", line 185, in set_dxf_attrib
    dxfattr.set_attrib(self, key, value)
  File "C:\Python27\ArcGIS10.6\lib\site-packages\ezdxf\lldxf\attributes.py", line 168, in set_attrib
    self._set_extended_type(subclass_tags, value)
  File "C:\Python27\ArcGIS10.6\lib\site-packages\ezdxf\lldxf\attributes.py", line 182, in _set_extended_type
    raise DXFValueError('2 or 3 axis required')
ezdxf.lldxf.const.DXFValueError: 2 or 3 axis required
...