mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-13 10:57:49 +00:00
You can now duplicate existing types in the type manager
This commit is contained in:
@@ -99,6 +99,8 @@ class LaunchTypeManager(bpy.types.Operator):
|
||||
op.ifc_class = relating_type["ifc_class"]
|
||||
op.relating_type_id = relating_type["id"]
|
||||
|
||||
op = row.operator("bim.duplicate_type", icon="COPYDOWN", text="")
|
||||
op.element = relating_type["id"]
|
||||
op = row.operator("bim.remove_type", icon="X", text="")
|
||||
op.element = relating_type["id"]
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ from . import ui, prop, operator
|
||||
classes = (
|
||||
operator.AssignType,
|
||||
operator.DisableEditingType,
|
||||
operator.DuplicateType,
|
||||
operator.EnableEditingType,
|
||||
operator.RemoveType,
|
||||
operator.SelectSimilarType,
|
||||
|
||||
@@ -23,6 +23,7 @@ import ifcopenshell.api
|
||||
import blenderbim.tool as tool
|
||||
import blenderbim.core.geometry
|
||||
import blenderbim.core.type as core
|
||||
import blenderbim.core.root
|
||||
from blenderbim.bim.ifc import IfcStore
|
||||
from ifcopenshell.api.type.data import Data
|
||||
from ifcopenshell.api.geometry.data import Data as GeometryData
|
||||
@@ -182,3 +183,23 @@ class RemoveType(bpy.types.Operator, tool.Ifc.Operator):
|
||||
tool.Ifc.unlink(obj=obj)
|
||||
bpy.data.objects.remove(obj)
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class DuplicateType(bpy.types.Operator, tool.Ifc.Operator):
|
||||
bl_idname = "bim.duplicate_type"
|
||||
bl_label = "Duplicate Type"
|
||||
bl_options = {"REGISTER"}
|
||||
element: bpy.props.IntProperty()
|
||||
|
||||
def _execute(self, context):
|
||||
element = tool.Ifc.get().by_id(self.element)
|
||||
obj = tool.Ifc.get_object(element)
|
||||
if not obj:
|
||||
return {"FINISHED"}
|
||||
new_obj = obj.copy()
|
||||
if obj.data:
|
||||
new_obj.data = obj.data.copy()
|
||||
new = blenderbim.core.root.copy_class(tool.Ifc, tool.Collector, tool.Geometry, tool.Root, obj=new_obj)
|
||||
new.Name += " Copy"
|
||||
bpy.ops.bim.load_type_thumbnails(ifc_class=new.is_a())
|
||||
return {"FINISHED"}
|
||||
|
||||
Reference in New Issue
Block a user