After updating blender I cant use a script node (SN) from someone else that I was using before. Now sverchok has script node lite (SNL). I dont know what I need to change for it to work, and cant find documentation on the changes either. (at the time of writing there's no documentation on the existence of SNL, just SN)

Can anyone point me to information about this?


Somewhat related questions:

Is there a way to use Sverchok's ScriptNode without defining in_sockets? (links to SNL doc in a github issue)

Custom NodeTree and NodeCustomGroup and bpy.ops.node.tree_path_parent()

Has anyone started a project similar to Grasshopper (Rhino) for blender?

How do I build an object using Python and predetermined coordinates?

Can custom nodes be written for the compositor?


I found conversions other users have performed, and diffed the two versions to check the changes they made. They only seem to change the syntax of the input/output in such a way that sv_main is no longer used:

  • every item in the lists in_sockets and out_sockets is now defined at the start inside bracketed (""") comments with the commands in and out
  • after the in / out command the variable name is given, followed by the variable type
  • the in variables also get a d default value, which was in sv_main before, and an n value of 1 or 2
  • if the default value is [] then n=1 otherwise n=2 (I dont know the meaning of this)
  • all code in sv_main is just executed at the end of the script and the def and return lines are just deleted

For instance

in_sockets = [
    ['s', 'maximum branches', npoints],
    ['s', 'branch length', dist],
    ['s', 'minimum distance', min_dist],
    ['s', 'maximum distance', max_dist],
    ['s', 'tip radius', tip_radius], 
    ['v', 'tropism', trop],
    ['v', 'End Vertices',  verts_in],
    ['v', 'Start Vertices', verts_start]

def sv_main(npoints=100 , dist=0.05, min_dist=0.05, max_dist=2.0, tip_radius=0.01, trop=[], verts_in=[], verts_start=[]):
    out_sockets = [
        ['v', 'Vertices', [verts_out]],
        ['s', 'Edges', [edges_out]],
        ['s', 'Branch radii', [rad_out]],
        ['s', 'Ends mask', [ends_out]],
        ['m', 'Leaf matrices', mats_out],
    #some code
return in_sockets, out_sockets

Is converted to

in npoints s d=100 n=2
in dist s d=0.05 n=2
in min_dist s d=0.05 n=2
in max_dist s d=2.0 n=2
in tip_radius s d=0.01 n=2
in tropism v d=[] n=1
in verts_in v d=[] n=1
in verts_start v d=[] n=1
out verts_out v 
out edges_out s 
out rad_out s
out ends_out s
out leaf_mats m
#some code

I took these code snippets from a sverchok script by elfnor, so thanks to her for the example!


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.