fix: relocate cannot work on missing layer
fix: import fail if label are all zero fix: add cutter name to node fix: cannot append node lib file on NAS (UNC path) fix: join component cause disappear feat: smooth label feat: better topo on cutout by range
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
from pathlib import Path
|
||||
import bpy
|
||||
|
||||
from .common import get_file_prop, get_node_lib_path, set_file_prop
|
||||
from ..exceptions import Incompatible, NoFound
|
||||
from .common import get_file_prop, set_file_prop
|
||||
from ..exceptions import NoFound
|
||||
|
||||
from ..constants import LATEST_NODE_LIB_PATH, VERSIONS
|
||||
|
||||
|
||||
def get_node_group(node_type: str, use_link=True):
|
||||
def get_node_tree(node_type: str, use_link=True):
|
||||
# unannotate below for local debug in node lib file.
|
||||
# node_group = bpy.data.node_groups[node_type]
|
||||
# return node_group
|
||||
@@ -19,36 +19,37 @@ def get_node_group(node_type: str, use_link=True):
|
||||
if get_file_prop("node_version") is None:
|
||||
set_file_prop("node_version", addon_version)
|
||||
|
||||
local_lib_path = None
|
||||
local_lib = None
|
||||
for node_group in bpy.data.node_groups:
|
||||
if node_group.name.startswith("BioxelNodes"):
|
||||
lib = node_group.library
|
||||
if lib:
|
||||
lib_path = Path(bpy.path.abspath(lib.filepath)).resolve()
|
||||
if lib_path != addon_lib_path:
|
||||
local_lib_path = lib_path
|
||||
local_lib = lib.filepath
|
||||
break
|
||||
|
||||
# local lib first
|
||||
lib_path = local_lib_path or addon_lib_path
|
||||
bpy.ops.wm.append('EXEC_DEFAULT',
|
||||
directory=f"{lib_path.as_posix()}/NodeTree",
|
||||
filename=node_type,
|
||||
link=use_link,
|
||||
use_recursive=True,
|
||||
do_reuse_local_id=True)
|
||||
node_group = bpy.data.node_groups.get(node_type)
|
||||
lib_path_str = local_lib or str(addon_lib_path)
|
||||
|
||||
if node_group is None:
|
||||
with bpy.data.libraries.load(lib_path_str,
|
||||
link=use_link,
|
||||
relative=True) as (data_from, data_to):
|
||||
data_to.node_groups = [n for n in data_from.node_groups
|
||||
if n == node_type]
|
||||
|
||||
node_tree = data_to.node_groups[0]
|
||||
|
||||
if node_tree is None:
|
||||
raise NoFound('No custom node found')
|
||||
|
||||
return node_group
|
||||
return node_tree
|
||||
|
||||
|
||||
def assign_node_group(node, node_type: str):
|
||||
node.node_tree = bpy.data.node_groups[node_type]
|
||||
def assign_node_tree(node, node_tree):
|
||||
node.node_tree = node_tree
|
||||
node.width = 200.0
|
||||
node.name = node_type
|
||||
node.name = node_tree.name
|
||||
return node
|
||||
|
||||
|
||||
@@ -61,9 +62,9 @@ def add_node_to_graph(node_name: str, node_group, node_label=None, use_link=True
|
||||
if node.select:
|
||||
node.select = False
|
||||
|
||||
get_node_group(node_type, use_link)
|
||||
node_tree = get_node_tree(node_type, use_link)
|
||||
node = node_group.nodes.new("GeometryNodeGroup")
|
||||
assign_node_group(node, node_type)
|
||||
assign_node_tree(node, node_tree)
|
||||
|
||||
node.label = node_label
|
||||
node.show_options = False
|
||||
|
||||
Reference in New Issue
Block a user