mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
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 🙃
This commit is contained in:
@@ -20,6 +20,7 @@ import bpy
|
||||
import ifcopenshell.api
|
||||
import blenderbim.tool as tool
|
||||
from mathutils import Vector
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
class Blender:
|
||||
@@ -253,6 +254,12 @@ class Blender:
|
||||
|
||||
@classmethod
|
||||
def append_data_block(cls, filepath, data_block_type, name, link=False, relative=False):
|
||||
if Path(filepath) == Path(bpy.data.filepath):
|
||||
data_block = getattr(bpy.data, data_block_type).get(name, None)
|
||||
if not data_block:
|
||||
return {"data_block": None, "msg": f"Data-block {data_block_type}/{name} not found in {filepath}"}
|
||||
return {"data_block": data_block.copy(), "msg": ""}
|
||||
|
||||
with bpy.data.libraries.load(filepath, link=link, relative=relative) as (data_from, data_to):
|
||||
if name not in getattr(data_from, data_block_type):
|
||||
return {"data_block": None, "msg": f"Data-block {data_block_type}/{name} not found in {filepath}"}
|
||||
|
||||
Reference in New Issue
Block a user