Skip to content

Instantly share code, notes, and snippets.

@zeffii
Created January 24, 2018 19:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zeffii/d1db56a487aef0a12b0e61e1ddb95919 to your computer and use it in GitHub Desktop.
Save zeffii/d1db56a487aef0a12b0e61e1ddb95919 to your computer and use it in GitHub Desktop.
import bpy
import sverchok
import re
from sverchok.utils.logging import info
remaps = """\
Colors|Color
Edges|Edge
Edgs|Edge
Normals|Normal
Numbers|Number
Objects|Object
Objs|Object
Obj|Object
Vectors|Vector
Vertices|Vertex
Vert|Vertex
Verts|Vertex
Randomize|Random
Outputs|Output
Out|Output
Inputs|Input
Properties|Property
Props|Property
Prop|Property
Pols|Polygon
Pols2|Polygon
Triangulation2|Triangulate
Converter|Convert
Gen|Generator
Float2|Float
Dview|Viz
Hilbert3d|Hilbert
Item2|Item
In|Input
Out|Output
Bvh|BVH
"""
remap_dict = {tag: replacer for tag, replacer in [item.split('|') for item in remaps.split()]}
def depluralize(tag_set):
for tag, replacer in remap_dict.items():
if tag in tag_set:
tag_set.remove(tag)
tag_set.update({replacer})
def remove_if_present(set_name, item=None, pattern=None, contains=None):
if item:
if item in set_name:
set_name.remove(item)
elif pattern or contains:
items_to_remove = set()
if pattern:
for named_item in set_name:
if named_item.lower().startswith(pattern):
items_to_remove.add(named_item)
elif contains:
for named_item in set_name:
if contains.lower() in named_item.lower():
items_to_remove.add(named_item)
for named_item in items_to_remove:
set_name.remove(named_item)
def get_tags_from_nodename(Node):
tags = re.findall('[A-Z0-9]*[a-z0-9]*', Node.name)
tags_set = set([i for i in list(tags) if i]) # drop empty item
known_items = ["Sv", "sv", "Sv3", "Special", "New", "", "Alt"]
for known in known_items:
remove_if_present(tags_set, known)
remove_if_present(tags_set, pattern='mk')
remove_if_present(tags_set, contains='node')
depluralize(tags_set)
# if item ends in a number remove it.
return tags_set
def get_tags_from_path(Node):
path = Node.ref.__module__.split('.')[2].title()
return set([path])
node_tags = {}
for node in sverchok.utils.node_classes.items():
Node = lambda: None
Node.ref = node[1]
Node.name = node[0]
tags_set = get_tags_from_nodename(Node)
tags_set.update(get_tags_from_path(Node))
# Node.tags = tags_set
node_tags[Node.name] = tags_set
all_tags = set()
for tags in node_tags.values():
all_tags.update(tags)
print(sorted(all_tags))
@zeffii
Copy link
Author

zeffii commented Jan 24, 2018

