mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-12 02:23:34 +00:00
Quick way to select profile in profiles UI
Example - https://imgchest.com/p/9rydakllwyk
This commit is contained in:
@@ -297,6 +297,8 @@ class BIM_PT_object_material(Panel):
|
||||
and ObjectMaterialData.data["material_class"] != "IfcMaterialList"
|
||||
):
|
||||
if "Profile" in ObjectMaterialData.data["material_class"]:
|
||||
op = row.operator("bim.profiles_ui_select", icon="ZOOM_SELECTED", text="")
|
||||
op.profile_id = set_item["id"]
|
||||
op = row.operator("bim.enable_editing_material_set_item_profile", icon="ITALIC", text="")
|
||||
op.material_set_item = set_item["id"]
|
||||
op = row.operator("bim.enable_editing_material_set_item", icon="GREASEPENCIL", text="")
|
||||
|
||||
@@ -31,6 +31,7 @@ classes = (
|
||||
operator.EnableEditingProfile,
|
||||
operator.LoadProfiles,
|
||||
operator.RemoveProfileDef,
|
||||
operator.SelectProfileInProfilesUI,
|
||||
prop.Profile,
|
||||
prop.BIMProfileProperties,
|
||||
ui.BIM_PT_profiles,
|
||||
|
||||
@@ -274,3 +274,28 @@ class EditArbitraryProfile(bpy.types.Operator, tool.Ifc.Operator):
|
||||
props.active_arbitrary_profile_id = 0
|
||||
|
||||
model_profile.DumbProfileRegenerator().regenerate_from_profile_def(profile)
|
||||
|
||||
|
||||
class SelectProfileInProfilesUI(bpy.types.Operator):
|
||||
bl_idname = "bim.profiles_ui_select"
|
||||
bl_label = "Select Profile In Profiles UI"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
profile_id: bpy.props.IntProperty()
|
||||
|
||||
def execute(self, context):
|
||||
props = bpy.context.scene.BIMProfileProperties
|
||||
ifc_file = tool.Ifc.get()
|
||||
profile = ifc_file.by_id(self.profile_id)
|
||||
bpy.ops.bim.load_profiles()
|
||||
|
||||
profile_index = next((i for i, m in enumerate(props.profiles) if m.ifc_definition_id == self.profile_id), None)
|
||||
if profile_index is None:
|
||||
self.report({"INFO"}, "Profile not found in Profiles UI. Perhaps it's unnamed?")
|
||||
return {"CANCELLED"}
|
||||
|
||||
props.active_profile_index = profile_index
|
||||
self.report(
|
||||
{"INFO"},
|
||||
f"Profile '{profile.Name or 'Unnamed'}' is selected in Profiles UI.",
|
||||
)
|
||||
return {"FINISHED"}
|
||||
|
||||
Reference in New Issue
Block a user