mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-25 09:32:37 +00:00
bim.duplicate_profile
simple operator for profile duplication example - https://imgur.com/a/dsP78iV
This commit is contained in:
@@ -21,6 +21,7 @@ from . import ui, prop, operator, data
|
|||||||
|
|
||||||
classes = (
|
classes = (
|
||||||
operator.AddProfileDef,
|
operator.AddProfileDef,
|
||||||
|
operator.DuplicateProfileDef,
|
||||||
operator.DisableEditingArbitraryProfile,
|
operator.DisableEditingArbitraryProfile,
|
||||||
operator.DisableEditingProfile,
|
operator.DisableEditingProfile,
|
||||||
operator.DisableProfileEditingUI,
|
operator.DisableProfileEditingUI,
|
||||||
|
|||||||
@@ -132,6 +132,27 @@ class AddProfileDef(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
bpy.ops.bim.load_profiles()
|
bpy.ops.bim.load_profiles()
|
||||||
|
|
||||||
|
|
||||||
|
class DuplicateProfileDef(bpy.types.Operator, tool.Ifc.Operator):
|
||||||
|
bl_idname = "bim.duplicate_profile_def"
|
||||||
|
bl_label = "Duplicate Profile"
|
||||||
|
bl_options = {"REGISTER", "UNDO"}
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def poll(cls, context):
|
||||||
|
props = context.scene.BIMProfileProperties
|
||||||
|
if len(props.profiles) > props.active_profile_index:
|
||||||
|
return True
|
||||||
|
cls.poll_message_set("No profile selected to duplicate.")
|
||||||
|
return False
|
||||||
|
|
||||||
|
def _execute(self, context):
|
||||||
|
props = context.scene.BIMProfileProperties
|
||||||
|
ifc_file = tool.Ifc.get()
|
||||||
|
profile = ifc_file.by_id(props.profiles[props.active_profile_index].ifc_definition_id)
|
||||||
|
tool.Profile.duplicate_profile(profile)
|
||||||
|
bpy.ops.bim.load_profiles()
|
||||||
|
|
||||||
|
|
||||||
class EnableEditingArbitraryProfile(bpy.types.Operator, tool.Ifc.Operator):
|
class EnableEditingArbitraryProfile(bpy.types.Operator, tool.Ifc.Operator):
|
||||||
bl_idname = "bim.enable_editing_arbitrary_profile"
|
bl_idname = "bim.enable_editing_arbitrary_profile"
|
||||||
bl_label = "Enable Editing Arbitrary Profile"
|
bl_label = "Enable Editing Arbitrary Profile"
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ class BIM_PT_profiles(Panel):
|
|||||||
row = self.layout.row(align=True)
|
row = self.layout.row(align=True)
|
||||||
row.prop(self.props, "profile_classes", text="")
|
row.prop(self.props, "profile_classes", text="")
|
||||||
row.operator("bim.add_profile_def", text="", icon="ADD")
|
row.operator("bim.add_profile_def", text="", icon="ADD")
|
||||||
|
row.operator("bim.duplicate_profile_def", icon="DUPLICATE", text="")
|
||||||
|
|
||||||
self.layout.template_list(
|
self.layout.template_list(
|
||||||
"BIM_UL_profiles",
|
"BIM_UL_profiles",
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
# along with BlenderBIM Add-on. If not, see <http://www.gnu.org/licenses/>.
|
# along with BlenderBIM Add-on. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import ifcopenshell
|
import ifcopenshell
|
||||||
|
import ifcopenshell.util.element
|
||||||
import ifcopenshell.util.unit
|
import ifcopenshell.util.unit
|
||||||
import ifcopenshell.util.placement
|
import ifcopenshell.util.placement
|
||||||
import ifcopenshell.util.representation
|
import ifcopenshell.util.representation
|
||||||
@@ -75,3 +76,7 @@ class Profile(blenderbim.core.tool.Profile):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def get_model_profiles(cls):
|
def get_model_profiles(cls):
|
||||||
return tool.Ifc.get().by_type("IfcProfileDef")
|
return tool.Ifc.get().by_type("IfcProfileDef")
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def duplicate_profile(cls, profile: ifcopenshell.entity_instance) -> ifcopenshell.entity_instance:
|
||||||
|
return ifcopenshell.util.element.copy_deep(tool.Ifc.get(), profile)
|
||||||
|
|||||||
Reference in New Issue
Block a user