You can now copy roof parameters from active to selected objects

This commit is contained in:
Gorgious56
2025-01-06 11:35:17 +01:00
parent 547c5fb8a9
commit f6e588b48c
4 changed files with 43 additions and 3 deletions
@@ -186,6 +186,7 @@ classes = (
roof.BIM_OT_add_roof,
roof.AddRoof,
roof.CancelEditingRoof,
roof.CopyRoofParameters,
roof.FinishEditingRoof,
roof.EnableEditingRoof,
roof.CancelEditingRoofPath,
@@ -569,6 +569,7 @@ class RoofData:
if not cls.data["pset_data"]:
return
cls.data["general_params"] = cls.general_params()
cls.data["path_data"] = cls.path_data()
@classmethod
def pset_data(cls):
@@ -589,6 +590,10 @@ class RoofData:
general_params[prop_readable_name] = prop_value
return general_params
@classmethod
def path_data(cls):
return cls.data["pset_data"]["data_dict"]["path_data"]
class ItemData:
data = {}
+36 -1
View File
@@ -438,7 +438,7 @@ def update_roof_modifier_bmesh(obj: bpy.types.Object) -> None:
# NOTE: using Data since bmesh update will hapen very often
if not RoofData.is_loaded:
RoofData.load()
path_data = RoofData.data["pset_data"]["data_dict"]["path_data"]
path_data = RoofData.data["path_data"]
angle_layer_data = path_data.get("gable_roof_angles", None)
separate_verts_data = path_data.get("gable_roof_separate_verts", None)
@@ -739,6 +739,41 @@ class CancelEditingRoofPath(bpy.types.Operator, tool.Ifc.Operator):
return cancel_editing_roof_path(context)
class CopyRoofParameters(bpy.types.Operator, tool.Ifc.Operator):
bl_idname = "bim.copy_roof_parameters"
bl_label = "Copy Roof Parameters from Active to Selected"
bl_options = {"REGISTER", "UNDO"}
@classmethod
def poll(cls, context):
return context.active_object and len(context.selected_objects) > 1
def _execute(self, context):
source_obj = context.active_object
source_props = source_obj.BIMRoofProperties
data = source_props.get_general_kwargs(convert_to_project_units=True)
for target_obj in context.selected_objects:
if target_obj == source_obj:
continue
context.view_layer.objects.active = target_obj
RoofData.load()
if not "path_data" in RoofData.data:
continue
data["path_data"] = RoofData.data["path_data"]
target_element = tool.Ifc.get_entity(target_obj)
target_props = target_obj.BIMRoofProperties
target_props.set_props_kwargs_from_ifc_data(data)
update_bbim_roof_pset(target_element, data)
refresh()
update_roof_modifier_bmesh(target_obj)
update_roof_modifier_ifc_data(context)
context.view_layer.objects.active = source_obj
return {"FINISHED"}
class FinishEditingRoofPath(bpy.types.Operator, tool.Ifc.Operator):
bl_idname = "bim.finish_editing_roof_path"
bl_label = "Finish Editing Roof Path"
+1 -2
View File
@@ -649,13 +649,12 @@ class BIM_PT_roof(bpy.types.Panel):
self.layout.prop(props, prop)
update_roof_modifier_bmesh(obj)
elif props.is_editing_path:
row.operator("bim.finish_editing_roof_path", icon="CHECKMARK", text="")
row.operator("bim.cancel_editing_roof_path", icon="CANCEL", text="")
else:
row.operator("bim.enable_editing_roof", icon="GREASEPENCIL", text="")
row.operator("bim.copy_roof_parameters", icon="COPYDOWN", text="")
row.operator("bim.enable_editing_roof_path", icon="ANIM", text="")
row.operator("bim.remove_roof", icon="X", text="")