From 129ecb72cf9d57c0f426d0d1ddeabee2cd13d392 Mon Sep 17 00:00:00 2001 From: "florentin.luce" Date: Thu, 13 Jun 2024 11:58:41 +0200 Subject: [PATCH] fix texture plane by importing nodegroup --- import_planes/core.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/import_planes/core.py b/import_planes/core.py index 7b63bb8..44726d6 100644 --- a/import_planes/core.py +++ b/import_planes/core.py @@ -8,10 +8,11 @@ import time from pathlib import Path from mathutils import Vector, geometry from pprint import pprint as pp -from ..constants import PREFIX, BGCOL, INIT_POS +from ..constants import PREFIX, BGCOL, INIT_POS, MODULE_DIR from ..core import (create_cam, set_collection, get_image_infos_from_object, get_col, import_image_as_gp_reference, create_image_plane, set_collection, get_image, - create_empty_image, create_plane_holder, create_plane_driver, reload_bg_list) + create_empty_image, create_plane_holder, create_plane_driver, reload_bg_list, + link_nodegroup) def get_json_infos(json_path) -> tuple((list, tuple)): @@ -118,7 +119,11 @@ def import_planes(images, import_type='GPENCIL', mode='REPLACE', image_size=None pack_image=False, ) elif import_type == 'MESH': - bg_img = create_image_plane(image_path) + if not (texture_plane_ng := bpy.data.node_groups.get('texture_plane')): + blend = str(MODULE_DIR / 'texture_plane.blend') + texture_plane_ng = link_nodegroup(blend, 'texture_plane', link=False) + + bg_img = create_image_plane(image_path, texture_plane_ng) elif import_type == 'EMPTY': bg_img = create_empty_image(image_path)