AttributeError: 'str' object has no attribute 'copy' #850
Unanswered
littlekittel
asked this question in
Issues
Replies: 1 comment 2 replies
-
Sorry, this is not useful for me. Please provide the script and the (zipped) DXF data to reproduce the error. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
i am trying to explode INSERT entities like this:
entity.explode(msp)
This works for most entities but for some I am getting a:
AttributeError: 'str' object has no attribute 'copy'
Any ideas what could be the issue?
Full error:
AttributeError Traceback (most recent call last)
Input In [680], in <cell line: 1>()
----> 1 for entity in e.explode(msp):
2 print("Name: {}, Layer: {}, block attribs: {}, insert attribs: {}".format(entity.dxf.name, entity.dxf.layer, [[x.dxf.tag, x.dxf.text] for x in entity.block().attdefs()], [[x.dxf.tag, x.dxf.text] for x in entity.attribs]))
File ~/opt/anaconda3/envs/dxf/lib/python3.9/site-packages/ezdxf/entities/insert.py:584, in Insert.explode(self, target_layout, redraw_order)
580 if target_layout is None:
581 raise DXFStructureError(
582 "INSERT without layout assignment, specify target layout."
583 )
--> 584 return explode_block_reference(
585 self, target_layout=target_layout, redraw_order=redraw_order
586 )
File ~/opt/anaconda3/envs/dxf/lib/python3.9/site-packages/ezdxf/explode.py:125, in explode_block_reference(block_ref, target_layout, redraw_order)
123 _explode_single_block_ref(virtual_insert)
124 else:
--> 125 _explode_single_block_ref(block_ref)
127 source_layout = block_ref.get_layout()
128 if source_layout is not None:
129 # Remove and destroy exploded INSERT if assigned to a layout
File ~/opt/anaconda3/envs/dxf/lib/python3.9/site-packages/ezdxf/explode.py:96, in explode_block_reference.._explode_single_block_ref(block_ref)
95 def _explode_single_block_ref(block_ref):
---> 96 for entity in virtual_block_reference_entities(
97 block_ref, redraw_order=redraw_order
98 ):
99 dxftype = entity.dxftype()
100 target_layout.add_entity(entity)
File ~/opt/anaconda3/envs/dxf/lib/python3.9/site-packages/ezdxf/explode.py:256, in virtual_block_reference_entities(block_ref, skipped_entity_callback, redraw_order)
251 if block_layout is None:
252 raise const.DXFStructureError(
253 f'Required block definition for "{block_ref.dxf.name}" does not exist.'
254 )
--> 256 yield from transform(disassemble(block_layout))
File ~/opt/anaconda3/envs/dxf/lib/python3.9/site-packages/ezdxf/explode.py:217, in virtual_block_reference_entities..transform(entities)
216 def transform(entities):
--> 217 for entity in entities:
218 try:
219 entity.transform(m)
File ~/opt/anaconda3/envs/dxf/lib/python3.9/site-packages/ezdxf/explode.py:205, in virtual_block_reference_entities..disassemble(layout)
203 continue
204 try:
--> 205 copy = entity.copy()
206 except const.DXFTypeError:
207 if hasattr(entity, "virtual_entities"):
File ~/opt/anaconda3/envs/dxf/lib/python3.9/site-packages/ezdxf/entities/dxfentity.py:333, in DXFEntity.copy(self)
330 xdict = self.extension_dict
331 if xdict is not None and doc is not None and xdict.is_alive:
332 # All linked DXF objects are copied and added to the OBJECTS section:
--> 333 entity.extension_dict = xdict.copy()
334 else:
335 entity.extension_dict = None
File ~/opt/anaconda3/envs/dxf/lib/python3.9/site-packages/ezdxf/entities/xdict.py:124, in ExtensionDict.copy(self)
120 def copy(self) -> ExtensionDict:
121 """Deep copy of the extension dictionary all entries are virtual
122 entities.
123 """
--> 124 new_xdict = self.dictionary.copy()
125 return ExtensionDict(new_xdict)
File ~/opt/anaconda3/envs/dxf/lib/python3.9/site-packages/ezdxf/entities/dxfentity.py:350, in DXFEntity.copy(self)
346 entity.set_source_of_copy(self)
347 # DO NOT COPY DYN_SOURCE_BLOCK_REFERENCE_ATTRIBUTE.
348 # Copying an entity from a block reference, takes it out of context of
349 # this block reference!
--> 350 self._copy_data(entity)
351 return entity
File ~/opt/anaconda3/envs/dxf/lib/python3.9/site-packages/ezdxf/entities/dictionary.py:102, in Dictionary._copy_data(self, entity)
99 entity._value_code = self._value_code
100 if self.dxf.hard_owned:
101 # Reactors are removed from the cloned DXF objects.
--> 102 entity._data = {key: entity.copy() for key, entity in self.items()}
103 else:
104 entity._data = {key: entity for key, entity in self.items()}
File ~/opt/anaconda3/envs/dxf/lib/python3.9/site-packages/ezdxf/entities/dictionary.py:102, in (.0)
99 entity._value_code = self._value_code
100 if self.dxf.hard_owned:
101 # Reactors are removed from the cloned DXF objects.
--> 102 entity._data = {key: entity.copy() for key, entity in self.items()}
103 else:
104 entity._data = {key: entity for key, entity in self.items()}
File ~/opt/anaconda3/envs/dxf/lib/python3.9/site-packages/ezdxf/entities/dxfentity.py:350, in DXFEntity.copy(self)
346 entity.set_source_of_copy(self)
347 # DO NOT COPY DYN_SOURCE_BLOCK_REFERENCE_ATTRIBUTE.
348 # Copying an entity from a block reference, takes it out of context of
349 # this block reference!
--> 350 self._copy_data(entity)
351 return entity
File ~/opt/anaconda3/envs/dxf/lib/python3.9/site-packages/ezdxf/entities/dictionary.py:102, in Dictionary._copy_data(self, entity)
99 entity._value_code = self._value_code
100 if self.dxf.hard_owned:
101 # Reactors are removed from the cloned DXF objects.
--> 102 entity._data = {key: entity.copy() for key, entity in self.items()}
103 else:
104 entity._data = {key: entity for key, entity in self.items()}
File ~/opt/anaconda3/envs/dxf/lib/python3.9/site-packages/ezdxf/entities/dictionary.py:102, in (.0)
99 entity._value_code = self._value_code
100 if self.dxf.hard_owned:
101 # Reactors are removed from the cloned DXF objects.
--> 102 entity._data = {key: entity.copy() for key, entity in self.items()}
103 else:
104 entity._data = {key: entity for key, entity in self.items()}
AttributeError: 'str' object has no attribute 'copy'
Beta Was this translation helpful? Give feedback.
All reactions