mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 17:58:20 +00:00
See #1636. Fix drawing caching when new voids are added or parametric objects updated.
This commit is contained in:
@@ -132,6 +132,7 @@ class SwitchRepresentation(bpy.types.Operator, Operator):
|
||||
if not representation:
|
||||
continue
|
||||
core.switch_representation(
|
||||
tool.Ifc,
|
||||
tool.Geometry,
|
||||
obj=obj,
|
||||
representation=representation,
|
||||
@@ -288,6 +289,7 @@ class UpdateParametricRepresentation(bpy.types.Operator):
|
||||
self.file.by_id(parameter.step_id)[parameter.index] = parameter.value
|
||||
show_representation_parameters = bool(props.ifc_parameters)
|
||||
core.switch_representation(
|
||||
tool.Ifc,
|
||||
tool.Geometry,
|
||||
obj=obj,
|
||||
representation=tool.Ifc.get().by_id(props.ifc_definition_id),
|
||||
|
||||
@@ -106,6 +106,7 @@ class AddFilledOpening(bpy.types.Operator, tool.Ifc.Operator):
|
||||
|
||||
representation = tool.Ifc.get().by_id(voided_obj.data.BIMMeshProperties.ifc_definition_id)
|
||||
blenderbim.core.geometry.switch_representation(
|
||||
tool.Ifc,
|
||||
tool.Geometry,
|
||||
obj=voided_obj,
|
||||
representation=representation,
|
||||
@@ -248,6 +249,7 @@ class RecalculateFill(bpy.types.Operator, tool.Ifc.Operator):
|
||||
)
|
||||
if body:
|
||||
blenderbim.core.geometry.switch_representation(
|
||||
tool.Ifc,
|
||||
tool.Geometry,
|
||||
obj=building_obj,
|
||||
representation=body,
|
||||
@@ -255,7 +257,6 @@ class RecalculateFill(bpy.types.Operator, tool.Ifc.Operator):
|
||||
is_global=True,
|
||||
should_sync_changes_first=False,
|
||||
)
|
||||
tool.Geometry.clear_cache(building_element)
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
@@ -417,6 +418,7 @@ class AddBoolean(Operator, tool.Ifc.Operator):
|
||||
tool.Model.clear_scene_openings()
|
||||
|
||||
blenderbim.core.geometry.switch_representation(
|
||||
tool.Ifc,
|
||||
tool.Geometry,
|
||||
obj=obj1,
|
||||
representation=representation,
|
||||
@@ -548,6 +550,7 @@ class RemoveBooleans(Operator, tool.Ifc.Operator, AddObjectHelper):
|
||||
body = ifcopenshell.util.representation.get_representation(element, "Model", "Body", "MODEL_VIEW")
|
||||
if body:
|
||||
blenderbim.core.geometry.switch_representation(
|
||||
tool.Ifc,
|
||||
tool.Geometry,
|
||||
obj=upstream_obj,
|
||||
representation=body,
|
||||
@@ -630,6 +633,7 @@ class EditOpenings(Operator, tool.Ifc.Operator):
|
||||
|
||||
body = ifcopenshell.util.representation.get_representation(element, "Model", "Body", "MODEL_VIEW")
|
||||
blenderbim.core.geometry.switch_representation(
|
||||
tool.Ifc,
|
||||
tool.Geometry,
|
||||
obj=obj,
|
||||
representation=body,
|
||||
|
||||
@@ -502,6 +502,7 @@ def regenerate_profile_usage(usecase_path, ifc_file, settings):
|
||||
representation = ifcopenshell.util.representation.get_representation(element, "Model", "Body", "MODEL_VIEW")
|
||||
if representation:
|
||||
blenderbim.core.geometry.switch_representation(
|
||||
tool.Ifc,
|
||||
tool.Geometry,
|
||||
obj=obj,
|
||||
representation=representation,
|
||||
|
||||
@@ -180,6 +180,7 @@ class DumbProfileGenerator:
|
||||
"geometry.assign_representation", tool.Ifc.get(), product=element, representation=representation
|
||||
)
|
||||
blenderbim.core.geometry.switch_representation(
|
||||
tool.Ifc,
|
||||
tool.Geometry,
|
||||
obj=obj,
|
||||
representation=representation,
|
||||
|
||||
@@ -201,6 +201,7 @@ class DumbSlabGenerator:
|
||||
)
|
||||
|
||||
blenderbim.core.geometry.switch_representation(
|
||||
tool.Ifc,
|
||||
tool.Geometry,
|
||||
obj=obj,
|
||||
representation=representation,
|
||||
|
||||
@@ -294,6 +294,7 @@ class ChangeExtrusionXAngle(bpy.types.Operator, tool.Ifc.Operator):
|
||||
wall_objs.append(obj)
|
||||
else:
|
||||
blenderbim.core.geometry.switch_representation(
|
||||
tool.Ifc,
|
||||
tool.Geometry,
|
||||
obj=obj,
|
||||
representation=representation,
|
||||
@@ -648,6 +649,7 @@ class DumbWallGenerator:
|
||||
"geometry.assign_representation", tool.Ifc.get(), product=element, representation=representation
|
||||
)
|
||||
blenderbim.core.geometry.switch_representation(
|
||||
tool.Ifc,
|
||||
tool.Geometry,
|
||||
obj=obj,
|
||||
representation=representation,
|
||||
@@ -874,6 +876,7 @@ class DumbWallJoiner:
|
||||
|
||||
body = ifcopenshell.util.representation.get_representation(element1, "Model", "Body", "MODEL_VIEW")
|
||||
blenderbim.core.geometry.switch_representation(
|
||||
tool.Ifc,
|
||||
tool.Geometry,
|
||||
obj=wall1,
|
||||
representation=body,
|
||||
@@ -1184,6 +1187,7 @@ class DumbWallJoiner:
|
||||
blenderbim.core.geometry.edit_object_placement(tool.Ifc, tool.Geometry, tool.Surveyor, obj=obj)
|
||||
|
||||
blenderbim.core.geometry.switch_representation(
|
||||
tool.Ifc,
|
||||
tool.Geometry,
|
||||
obj=obj,
|
||||
representation=new_body,
|
||||
|
||||
@@ -106,6 +106,7 @@ def replace_representation_for_object(ifc_file, ifc_context, obj, new_representa
|
||||
for inverse in ifc_file.get_inverse(old_representation):
|
||||
ifcopenshell.util.element.replace_attribute(inverse, old_representation, new_representation)
|
||||
core.switch_representation(
|
||||
tool.Ifc,
|
||||
tool.Geometry,
|
||||
obj=obj,
|
||||
representation=new_representation,
|
||||
|
||||
@@ -78,6 +78,7 @@ class AddOpening(bpy.types.Operator, tool.Ifc.Operator):
|
||||
|
||||
representation = tool.Ifc.get().by_id(obj1.data.BIMMeshProperties.ifc_definition_id)
|
||||
blenderbim.core.geometry.switch_representation(
|
||||
tool.Ifc,
|
||||
tool.Geometry,
|
||||
obj=obj1,
|
||||
representation=representation,
|
||||
@@ -113,6 +114,7 @@ class RemoveOpening(bpy.types.Operator, tool.Ifc.Operator):
|
||||
ifcopenshell.api.run("void.remove_opening", tool.Ifc.get(), opening=opening)
|
||||
|
||||
blenderbim.core.geometry.switch_representation(
|
||||
tool.Ifc,
|
||||
tool.Geometry,
|
||||
obj=obj,
|
||||
representation=tool.Ifc.get().by_id(obj.data.BIMMeshProperties.ifc_definition_id),
|
||||
|
||||
@@ -79,6 +79,7 @@ def add_representation(
|
||||
|
||||
|
||||
def switch_representation(
|
||||
ifc,
|
||||
geometry,
|
||||
obj=None,
|
||||
representation=None,
|
||||
@@ -108,6 +109,7 @@ def switch_representation(
|
||||
geometry.delete_data(existing_data)
|
||||
|
||||
geometry.clear_modifiers(obj)
|
||||
geometry.clear_cache(ifc.get_entity(obj))
|
||||
|
||||
|
||||
def get_representation_ifc_parameters(geometry, obj=None, should_sync_changes_first=False):
|
||||
|
||||
@@ -410,7 +410,6 @@ class Qto:
|
||||
def calculate_object_quantities(cls, calculator, baste_qto, object): pass
|
||||
def add_object_base_qto(cls, object): pass
|
||||
def add_product_base_qto(cls, product): pass
|
||||
def get_applicable_base_quantity_names(cls, product): pass
|
||||
def get_new_calculated_quantity(cls, qto_name, quantity_name, object): pass
|
||||
def get_new_guessed_quantity(cls, object, qto_name, quantity_name, ): pass
|
||||
|
||||
@@ -658,7 +657,6 @@ class Unit:
|
||||
def export_unit_attributes(cls): pass
|
||||
def get_scene_unit_name(cls, unit_type): pass
|
||||
def get_scene_unit_si_prefix(cls): pass
|
||||
def get_si_name_from_unit_type(cls, unit_type): pass
|
||||
def import_unit_attributes(cls, unit): pass
|
||||
def import_units(cls): pass
|
||||
def is_scene_unit_metric(cls): pass
|
||||
|
||||
@@ -32,5 +32,5 @@ class Patch(blenderbim.core.tool.Patch):
|
||||
@classmethod
|
||||
def run_migrate_patch(cls, infile, outfile, schema):
|
||||
log = os.path.join(bpy.context.scene.BIMProperties.data_dir, "process.log")
|
||||
output = ifcpatch.execute({"input": ifcopenshell.open(infile), "recipe": "Migrate", "arguments": [schema]})
|
||||
output = ifcpatch.execute({"input": infile, "file": ifcopenshell.open(infile), "recipe": "Migrate", "arguments": [schema]})
|
||||
ifcpatch.write(output, outfile)
|
||||
|
||||
@@ -101,6 +101,7 @@ class Type(blenderbim.core.tool.Type):
|
||||
cls, obj=None, representation=None, should_reload=None, is_global=None
|
||||
):
|
||||
return blenderbim.core.geometry.switch_representation(
|
||||
tool.Ifc,
|
||||
tool.Geometry,
|
||||
obj=obj,
|
||||
representation=representation,
|
||||
|
||||
@@ -190,7 +190,7 @@ class TestAddRepresentation:
|
||||
|
||||
|
||||
class TestSwitchRepresentation:
|
||||
def test_switching_to_a_freshly_loaded_representation(self, geometry):
|
||||
def test_switching_to_a_freshly_loaded_representation(self, ifc, geometry):
|
||||
geometry.is_edited("obj").should_be_called().will_return(False)
|
||||
geometry.resolve_mapped_representation("mapped_rep").should_be_called().will_return("representation")
|
||||
geometry.get_representation_data("representation").should_be_called().will_return(None)
|
||||
@@ -200,7 +200,10 @@ class TestSwitchRepresentation:
|
||||
geometry.link("representation", "new_data").should_be_called()
|
||||
geometry.change_object_data("obj", "new_data", is_global=True).should_be_called()
|
||||
geometry.clear_modifiers("obj").should_be_called()
|
||||
ifc.get_entity("obj").should_be_called().will_return("element")
|
||||
geometry.clear_cache("element").should_be_called()
|
||||
subject.switch_representation(
|
||||
ifc,
|
||||
geometry,
|
||||
obj="obj",
|
||||
representation="mapped_rep",
|
||||
@@ -209,7 +212,7 @@ class TestSwitchRepresentation:
|
||||
should_sync_changes_first=True,
|
||||
)
|
||||
|
||||
def test_switching_to_a_reloaded_representation_and_deleting_the_existing_data(self, geometry):
|
||||
def test_switching_to_a_reloaded_representation_and_deleting_the_existing_data(self, ifc, geometry):
|
||||
geometry.is_edited("obj").should_be_called().will_return(False)
|
||||
geometry.resolve_mapped_representation("mapped_rep").should_be_called().will_return("representation")
|
||||
geometry.get_representation_data("representation").should_be_called().will_return("existing_data")
|
||||
@@ -220,7 +223,10 @@ class TestSwitchRepresentation:
|
||||
geometry.change_object_data("obj", "new_data", is_global=True).should_be_called()
|
||||
geometry.delete_data("existing_data").should_be_called()
|
||||
geometry.clear_modifiers("obj").should_be_called()
|
||||
ifc.get_entity("obj").should_be_called().will_return("element")
|
||||
geometry.clear_cache("element").should_be_called()
|
||||
subject.switch_representation(
|
||||
ifc,
|
||||
geometry,
|
||||
obj="obj",
|
||||
representation="mapped_rep",
|
||||
@@ -229,13 +235,16 @@ class TestSwitchRepresentation:
|
||||
should_sync_changes_first=True,
|
||||
)
|
||||
|
||||
def test_switching_to_an_existing_representation(self, geometry):
|
||||
def test_switching_to_an_existing_representation(self, ifc, geometry):
|
||||
geometry.is_edited("obj").should_be_called().will_return(False)
|
||||
geometry.resolve_mapped_representation("mapped_rep").should_be_called().will_return("representation")
|
||||
geometry.get_representation_data("representation").should_be_called().will_return("data")
|
||||
geometry.change_object_data("obj", "data", is_global=True).should_be_called()
|
||||
geometry.clear_modifiers("obj").should_be_called()
|
||||
ifc.get_entity("obj").should_be_called().will_return("element")
|
||||
geometry.clear_cache("element").should_be_called()
|
||||
subject.switch_representation(
|
||||
ifc,
|
||||
geometry,
|
||||
obj="obj",
|
||||
representation="mapped_rep",
|
||||
@@ -244,7 +253,7 @@ class TestSwitchRepresentation:
|
||||
should_sync_changes_first=True,
|
||||
)
|
||||
|
||||
def test_updating_a_representation_if_the_blender_object_has_been_edited_prior_to_switching(self, geometry):
|
||||
def test_updating_a_representation_if_the_blender_object_has_been_edited_prior_to_switching(self, ifc, geometry):
|
||||
geometry.is_edited("obj").should_be_called().will_return(True)
|
||||
geometry.is_box_representation("mapped_rep").should_be_called().will_return(False)
|
||||
geometry.get_representation_id("mapped_rep").should_be_called().will_return("representation_id")
|
||||
@@ -254,7 +263,10 @@ class TestSwitchRepresentation:
|
||||
geometry.get_representation_data("representation").should_be_called().will_return("data")
|
||||
geometry.change_object_data("obj", "data", is_global=False).should_be_called()
|
||||
geometry.clear_modifiers("obj").should_be_called()
|
||||
ifc.get_entity("obj").should_be_called().will_return("element")
|
||||
geometry.clear_cache("element").should_be_called()
|
||||
subject.switch_representation(
|
||||
ifc,
|
||||
geometry,
|
||||
obj="obj",
|
||||
representation="mapped_rep",
|
||||
@@ -270,6 +282,7 @@ class TestSwitchRepresentation:
|
||||
geometry.run_geometry_update_representation(obj="obj").should_be_called()
|
||||
geometry.does_representation_id_exist("representation_id").should_be_called().will_return(False)
|
||||
subject.switch_representation(
|
||||
ifc,
|
||||
geometry,
|
||||
obj="obj",
|
||||
representation="mapped_rep",
|
||||
|
||||
@@ -54,7 +54,7 @@ class TestImportProjectedCRS(NewFile):
|
||||
projected_crs.VerticalDatum = "VerticalDatum"
|
||||
projected_crs.MapProjection = "MapProjection"
|
||||
projected_crs.MapZone = "MapZone"
|
||||
unit = ifcopenshell.api.run("unit.add_si_unit", ifc, unit_type="LENGTHUNIT", name="METRE")
|
||||
unit = ifcopenshell.api.run("unit.add_si_unit", ifc, unit_type="LENGTHUNIT")
|
||||
projected_crs.MapUnit = unit
|
||||
subject.import_projected_crs()
|
||||
props = bpy.context.scene.BIMGeoreferenceProperties
|
||||
@@ -206,7 +206,7 @@ class TestGetCursorLocation(NewFile):
|
||||
tool.Ifc.set(ifc)
|
||||
ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcProject")
|
||||
ifcopenshell.api.run("context.add_context", ifc, context_type="Model")
|
||||
unit = ifcopenshell.api.run("unit.add_si_unit", ifc, unit_type="LENGTHUNIT", prefix="MILLI", name="METRE")
|
||||
unit = ifcopenshell.api.run("unit.add_si_unit", ifc, unit_type="LENGTHUNIT", prefix="MILLI")
|
||||
ifcopenshell.api.run("unit.assign_unit", ifc, units=[unit])
|
||||
bpy.context.scene.cursor.location = (1.0, 2.0, 3.0)
|
||||
assert subject.get_cursor_location() == [1000.0, 2000.0, 3000.0]
|
||||
@@ -218,7 +218,7 @@ class TestSetCursorLocation(NewFile):
|
||||
tool.Ifc.set(ifc)
|
||||
ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcProject")
|
||||
ifcopenshell.api.run("context.add_context", ifc, context_type="Model")
|
||||
unit = ifcopenshell.api.run("unit.add_si_unit", ifc, unit_type="LENGTHUNIT", prefix="MILLI", name="METRE")
|
||||
unit = ifcopenshell.api.run("unit.add_si_unit", ifc, unit_type="LENGTHUNIT", prefix="MILLI")
|
||||
ifcopenshell.api.run("unit.assign_unit", ifc, units=[unit])
|
||||
subject.set_cursor_location([1000.0, 2000.0, 3000.0])
|
||||
assert list(bpy.context.scene.cursor.location) == [1.0, 2.0, 3.0]
|
||||
|
||||
@@ -39,22 +39,3 @@ class TestSetQtoResult(test.bim.bootstrap.NewFile):
|
||||
def test_run(self):
|
||||
subject.set_qto_result(123.4567)
|
||||
assert bpy.context.scene.BIMQtoProperties.qto_result == "123.457"
|
||||
|
||||
class TestGetPsetQtoObjectIfcInfo(test.bim.bootstrap.NewFile):
|
||||
def test_run(self):
|
||||
ifc = ifcopenshell.file()
|
||||
tool.Ifc.set(ifc)
|
||||
wall = ifc.createIfcWall()
|
||||
wall_obj = bpy.data.objects.new("Object", bpy.data.meshes.new("Mesh"))
|
||||
tool.Ifc.link(wall, wall_obj)
|
||||
pset_qto = ifcopenshell.api.run("pset.add_qto", ifc, product=wall, name="Qto_foo")
|
||||
assert subject.get_pset_qto_object_ifc_info(wall_obj)['Qto_foo']['id'] == pset_qto.get_info()['id']
|
||||
assert list(subject.get_pset_qto_object_ifc_info(wall_obj).keys())[0] == pset_qto.get_info()['Name']
|
||||
|
||||
def test_isempty(self):
|
||||
ifc = ifcopenshell.file()
|
||||
tool.Ifc.set(ifc)
|
||||
wall = ifc.createIfcWall()
|
||||
wall_obj = bpy.data.objects.new("Object", bpy.data.meshes.new("Mesh"))
|
||||
tool.Ifc.link(wall, wall_obj)
|
||||
assert not subject.get_pset_qto_object_ifc_info(wall_obj) == True
|
||||
|
||||
@@ -42,7 +42,7 @@ class TestGetGlobalMatrix(test.bim.bootstrap.NewFile):
|
||||
def test_applying_an_object_placement_blender_offset(self):
|
||||
ifc = ifcopenshell.file()
|
||||
ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcProject")
|
||||
unit = ifcopenshell.api.run("unit.add_si_unit", ifc, unit_type="LENGTHUNIT", name="METRE", prefix="MILLI")
|
||||
unit = ifcopenshell.api.run("unit.add_si_unit", ifc, unit_type="LENGTHUNIT", prefix="MILLI")
|
||||
ifcopenshell.api.run("unit.assign_unit", ifc, units=[unit])
|
||||
tool.Ifc.set(ifc)
|
||||
props = bpy.context.scene.BIMGeoreferenceProperties
|
||||
|
||||
@@ -165,7 +165,7 @@ class TestImportSystems(NewFile):
|
||||
zone = ifc.createIfcZone()
|
||||
subject.import_systems()
|
||||
props = bpy.context.scene.BIMSystemProperties
|
||||
assert len(props.systems) == 1
|
||||
assert len(props.systems) == 2
|
||||
assert props.systems[0].ifc_definition_id == system.id()
|
||||
assert props.systems[0].name == "Unnamed"
|
||||
assert props.systems[0].ifc_class == "IfcDistributionSystem"
|
||||
|
||||
Reference in New Issue
Block a user