Skip to content

Commit

Permalink
bim.duplicate_style
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrej730 committed Apr 23, 2024
1 parent cd01307 commit 3ff31b5
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/blenderbim/blenderbim/bim/module/style/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
operator.DisableAddingPresentationStyle,
operator.DisableEditingStyle,
operator.DisableEditingStyles,
operator.DuplicateStyle,
operator.EditStyle,
operator.EditSurfaceStyle,
operator.EnableAddingPresentationStyle,
Expand Down
16 changes: 16 additions & 0 deletions src/blenderbim/blenderbim/bim/module/style/operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,22 @@ def _execute(self, context):
props.is_adding = True


class DuplicateStyle(bpy.types.Operator, tool.Ifc.Operator):
bl_idname = "bim.duplicate_style"
bl_label = "Duplicate Style"
bl_options = {"REGISTER", "UNDO"}

style: bpy.props.IntProperty(name="Style ID")

def _execute(self, context):
style_type = context.scene.BIMStylesProperties.style_type
ifc_file = tool.Ifc.get()
style = ifc_file.by_id(self.style)
tool.Style.duplicate_style(style)
bpy.ops.bim.disable_editing_styles()
bpy.ops.bim.load_styles(style_type=style_type)


class DisableAddingPresentationStyle(bpy.types.Operator, tool.Ifc.Operator):
bl_idname = "bim.disable_adding_presentation_style"
bl_label = "Disable Add Presentation Style"
Expand Down
1 change: 1 addition & 0 deletions src/blenderbim/blenderbim/bim/module/style/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ def draw(self, context):

op = row.operator("bim.enable_editing_style", text="Edit Style", icon="GREASEPENCIL")
op.style = style.ifc_definition_id
row.operator("bim.duplicate_style", text="", icon="DUPLICATE").style = style.ifc_definition_id
row.operator("bim.select_by_style", text="", icon="RESTRICT_SELECT_OFF").style = style.ifc_definition_id
row.operator("bim.remove_style", text="", icon="X").style = style.ifc_definition_id

Expand Down
5 changes: 5 additions & 0 deletions src/blenderbim/blenderbim/tool/style.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import bpy
import numpy as np
import ifcopenshell
import ifcopenshell.util.element
import blenderbim.core.tool
import blenderbim.tool as tool
import blenderbim.bim.helper
Expand Down Expand Up @@ -59,6 +60,10 @@ def disable_editing_external_style(cls, obj):
def disable_editing_styles(cls):
bpy.context.scene.BIMStylesProperties.is_editing = False

@classmethod
def duplicate_style(cls, style: ifcopenshell.entity_instance) -> ifcopenshell.entity_instance:
return ifcopenshell.util.element.copy_deep(tool.Ifc.get(), style)

@classmethod
def enable_editing(cls, obj):
obj.BIMStyleProperties.is_editing = True
Expand Down

0 comments on commit 3ff31b5

Please sign in to comment.