-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathnode_group.py
39 lines (33 loc) · 1.18 KB
/
node_group.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# Nikita Akimov
#
# GitHub
# https://github.com/Korchy/BIS
# NodeGroup class
from . import cfg
from .node import Node
class NodeGroup:
@classmethod
def to_json(cls, node_group):
# base node_group specification
node_group_json = Node.to_json(node=node_group)
node_group_json['instance']['name'] = node_group.node_tree.name
node_group_json['instance']['type'] = node_group.type
return node_group_json
@classmethod
def from_json(cls, node_group_json, parent_node_tree, attachments_path):
node_group = None
try:
node_group = parent_node_tree.nodes.new(type=node_group_json['class'])
except Exception as exception:
if cfg.show_debug_err:
print(repr(exception))
if node_group:
Node.from_json(
node=node_group,
node_json=node_group_json,
attachments_path=attachments_path
)
# to prevent .001 in name of new node group if already exists some other nodes with this name
node_group.node_tree.name = node_group_json['instance']['name']
return node_group