Skip to content

Commit 64991cb

Browse files
author
bonsaiPR automation
committed
Merge remote-tracking branch 'pr-7669/clipboard-module' into build-0.8.6-alpha2608071253
2 parents 8510787 + 4bc21f8 commit 64991cb

6 files changed

Lines changed: 2053 additions & 2 deletions

File tree

src/bonsai/bonsai/bim/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
"light": None,
9393
"alignment": None,
9494
"clip_box": None,
95+
"clipboard": None,
9596
# Uncomment this line to enable loading of the demo module. Happy hacking!
9697
# The name "demo" must correlate to a folder name in `bim/module/`.
9798
# "demo": None,
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Bonsai - OpenBIM Blender Add-on
2+
# Copyright (C) 2022 Dion Moult <dion@thinkmoult.com>
3+
#
4+
# This file is part of Bonsai.
5+
#
6+
# Bonsai is free software: you can redistribute it and/or modify
7+
# it under the terms of the GNU General Public License as published by
8+
# the Free Software Foundation, either version 3 of the License, or
9+
# (at your option) any later version.
10+
#
11+
# Bonsai is distributed in the hope that it will be useful,
12+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
# GNU General Public License for more details.
15+
#
16+
# You should have received a copy of the GNU General Public License
17+
# along with Bonsai. If not, see <http://www.gnu.org/licenses/>.
18+
19+
import bpy
20+
from . import operator, prop, ui
21+
from bpy.app.handlers import persistent
22+
import os
23+
import bonsai.tool as tool
24+
25+
classes = (
26+
operator.CopyToClipboard,
27+
operator.PasteFromClipboard,
28+
prop.ClipboardSection,
29+
prop.BIMClipboardProperties,
30+
ui.BIM_PT_tab_clipboard,
31+
)
32+
33+
addon_keymaps = []
34+
35+
36+
@persistent
37+
def load_post_handler(dummy):
38+
clipboard_json = tool.Blender.get_data_dir_path("bonsai_clipboard.json").__str__()
39+
clipboard_ifc = tool.Blender.get_data_dir_path("bonsai_clipboard.ifc").__str__()
40+
41+
if os.path.exists(clipboard_json) and os.path.exists(clipboard_ifc):
42+
bpy.context.scene.BIMClipboardProperties.ensure_sections()
43+
44+
45+
def register():
46+
bpy.types.Scene.BIMClipboardProperties = bpy.props.PointerProperty(type=prop.BIMClipboardProperties)
47+
bpy.app.handlers.load_post.append(load_post_handler)
48+
49+
wm = bpy.context.window_manager
50+
if wm.keyconfigs.addon:
51+
km = wm.keyconfigs.addon.keymaps.new(name="Object Mode", space_type="EMPTY")
52+
kmi = km.keymap_items.new("bim.copy_to_clipboard", "C", "PRESS", ctrl=True)
53+
addon_keymaps.append((km, kmi))
54+
kmi = km.keymap_items.new("bim.paste_from_clipboard", "V", "PRESS", ctrl=True)
55+
addon_keymaps.append((km, kmi))
56+
57+
58+
def unregister():
59+
for km, kmi in addon_keymaps:
60+
km.keymap_items.remove(kmi)
61+
addon_keymaps.clear()
62+
63+
del bpy.types.Scene.BIMClipboardProperties
64+
if load_post_handler in bpy.app.handlers.load_post:
65+
bpy.app.handlers.load_post.remove(load_post_handler)
66+

0 commit comments

Comments
 (0)