mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-12 06:32:09 +00:00
Fix bug where assigning a spatial container didn't work with non local placements
This commit is contained in:
@@ -248,7 +248,11 @@ class IfcStore:
|
||||
operator, rollback=lambda d: IfcStore.get_file().undo(), commit=lambda d: IfcStore.get_file().redo()
|
||||
)
|
||||
IfcStore.end_transaction(operator)
|
||||
context.view_layer.objects.active = active_object
|
||||
try:
|
||||
active_object.name
|
||||
context.view_layer.objects.active = active_object
|
||||
except:
|
||||
pass
|
||||
|
||||
return result
|
||||
|
||||
|
||||
@@ -242,7 +242,6 @@ class AssignClass(bpy.types.Operator):
|
||||
tool.Ifc,
|
||||
tool.Collector,
|
||||
tool.Container,
|
||||
tool.Surveyor,
|
||||
structure_obj=spatial_obj,
|
||||
element_obj=obj,
|
||||
)
|
||||
|
||||
@@ -46,7 +46,6 @@ class AssignContainer(bpy.types.Operator, Operator):
|
||||
tool.Ifc,
|
||||
tool.Collector,
|
||||
tool.Container,
|
||||
tool.Surveyor,
|
||||
structure_obj=structure_obj,
|
||||
element_obj=element_obj,
|
||||
)
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
import blenderbim.core
|
||||
|
||||
|
||||
def assign_container(ifc, collector, container, surveyor, structure_obj=None, element_obj=None):
|
||||
def assign_container(ifc, collector, container, structure_obj=None, element_obj=None):
|
||||
if not container.can_contain(structure_obj, element_obj):
|
||||
return
|
||||
rel = ifc.run(
|
||||
@@ -27,7 +27,6 @@ def assign_container(ifc, collector, container, surveyor, structure_obj=None, el
|
||||
product=ifc.get_entity(element_obj),
|
||||
relating_structure=ifc.get_entity(structure_obj),
|
||||
)
|
||||
blenderbim.core.geometry.edit_object_placement(ifc, surveyor, obj=element_obj)
|
||||
container.disable_editing(element_obj)
|
||||
collector.assign(element_obj)
|
||||
return rel
|
||||
|
||||
@@ -17,24 +17,22 @@
|
||||
# along with BlenderBIM Add-on. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import blenderbim.core.spatial as subject
|
||||
from test.core.bootstrap import ifc, collector, container, surveyor
|
||||
from test.core.bootstrap import ifc, collector, container
|
||||
|
||||
|
||||
class TestAssignContainer:
|
||||
def test_run(self, ifc, collector, container, surveyor):
|
||||
def test_run(self, ifc, collector, container):
|
||||
container.can_contain("structure_obj", "element_obj").should_be_called().will_return(True)
|
||||
ifc.get_entity("structure_obj").should_be_called().will_return("structure")
|
||||
ifc.get_entity("element_obj").should_be_called().will_return("element")
|
||||
ifc.run(
|
||||
"spatial.assign_container", product="element", relating_structure="structure"
|
||||
).should_be_called().will_return("rel")
|
||||
surveyor.get_absolute_matrix("element_obj").should_be_called().will_return("matrix")
|
||||
ifc.run("geometry.edit_object_placement", product="element", matrix="matrix").should_be_called()
|
||||
container.disable_editing("element_obj").should_be_called()
|
||||
collector.assign("element_obj").should_be_called()
|
||||
assert (
|
||||
subject.assign_container(
|
||||
ifc, collector, container, surveyor, structure_obj="structure_obj", element_obj="element_obj"
|
||||
ifc, collector, container, structure_obj="structure_obj", element_obj="element_obj"
|
||||
)
|
||||
== "rel"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user