deprecate shading_checksum #4843

Changing diffuse color for Blender material now won't change the linked IFC style.

Since now all style parameters for styles are changed through styles UI and users shouldn't use Blender materials tab unless they want to do something advanced (though they are still currently can use it to assign material styles to the specific faces).

PS 1 less thing to sync 🥳
This commit is contained in:
Andrej730
2024-06-25 15:50:04 +05:00
parent 8172096a5b
commit ef9bbd8de6
10 changed files with 4 additions and 32 deletions
+2 -2
View File
@@ -118,8 +118,8 @@ class IfcExporter:
continue
try:
if isinstance(obj, bpy.types.Material):
if tool.Ifc.has_changed_shading(obj):
blenderbim.core.style.update_style_colours(tool.Ifc, tool.Style, obj=obj)
# TODO: do we add materials to edited_objs?
continue
else:
element = tool.Ifc.get_entity(obj)
if element:
-5
View File
@@ -84,11 +84,6 @@ def name_callback(obj, data):
refresh_ui_data()
def color_callback(obj, data):
if obj.BIMMaterialProperties.ifc_style_id:
tool.Ifc.edit(obj)
def active_object_callback():
refresh_ui_data()
update_bim_tool_props()
+2 -6
View File
@@ -249,9 +249,7 @@ class IfcStore:
blenderbim.bim.handler.subscribe_to(obj, "name", blenderbim.bim.handler.name_callback)
if isinstance(obj, bpy.types.Material):
blenderbim.bim.handler.subscribe_to(obj, "diffuse_color", blenderbim.bim.handler.color_callback)
elif isinstance(obj, bpy.types.Object):
if isinstance(obj, bpy.types.Object):
blenderbim.bim.handler.subscribe_to(
obj, "active_material_index", blenderbim.bim.handler.active_material_index_callback
)
@@ -277,9 +275,7 @@ class IfcStore:
if "guid" in data:
IfcStore.guid_map[data["guid"]] = obj
blenderbim.bim.handler.subscribe_to(obj, "name", blenderbim.bim.handler.name_callback)
if isinstance(obj, bpy.types.Material):
blenderbim.bim.handler.subscribe_to(obj, "diffuse_color", blenderbim.bim.handler.color_callback)
elif isinstance(obj, bpy.types.Object):
if isinstance(obj, bpy.types.Object):
blenderbim.bim.handler.subscribe_to(
obj, "active_material_index", blenderbim.bim.handler.active_material_index_callback
)
@@ -287,7 +287,6 @@ def update_shading_style(self, context):
switch_shading(blender_material, self.active_style_type)
elif self.active_style_type == "Shading":
switch_shading(blender_material, self.active_style_type)
tool.Style.record_shading(blender_material)
class BIMStyleProperties(PropertyGroup):
-2
View File
@@ -103,8 +103,6 @@ def update_style_colours(ifc: tool.Ifc, style: tool.Style, obj: bpy.types.Materi
else:
ifc.run("style.add_surface_style", style=element, ifc_class="IfcSurfaceStyleShading", attributes=attributes)
style.record_shading(obj)
def update_style_textures(
ifc: tool.Ifc, style: tool.Style, obj: ifcopenshell.entity_instance, representation: ifcopenshell.entity_instance
-1
View File
@@ -951,7 +951,6 @@ class Style:
def import_presentation_styles(cls, style_type): pass
def import_surface_attributes(cls, style, obj): pass
def is_editing_styles(cls): pass
def record_shading(cls, obj): pass
@interface
-6
View File
@@ -51,11 +51,6 @@ class Ifc(blenderbim.core.tool.Ifc):
if IfcStore.get_file():
return IfcStore.get_file().schema
@classmethod
def has_changed_shading(cls, obj: bpy.types.Material) -> bool:
checksum = obj.BIMMaterialProperties.shading_checksum
return checksum != repr(np.array(obj.diffuse_color).tobytes())
@classmethod
def is_edited(cls, obj: bpy.types.Object) -> bool:
return list(obj.scale) != [1.0, 1.0, 1.0] or obj in IfcStore.edited_objs
@@ -157,7 +152,6 @@ class Ifc(blenderbim.core.tool.Ifc):
IfcStore.id_map[style.id()] = obj
blenderbim.bim.handler.subscribe_to(obj, "name", blenderbim.bim.handler.name_callback)
blenderbim.bim.handler.subscribe_to(obj, "diffuse_color", blenderbim.bim.handler.color_callback)
@classmethod
def link(cls, element: ifcopenshell.entity_instance, obj: IFC_CONNECTED_TYPE) -> None:
-4
View File
@@ -526,10 +526,6 @@ class Style(blenderbim.core.tool.Style):
def is_editing_styles(cls) -> bool:
return bpy.context.scene.BIMStylesProperties.is_editing
@classmethod
def record_shading(cls, obj: bpy.types.Material) -> None:
obj.BIMMaterialProperties.shading_checksum = repr(np.array(obj.diffuse_color).tobytes())
@classmethod
def select_elements(cls, elements: list[ifcopenshell.entity_instance]) -> None:
for element in elements:
-1
View File
@@ -172,7 +172,6 @@ def i_add_a_new_collection_item(collection):
def the_material_name_colour_is_set_to_colour(name, colour):
obj = the_material_name_exists(name)
obj.diffuse_color = [float(c) for c in colour.split(",")]
blenderbim.bim.handler.color_callback(obj, None)
@given("I add an array modifier")
-4
View File
@@ -85,7 +85,6 @@ class TestUpdateStyleColours:
ifc.run("style.add_surface_textures", material="obj").should_be_called().will_return("textures")
ifc.run("style.edit_surface_style", style="texture_style", attributes={"Textures": "textures"}).should_be_called().will_return("textures")
style.record_shading("obj").should_be_called()
subject.update_style_colours(ifc, style, obj="obj", verbose="verbose")
def test_adding_a_rendering_style_if_not_available(self, ifc, style):
@@ -107,7 +106,6 @@ class TestUpdateStyleColours:
attributes={"Textures": "textures"},
).should_be_called()
style.record_shading("obj").should_be_called()
subject.update_style_colours(ifc, style, obj="obj", verbose="verbose")
def test_updating_shading_style_as_a_fallback_if_available(self, ifc, style):
@@ -116,7 +114,6 @@ class TestUpdateStyleColours:
style.get_surface_shading_style("obj").should_be_called().will_return("style")
style.get_surface_shading_attributes("obj").should_be_called().will_return("attributes")
ifc.run("style.edit_surface_style", style="style", attributes="attributes").should_be_called()
style.record_shading("obj").should_be_called()
subject.update_style_colours(ifc, style, obj="obj")
def test_adding_a_shading_style_as_a_fallback_if_not_available(self, ifc, style):
@@ -127,7 +124,6 @@ class TestUpdateStyleColours:
ifc.run(
"style.add_surface_style", style="element", ifc_class="IfcSurfaceStyleShading", attributes="attributes"
).should_be_called()
style.record_shading("obj").should_be_called()
subject.update_style_colours(ifc, style, obj="obj")