mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
Option to name existing used unnamed profiles
Example - https://imgur.com/a/IhMbs6K
This commit is contained in:
@@ -42,6 +42,7 @@ classes = (
|
||||
operator.FlipObject,
|
||||
operator.GetRepresentationIfcParameters,
|
||||
operator.ImportRepresentationItems,
|
||||
operator.NameProfile,
|
||||
operator.OverrideDelete,
|
||||
operator.OverrideDuplicateMove,
|
||||
operator.OverrideDuplicateMoveLinked,
|
||||
|
||||
@@ -2775,6 +2775,41 @@ class UpdateItemAttributes(bpy.types.Operator, tool.Ifc.Operator):
|
||||
tool.Root.reload_item_decorator()
|
||||
|
||||
|
||||
class NameProfile(bpy.types.Operator, tool.Ifc.Operator):
|
||||
bl_idname = "bim.name_profile"
|
||||
bl_label = "Name Profile"
|
||||
bl_description = "Add name to existing unnamed profile"
|
||||
bl_options = {"REGISTER", "UNDO", "INTERNAL"}
|
||||
|
||||
extrusion_item_obj: bpy.props.StringProperty(name="Extrusion Item Object Name")
|
||||
profile_name: bpy.props.StringProperty(
|
||||
name="Profile Name",
|
||||
options={"SKIP_SAVE"},
|
||||
)
|
||||
|
||||
def invoke(self, context, event):
|
||||
return context.window_manager.invoke_props_dialog(self)
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
layout.prop(self, "profile_name")
|
||||
|
||||
def _execute(self, context):
|
||||
if not self.profile_name:
|
||||
self.report({"INFO"}, "Profile name is not provided")
|
||||
return {"CANCELLED"}
|
||||
|
||||
ifc_file = tool.Ifc.get()
|
||||
extrusion_item_obj = bpy.data.objects[self.extrusion_item_obj]
|
||||
mesh_props = extrusion_item_obj.data.BIMMeshProperties
|
||||
extrusion = ifc_file.by_id(mesh_props.ifc_definition_id)
|
||||
assert extrusion.is_a("IfcSweptAreaSolid")
|
||||
profile = extrusion.SweptArea
|
||||
profile.ProfileName = self.profile_name
|
||||
bonsai.bim.handler.refresh_ui_data() # Ensure enum is up to date.
|
||||
mesh_props.item_profile = str(profile.id())
|
||||
|
||||
|
||||
class AddMeshlikeItem(bpy.types.Operator, tool.Ifc.Operator):
|
||||
bl_idname = "bim.add_meshlike_item"
|
||||
bl_label = "Add Meshlike Item"
|
||||
|
||||
@@ -285,8 +285,11 @@ class EditItemUI:
|
||||
|
||||
mesh_props = obj.data.BIMMeshProperties
|
||||
if cls.get_item_object_class(obj) == "IfcExtrudedAreaSolid":
|
||||
row = cls.layout.row()
|
||||
row = cls.layout.row(align=True)
|
||||
row.prop(mesh_props, "item_profile")
|
||||
if mesh_props.item_profile == "-":
|
||||
op = row.operator("bim.name_profile", text="", icon="TAG")
|
||||
op.extrusion_item_obj = obj.name
|
||||
|
||||
for item_attribute in obj.data.BIMMeshProperties.item_attributes:
|
||||
row = cls.layout.row()
|
||||
|
||||
Reference in New Issue
Block a user