Skip to content

Commit 3239313

Browse files
committed
Support external shaders from currently opened blend file
Previously it was crashing if you try use shader from current .blend file as external. I guess we now kind of support external internal shaders 🙃
1 parent c7b3331 commit 3239313

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

src/blenderbim/blenderbim/tool/blender.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import ifcopenshell.api
2121
import blenderbim.tool as tool
2222
from mathutils import Vector
23+
from pathlib import Path
2324

2425

2526
class Blender:
@@ -253,6 +254,12 @@ def select_and_activate_single_object(cls, context, active_object):
253254

254255
@classmethod
255256
def append_data_block(cls, filepath, data_block_type, name, link=False, relative=False):
257+
if Path(filepath) == Path(bpy.data.filepath):
258+
data_block = getattr(bpy.data, data_block_type).get(name, None)
259+
if not data_block:
260+
return {"data_block": None, "msg": f"Data-block {data_block_type}/{name} not found in {filepath}"}
261+
return {"data_block": data_block.copy(), "msg": ""}
262+
256263
with bpy.data.libraries.load(filepath, link=link, relative=relative) as (data_from, data_to):
257264
if name not in getattr(data_from, data_block_type):
258265
return {"data_block": None, "msg": f"Data-block {data_block_type}/{name} not found in {filepath}"}

0 commit comments

Comments
 (0)