Skip to content

Instantly share code, notes, and snippets.

@zeffii
Forked from anonymous/ui_ops4_.py
Created May 6, 2014 13:58
Show Gist options
  • Save zeffii/f5d7c7e15d97d5669302 to your computer and use it in GitHub Desktop.
Save zeffii/f5d7c7e15d97d5669302 to your computer and use it in GitHub Desktop.
import json
def sv_main(items_in=[]):
in_sockets = [
['v', 'items_in', items_in]]
Verts = []
def func1():
# directly from incoming Object_in socket.
sn = bpy.context.node
print(items_in)
# safe? or return early
if not (sn.inputs and sn.inputs[0].links):
msg = 'no input socket, or nothing connected'
print(dir(sn))
return
# will try to find objects_local in from_node, else return None
obj_in = sn.inputs[0].links[0].from_node
obj_names = obj_in.get('objects_local', None)
if not obj_names:
return
obj_names = ast.literal_eval(obj_names)
verts = SvGetSocketAnyType(sn, sn.inputs['items_in'])
obj_dict = {}
for idx, obj_name in enumerate(obj_names):
obj_dict[obj_name] = {'verts': verts[idx]}
json_string = json.dumps(obj_dict)
print(json_string)
# return json_string
out_sockets = [['v', 'Verts', [Verts]]]
ui_operators = [['print_names', func1]]
return in_sockets, out_sockets, ui_operators
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment