Users copying and pasting via ctrl-c/v will now also copy IFC objects.

This commit is contained in:
Dion Moult
2021-10-26 17:36:58 +11:00
parent 34e8d9563d
commit 955a9af461
3 changed files with 57 additions and 0 deletions
@@ -26,6 +26,8 @@ classes = (
operator.GetRepresentationIfcParameters,
operator.OverrideDelete,
operator.OverrideDuplicateMove,
operator.OverrideDuplicateMoveLinked,
operator.OverridePasteBuffer,
operator.RemoveRepresentation,
operator.SwitchRepresentation,
operator.UpdateParametricRepresentation,
@@ -38,11 +40,26 @@ classes = (
)
addon_keymaps = []
def register():
bpy.types.Scene.BIMGeometryProperties = bpy.props.PointerProperty(type=prop.BIMGeometryProperties)
bpy.types.OBJECT_PT_transform.append(ui.BIM_PT_transform)
wm = bpy.context.window_manager
if wm.keyconfigs.addon:
km = wm.keyconfigs.addon.keymaps.new(name="3D View", space_type="VIEW_3D")
kmi = km.keymap_items.new("bim.override_paste_buffer", "V", "PRESS", ctrl=True)
kmi.properties["name"] = "bim.override_paste_buffer"
addon_keymaps.append((km, kmi))
def unregister():
bpy.types.OBJECT_PT_transform.remove(ui.BIM_PT_transform)
del bpy.types.Scene.BIMGeometryProperties
wm = bpy.context.window_manager
kc = wm.keyconfigs.addon
if kc:
for km, kmi in addon_keymaps:
km.keymap_items.remove(kmi)
addon_keymaps.clear()
@@ -500,3 +500,14 @@ class OverrideDuplicateMoveLinked(bpy.types.Operator):
bpy.ops.transform.translate("INVOKE_DEFAULT")
blenderbim.bim.handler.purge_module_data()
return {"FINISHED"}
class OverridePasteBuffer(bpy.types.Operator):
bl_idname = "bim.override_paste_buffer"
bl_label = "Paste BIM Objects"
def execute(self, context):
bpy.ops.view3d.pastebuffer()
for obj in context.selected_objects:
blenderbim.core.root.copy_class(tool.Ifc, tool.Collector, tool.Geometry, tool.Root, obj=obj)
return {"FINISHED"}
@@ -271,3 +271,32 @@ Scenario: Override duplicate move linked - with active IFC data
And the object "IfcWall/Cube.001" has a "Tessellation" representation of "Model/Body/MODEL_VIEW"
And the object "IfcBuildingStorey/My Storey.001" exists
And the object "IfcBuildingStorey/My Storey.001" is an "IfcBuildingStorey"
Scenario: Override paste buffer - without active IFC data
Given an empty Blender session
And I add a cube
And I add an empty
And the object "Cube" is selected
And additionally the object "Empty" is selected
When I press "view3d.copybuffer"
And I press "bim.override_paste_buffer"
Then the object "Cube" exists
And the object "Cube.001" exists
Scenario: Override paste buffer - with active IFC data
Given an empty IFC project
And I add a cube
And the object "Cube" is selected
And I set "scene.BIMRootProperties.ifc_class" to "IfcWall"
And I press "bim.assign_class"
And the object "IfcWall/Cube" is selected
And additionally the object "IfcBuildingStorey/My Storey" is selected
When I press "view3d.copybuffer"
And I press "bim.override_paste_buffer"
Then the object "IfcWall/Cube" exists
And the object "IfcWall/Cube" is an "IfcWall"
And the object "IfcWall/Cube.001" exists
And the object "IfcWall/Cube.001" is an "IfcWall"
And the object "IfcWall/Cube.001" has a "Tessellation" representation of "Model/Body/MODEL_VIEW"
And the object "IfcBuildingStorey/My Storey.001" exists
And the object "IfcBuildingStorey/My Storey.001" is an "IfcBuildingStorey"