mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-17 05:52:33 +00:00
Fix terrible bug #1819 where duplicating mapped elements didn't actually copy the geometry mapping.
This commit is contained in:
@@ -169,7 +169,7 @@ class IfcExporter:
|
||||
if parent.is_a("IfcSpatialStructureElement") and not element.is_a("IfcSpatialStructureElement"):
|
||||
if parent != ifcopenshell.util.element.get_container(element):
|
||||
blenderbim.core.spatial.assign_container(
|
||||
tool.Ifc, tool.Collector, tool.Container, structure_obj=parent_obj, element_obj=obj
|
||||
tool.Ifc, tool.Collector, tool.Spatial, structure_obj=parent_obj, element_obj=obj
|
||||
)
|
||||
elif parent != ifcopenshell.util.element.get_aggregate(element):
|
||||
blenderbim.core.aggregate.assign_object(
|
||||
|
||||
@@ -25,7 +25,7 @@ def copy_class(ifc, collector, root, obj=None):
|
||||
ifc.link(element, obj)
|
||||
relating_type = root.get_element_type(element)
|
||||
if relating_type and root.does_type_have_representations(relating_type):
|
||||
ifc.run("type.assign_type", related_object=element, relating_type=relating_type)
|
||||
ifc.run("type.map_type_representations", related_object=element, relating_type=relating_type)
|
||||
else:
|
||||
root.run_geometry_add_representation(obj=obj, context=root.get_object_context(obj))
|
||||
collector.assign(obj)
|
||||
|
||||
@@ -6,6 +6,7 @@ markers =
|
||||
geometry
|
||||
material
|
||||
misc
|
||||
model
|
||||
owner
|
||||
patch
|
||||
project
|
||||
|
||||
@@ -89,3 +89,19 @@ Scenario: Override duplicate move - with active IFC data
|
||||
And the object "IfcWall/Cube.001" is an "IfcWall"
|
||||
And the object "IfcBuildingStorey/My Storey.001" exists
|
||||
And the object "IfcBuildingStorey/My Storey.001" is an "IfcBuildingStorey"
|
||||
|
||||
Scenario: Override duplicate move - copying a type instance with a representation map
|
||||
Given an empty IFC project
|
||||
And I add a cube
|
||||
And the object "Cube" is selected
|
||||
And I set "scene.BIMRootProperties.ifc_product" to "IfcElementType"
|
||||
And I set "scene.BIMRootProperties.ifc_class" to "IfcWallType"
|
||||
And I press "bim.assign_class"
|
||||
And I set "scene.BIMTypeProperties.ifc_class" to "IfcWallType"
|
||||
And the variable "cube" is "{ifc}.by_type('IfcWallType')[0].id()"
|
||||
And I set "scene.BIMTypeProperties.relating_type" to "{cube}"
|
||||
And I press "bim.add_type_instance"
|
||||
And the object "IfcWall/Instance" is selected
|
||||
When I press "object.duplicate_move"
|
||||
Then the object "IfcWall/Instance.001" exists
|
||||
And the object "IfcWall/Instance.001" has a "MappedRepresentation" representation of "Model/Body/MODEL_VIEW"
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
@model
|
||||
Feature: Model
|
||||
|
||||
Scenario: Add type instance - add from a mesh
|
||||
Given an empty IFC project
|
||||
And I add a cube
|
||||
And the object "Cube" is selected
|
||||
And I set "scene.BIMRootProperties.ifc_product" to "IfcElementType"
|
||||
And I set "scene.BIMRootProperties.ifc_class" to "IfcWallType"
|
||||
And I press "bim.assign_class"
|
||||
And I set "scene.BIMTypeProperties.ifc_class" to "IfcWallType"
|
||||
And the variable "cube" is "{ifc}.by_type('IfcWallType')[0].id()"
|
||||
And I set "scene.BIMTypeProperties.relating_type" to "{cube}"
|
||||
When I press "bim.add_type_instance"
|
||||
Then the object "IfcWall/Instance" exists
|
||||
|
||||
Scenario: Add type instance - add from an empty
|
||||
Given an empty IFC project
|
||||
And I add an empty
|
||||
And the object "Empty" is selected
|
||||
And I set "scene.BIMRootProperties.ifc_product" to "IfcElementType"
|
||||
And I set "scene.BIMRootProperties.ifc_class" to "IfcWallType"
|
||||
And I press "bim.assign_class"
|
||||
And I set "scene.BIMTypeProperties.ifc_class" to "IfcWallType"
|
||||
And the variable "empty" is "{ifc}.by_type('IfcWallType')[0].id()"
|
||||
And I set "scene.BIMTypeProperties.relating_type" to "{empty}"
|
||||
When I press "bim.add_type_instance"
|
||||
Then the object "IfcWall/Instance" exists
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
import os
|
||||
import bpy
|
||||
import webbrowser
|
||||
import ifcopenshell
|
||||
import blenderbim.tool as tool
|
||||
import blenderbim.bim
|
||||
@@ -29,6 +30,9 @@ scenarios("feature")
|
||||
|
||||
variables = {"cwd": os.getcwd(), "ifc": "IfcStore.get_file()"}
|
||||
|
||||
# Monkey-patch webbrowser opening since we want to test headlessly
|
||||
webbrowser.open = lambda x: True
|
||||
|
||||
|
||||
def replace_variables(value):
|
||||
for key, new_value in variables.items():
|
||||
@@ -204,14 +208,14 @@ def the_object_name_has_a_body_of_value(name, value):
|
||||
assert the_object_name_exists(name).data.body == value
|
||||
|
||||
|
||||
@then(parsers.parse('the object "{name}" has a "{_type}" representation of "{context}"'))
|
||||
def the_object_name_has_a_type_representation_of_context(name, _type, context):
|
||||
@then(parsers.parse('the object "{name}" has a "{type}" representation of "{context}"'))
|
||||
def the_object_name_has_a_representation_type_of_context(name, type, context):
|
||||
ifc = an_ifc_file_exists()
|
||||
element = ifc.by_id(the_object_name_exists(name).BIMObjectProperties.ifc_definition_id)
|
||||
context, subcontext, target_view = context.split("/")
|
||||
assert ifcopenshell.util.representation.get_representation(
|
||||
element, context, subcontext or None, target_view or None
|
||||
)
|
||||
rep = ifcopenshell.util.representation.get_representation(element, context, subcontext or None, target_view or None)
|
||||
assert rep
|
||||
assert rep.RepresentationType == type
|
||||
|
||||
|
||||
@then(parsers.parse('the material "{name}" exists'))
|
||||
|
||||
@@ -32,7 +32,7 @@ class TestCopyClass:
|
||||
ifc.link("element", "obj").should_be_called()
|
||||
root.get_element_type("element").should_be_called().will_return("type")
|
||||
root.does_type_have_representations("type").should_be_called().will_return(True)
|
||||
ifc.run("type.assign_type", related_object="element", relating_type="type").should_be_called()
|
||||
ifc.run("type.map_type_representations", related_object="element", relating_type="type").should_be_called()
|
||||
collector.assign("obj").should_be_called()
|
||||
root.is_opening_element("element").should_be_called().will_return(False)
|
||||
subject.copy_class(ifc, collector, root, obj="obj")
|
||||
@@ -65,7 +65,7 @@ class TestCopyClass:
|
||||
ifc.link("element", "obj").should_be_called()
|
||||
root.get_element_type("element").should_be_called().will_return("type")
|
||||
root.does_type_have_representations("type").should_be_called().will_return(True)
|
||||
ifc.run("type.assign_type", related_object="element", relating_type="type").should_be_called()
|
||||
ifc.run("type.map_type_representations", related_object="element", relating_type="type").should_be_called()
|
||||
collector.assign("obj").should_be_called()
|
||||
root.is_opening_element("element").should_be_called().will_return(True)
|
||||
root.add_dynamic_opening_voids("element", "obj").should_be_called()
|
||||
|
||||
Reference in New Issue
Block a user