mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 02:02:22 +00:00
Editiing arbitrary profile without enabling editing profile
It was a bit confusing UX since when you finish editing arbitrary profile path the data is already saved in ifc but you were still in editing profile properties
This commit is contained in:
@@ -131,14 +131,15 @@ class EnableEditingArbitraryProfile(bpy.types.Operator, tool.Ifc.Operator):
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
||||
def _execute(self, context):
|
||||
for obj in context.selected_objects:
|
||||
obj.select_set(False)
|
||||
props = context.scene.BIMProfileProperties
|
||||
profile = tool.Ifc.get().by_id(props.active_profile_id)
|
||||
active_profile = props.profiles[props.active_profile_index]
|
||||
profile_id = active_profile.ifc_definition_id
|
||||
props.active_arbitrary_profile_id = profile_id
|
||||
profile = tool.Ifc.get().by_id(profile_id)
|
||||
obj = tool.Model.import_profile(profile)
|
||||
tool.Ifc.link(profile, obj)
|
||||
bpy.context.scene.collection.objects.link(obj)
|
||||
bpy.context.view_layer.objects.active = obj
|
||||
tool.Blender.select_and_activate_single_object(context, obj)
|
||||
bpy.ops.object.mode_set(mode="EDIT")
|
||||
ProfileDecorator.install(context, exit_edit_mode_callback=lambda: disable_editing_arbitrary_profile(context))
|
||||
bpy.ops.wm.tool_set_by_id(tool.Blender.get_viewport_context(), name="bim.cad_tool")
|
||||
@@ -153,6 +154,8 @@ def disable_editing_arbitrary_profile(context):
|
||||
bpy.data.objects.remove(obj)
|
||||
bpy.data.meshes.remove(profile_mesh)
|
||||
|
||||
props = context.scene.BIMProfileProperties
|
||||
props.active_arbitrary_profile_id = 0
|
||||
# need to update profile manager ui
|
||||
# if this was called from decorator
|
||||
refresh()
|
||||
@@ -174,7 +177,7 @@ class EditArbitraryProfile(bpy.types.Operator, tool.Ifc.Operator):
|
||||
|
||||
def _execute(self, context):
|
||||
props = context.scene.BIMProfileProperties
|
||||
old_profile = tool.Ifc.get().by_id(props.active_profile_id)
|
||||
old_profile = tool.Ifc.get().by_id(props.active_arbitrary_profile_id)
|
||||
|
||||
obj = context.active_object
|
||||
|
||||
@@ -194,6 +197,7 @@ class EditArbitraryProfile(bpy.types.Operator, tool.Ifc.Operator):
|
||||
bpy.ops.object.mode_set(mode="EDIT")
|
||||
return
|
||||
|
||||
prev_profile_id = profile.id()
|
||||
profile_mesh = obj.data
|
||||
bpy.data.objects.remove(obj)
|
||||
bpy.data.meshes.remove(profile_mesh)
|
||||
@@ -204,6 +208,8 @@ class EditArbitraryProfile(bpy.types.Operator, tool.Ifc.Operator):
|
||||
ifcopenshell.util.element.replace_attribute(inverse, old_profile, profile)
|
||||
ifcopenshell.util.element.remove_deep2(tool.Ifc.get(), old_profile)
|
||||
bpy.ops.bim.load_profiles()
|
||||
props.active_profile_id = profile.id()
|
||||
if props.active_profile_id == prev_profile_id:
|
||||
props.active_profile_id = profile.id()
|
||||
props.active_arbitrary_profile_id = 0
|
||||
|
||||
model_profile.DumbProfileRegenerator().regenerate_from_profile_def(profile)
|
||||
|
||||
@@ -54,6 +54,7 @@ class BIMProfileProperties(PropertyGroup):
|
||||
profiles: CollectionProperty(name="Profiles", type=Profile)
|
||||
active_profile_index: IntProperty(name="Active Profile Index")
|
||||
active_profile_id: IntProperty(name="Active Profile Id")
|
||||
active_arbitrary_profile_id: IntProperty(name="Active Arbitrary Profile Id")
|
||||
profile_attributes: CollectionProperty(name="Profile Attributes", type=Attribute)
|
||||
profile_classes: EnumProperty(items=get_profile_classes, name="Profile Classes")
|
||||
|
||||
|
||||
@@ -42,10 +42,12 @@ class BIM_PT_profiles(Panel):
|
||||
ProfileData.load()
|
||||
self.props = context.scene.BIMProfileProperties
|
||||
|
||||
active_profile = None
|
||||
if self.props.is_editing and self.props.profiles and self.props.active_profile_index < len(self.props.profiles):
|
||||
preview_collection = ProfileData.preview_collection
|
||||
box = self.layout.box()
|
||||
profile_id = self.props.profiles[self.props.active_profile_index].ifc_definition_id
|
||||
active_profile = self.props.profiles[self.props.active_profile_index]
|
||||
profile_id = active_profile.ifc_definition_id
|
||||
profile_id_str = str(profile_id)
|
||||
if profile_id_str in preview_collection:
|
||||
preview_image = preview_collection[profile_id_str]
|
||||
@@ -77,19 +79,19 @@ class BIM_PT_profiles(Panel):
|
||||
self.props,
|
||||
"active_profile_index",
|
||||
)
|
||||
if active_profile and active_profile.ifc_class == "IfcArbitraryClosedProfileDef":
|
||||
if self.props.active_arbitrary_profile_id:
|
||||
row = self.layout.row(align=True)
|
||||
row.operator("bim.edit_arbitrary_profile", text="Save Arbitrary Profile", icon="CHECKMARK")
|
||||
row.operator("bim.disable_editing_arbitrary_profile", text="", icon="CANCEL")
|
||||
else:
|
||||
row = self.layout.row()
|
||||
row.operator("bim.enable_editing_arbitrary_profile", text="Edit Arbitrary Profile", icon="GREASEPENCIL")
|
||||
|
||||
if self.props.active_profile_id:
|
||||
self.draw_editable_ui(context)
|
||||
|
||||
def draw_editable_ui(self, context):
|
||||
if ProfileData.data["is_arbitrary_profile"]:
|
||||
if ProfileData.data["is_editing_arbitrary_profile"]:
|
||||
row = self.layout.row(align=True)
|
||||
row.operator("bim.edit_arbitrary_profile", text="Save Profile", icon="CHECKMARK")
|
||||
row.operator("bim.disable_editing_arbitrary_profile", text="", icon="CANCEL")
|
||||
else:
|
||||
row = self.layout.row()
|
||||
row.operator("bim.enable_editing_arbitrary_profile", text="Edit Profile", icon="GREASEPENCIL")
|
||||
blenderbim.bim.helper.draw_attributes(self.props.profile_attributes, self.layout)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user