Created
September 23, 2014 15:56
-
-
Save zeffii/eb593fc8be4b0b6ad596 to your computer and use it in GitHub Desktop.
from json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bpy | |
import json | |
import os | |
import ast | |
filename = 'node_tree.json' | |
location = 'C:\\blender_trunk' | |
fullpath = os.path.join(location, filename) | |
with open(fullpath) as fp: | |
f = json.load(fp) | |
nodegroup_params = { | |
'name': 'NodeTest2', | |
'type': 'SverchCustomTreeType'} | |
ng = bpy.data.node_groups.new(**nodegroup_params) | |
nodes = ng.nodes | |
print('first import all.') | |
for n in sorted(f): | |
print('adding {0}'.format(n)) | |
bl_idname = f[n]['bl_idname'] | |
# add node and set name. | |
# forget label for now. | |
node = nodes.new(bl_idname) | |
if not node.name == n: | |
node.name = n | |
node.location = f[n]['location'] | |
params = f[n]['params'] | |
for p in params: | |
# val = ast.literal_eval(params[p]) | |
val = params[p] | |
setattr(node, p, val) | |
print('first import all.') | |
for n in sorted(f): | |
print(n) | |
print('> ', f[n]['incoming']) | |
print('> ', f[n]['outgoing']) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment