Fix error duplicating array item after c415767 #5705

error traceback
```
Traceback (most recent call last):
  File "bonsai\bim\module\geometry\operator.py", line 909, in execute
    return OverrideDuplicateMove.execute_duplicate_operator(self, context, linked=False)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "bonsai\bim\module\geometry\operator.py", line 918, in execute_duplicate_operator
    IfcStore.execute_ifc_operator(self, context)
  File "bonsai\bim\ifc.py", line 443, in execute_ifc_operator
    result = getattr(operator, "_execute")(context)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "bonsai\bim\module\geometry\operator.py", line 912, in _execute
    return OverrideDuplicateMove.execute_ifc_duplicate_operator(self, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "bonsai\bim\module\geometry\operator.py", line 1021, in execute_ifc_duplicate_operator
    tool.Model.handle_array_on_copied_element(new, array_data)
  File "bonsai\tool\model.py", line 673, in handle_array_on_copied_element
    array_pset_data = array_pset["Data"]
                      ~~~~~~~~~~^^^^^^^^
KeyError: 'Data'
```
This commit is contained in:
Andrej730
2024-11-07 17:12:38 +05:00
parent fb081e3cf2
commit 09fcd32b7a
+7 -3
View File
@@ -25,6 +25,7 @@ import collections.abc
import numpy as np import numpy as np
import ifcopenshell import ifcopenshell
import ifcopenshell.api import ifcopenshell.api
import ifcopenshell.api.pset
import ifcopenshell.util.element import ifcopenshell.util.element
import ifcopenshell.util.unit import ifcopenshell.util.unit
import ifcopenshell.util.placement import ifcopenshell.util.placement
@@ -669,7 +670,10 @@ class Model(bonsai.core.tool.Model):
if not array_pset: if not array_pset:
return return
array_pset_data = array_pset["Data"] # TODO: Non-strictness is temporary. It was added due
# to a bug infecting ifc models since it occurred,
# can be reverted later.
array_pset_data = array_pset.get("Data", None)
array_pset = tool.Ifc.get().by_id(array_pset["id"]) array_pset = tool.Ifc.get().by_id(array_pset["id"])
ifcopenshell.api.run("pset.remove_pset", tool.Ifc.get(), product=element, pset=array_pset) ifcopenshell.api.run("pset.remove_pset", tool.Ifc.get(), product=element, pset=array_pset)
@@ -764,11 +768,11 @@ class Model(bonsai.core.tool.Model):
# add child pset # add child pset
child_pset = tool.Pset.get_element_pset(child_element, "BBIM_Array") child_pset = tool.Pset.get_element_pset(child_element, "BBIM_Array")
if child_pset: if child_pset:
ifcopenshell.api.run( ifcopenshell.api.pset.edit_pset(
"pset.edit_pset",
tool.Ifc.get(), tool.Ifc.get(),
pset=child_pset, pset=child_pset,
properties={"Data": None}, properties={"Data": None},
should_purge=False,
) )
# set child object position # set child object position