['Adaptive', 'Along', 'Analyzer', 'Angles', 'Apply', 'Arc', 'Area', 'Array', 'Art', 'Asset', 'Attractor', 'Axis', 'BBox', 'BMOps', 'BMVerts', 'BMinput', 'BMoutput', 'BMto', 'BVH', 'Basic', 'Bend', 'Bevel', 'Bisect', 'Bmesh', 'Bmesh_Nodes', 'Boom', 'Box', 'Bricks', 'CSGBoolean', 'Cache', 'Cast', 'Centers', 'Circle', 'Client', 'Color', 'Components', 'Connect', 'Contour', 'Convert', 'Convex', 'Cross', 'Curve', 'Cylinder', 'Data', 'Debug', 'Decompose', 'Deform', 'Del', 'Delaunay', 'Delete', 'Dissolve', 'Distance', 'Doubles', 'Drop', 'Dupli', 'Duplicate', 'Easing', 'Edge', 'Edit', 'Element', 'Elman1', 'Empty', 'Euler', 'Eval', 'Evaluate', 'Exec', 'Exp', 'Exponential', 'Extrude', 'Fibonacci', 'Field', 'Fills', 'Filter', 'Flip', 'Float', 'Formula', 'Formula2', 'Fractal', 'Frame', 'Func', 'GText', 'Generative', 'Generator', 'Generators_Extended', 'Generic', 'Get', 'Grease', 'Grid', 'Group', 'Heavy', 'Hexa', 'Hilbert', 'Hole', 'Homogenous', 'Hull', 'Icosphere', 'Image', 'Index', 'Info', 'Input', 'Inset', 'Inside', 'Instancer', 'Instances', 'Int', 'Integer', 'Interpolation', 'Intersect', 'Item', 'Iterate', 'Join', 'KDTree', 'Knot', 'Lacunarity', 'Lathe', 'Layout', 'Length', 'Lerp', 'Levels', 'Limited', 'Line', 'List', 'List_Main', 'List_Masks', 'List_Mutators', 'List_Struct', 'Lite', 'Logic', 'Loose', 'Map', 'Mask', 'Match', 'Math', 'Matrix', 'Mesh', 'Metaball', 'Mirror', 'Mix', 'Mod', 'Modifier', 'Modifier_Change', 'Modifier_Make', 'Monad', 'Move', 'Multi', 'NGon', 'Network', 'Neuro', 'Noise', 'Normal', 'Note', 'Num', 'Number', 'Numpy', 'OBJRay', 'Object', 'Object_Nodes', 'Offset', 'On', 'Output', 'Overlap', 'Particles', 'Path', 'Pencil', 'Pipe', 'Plane', 'Point', 'Polar', 'Polygon', 'Polyline', 'Print', 'Profile', 'Property', 'Proportional', 'Random', 'Range', 'Raycaster', 'Recalc', 'Region', 'Remote', 'Remove', 'Repeater', 'Reverse', 'Rewire', 'Ring', 'Rnd', 'Rotation', 'Rounded', 'SCNRay', 'Scalar', 'Scale', 'Scene', 'Script', 'Sculpt', 'Section', 'Select', 'Separate', 'Set', 'Shape', 'Shear', 'Shift', 'Shuffle', 'Similar', 'Simple', 'Skin', 'Slice', 'Smooth', 'Solidify', 'Sort', 'Sphere', 'Spiral', 'Spline', 'Split', 'Stethoscope', 'Stripes', 'Strokes', 'Subdivide', 'Sum', 'Surface', 'Suzanne', 'Switch', 'Text', 'Texture', 'To', 'Torus', 'Track', 'Transform', 'Transforms', 'Triangles', 'Triangulate', 'Tube', 'Turbulence', 'Type', 'UVtexture', 'Udp', 'Value', 'Vector', 'Vertex', 'Viewer', 'Viz', 'Volume', 'Voronoi2', 'Wafel', 'Wifi', 'Wireframe', 'Zip']

@Ribel78
Copy link

Ribel78 commented Jan 25, 2018

Looking at the list now makes more clear which topics the nodes cover.
I think it is better to be in alphabetical order as are they now.
You can additionally merge similar words into common tags:

'Bmesh', 'Bmesh_Nodes' - Bmesh
'Del', ..., 'Delete' ? - Delete
'Dupli', 'Duplicate' - Duplicate
'Eval', 'Evaluate' - Evaluate
'Exp', 'Exponential' - Exponential
'Formula', 'Formula2' - Formula
'Generator', 'Generators_Extended' - Generator
'List', 'List_Main', 'List_Masks', 'List_Mutators', 'List_Struct', - List
'Mod' ???, 'Modifier', 'Modifier_Change', 'Modifier_Make' - Modifier
'Num', 'Number', - Number
'OBJRay', 'Object', 'Object_Nodes' - Object

The amount of keywords is not that big for single column of buttons (linearly) in the Tool Shelf.
It will be interesting if a floating panel can display the words as shown above (rectangular form)?
A person who is new to Sverchok or exploring it would like to see visually what is there, before switching to the faster menu search, just because he will know that his search will have a hit.
If this doesn't make in Blender, what about in the Sverchok documentation?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment