- Freedom to code, only try to follow pep8, and avoid abuse.
- Agile software development - look http://en.wikipedia.org/wiki/Agile_software_development here.
- Ideas from other addons to implement to sverchok. It is big deal.
- If you making something it is better to say in issues before.
- Brainstorming and finding solutions. We are mostly new in python and programming, we are artists.
What not to do:¶
Doing these things will break old layouts and or create very ugly code in the node.
- Change .bl_idname of a node
- Remove or rename sockets
- Adding new socket without updating upgrade.py
- ‘current_mode’ names of properties are reserved for nodes, not use for anything else
In blender console you can easily inspect the sverchok system by writing:
import sverchok print(dir(sverchok.nodes))
To create a node:¶
- Make a scripted node to test the idea.
- Show your node to us in an issue or silently create branch or fork of master in github. If it is huge complex job we can make you collaborator.
- Copy an existing node that is similar.
- Change class name, class id, class description, class registration in your file
- Add node id in menu.py in an approritate category.
- Add file to category that you need
- Add in
- Tell us to merge branches/forks
All classes that are subclasses of blender classes - have to have prefix Sv, ie SvColors.
node_tree.py contains base classes of node tree and, maybe you need to create collection property or new socket (for new type of socket tell us first), you make it here.
data_structure.py has magic of:
update definitions, that works pretty well with sockets’ and nodes’ updates
some bmesh functiones
cache – operates with handles – we use it to operate with nodes’ data, it is dictionary, with node’name, node-tree’name and it’s data
- list levels definitions - you must yse them:
data correct makes list from chaotic to 4th levels list, seems like [[[floats/integers]]] and not [[f/i]] or [[[[f/i]]]].
dataCorrect(data, nominal_dept=2), where data - is your list, nominal_depth - optioal, normal for your’ case depth of list
data spoil - make list more nasty for value of depth
dataSpoil(data, dept), where data - your list, depth - level of nestynessing. Gives list from  to [] etc
Levels of list - find level of nestiness.
levelsOflist(list) - returns level of list nestiness [] - is 2,  - 1, [[]] - 3
matrix definitions - to make something with matrices/vertices
- Matrix_generate(prop) - make from simple list real mathutils.Matrix(()()()())
- Matrix_listing(prop) - make from mathutils.Matrix() simple list like [] with container is [[]]
- Matrix_location(prop, list=False) - return mathutils.Vector() of matrix’ location
- Matrix_scale(prop, list=False) - the same, but returns matrix’ scale vectors
- Matrix_rotation(prop, list=False) - return rotation axis and rotation angle in radians value as tuple (Vector((x,y,z)),angle)
- Vector_generate(prop) - makes from simple list real mathutils.Vector(), as Matrix generate def
- Vector_degenerate(prop) - as matrix listing, it degenerate Vectors to simple list
- Edg_pol_generate(prop) - define wether it is edges or polygons in list, and terurns tuple as (type,list)
- matrixdef(orig, loc, scale, rot, angle, vec_angle=[]) - defines matrix
- fullList(l, count) - makes list full till some count. last item multiplied to rest of needed length, ie [1,2,3,4] for count 6 will be [1,2,3,4,4,4]
- match_short(lsts) Shortest list decides output length [[1,2,3,4,5], [10,11]] -> [[1,2], [10, 11]]
- match_cross2(lsts) cross rference [[1,2], [5,6,7]] ->[[1, 2, 1, 2, 1, 2], [5, 5, 6, 6, 7, 7]]
- match_long_repeat(lsts) repeat last of shorter list [[1,2,3,4,5] ,[10,11]] -> [[1,2,3,4,5] ,[10,11,10,11,10]]
- match_long_cycle(lsts) cycle shorts lists [[1,2,3,4,5] ,[10,11]] -> [[1,2,3,4,5] ,[10,11,10,11,10]]
- repeat_last(lst) creates an infinite iterator that repeats last item of list, for cycle see itertools.cycle
- some others to operate with exact nodes
update sockets - definitions to operate with update
changable type of socket - makes possible to use changable socket in your node - it calling
- node has to have self veriables:
- and in update:
- inputsocketname = ‘data’ # ‘data’ - name of your input socket, that defines type
- outputsocketname = [‘dataTrue’,’dataFalse’] # ‘data...’ - are names of your sockets to be changed
- changable_sockets(self, inputsocketname, outputsocketname)
multi-socket multi_socket(node,min=1) - as used by ListJoin, List Zip, Connect UV
base_name = ‘data’
multi_socket_type = ‘StringsSocket’
setup the fixed number of socket you need, the last of them is the first multi socket. minimum of one.
then in update(self):
- multi_socket(self, min=1, start=0, breck=False) - [where min - minimum count of input sockets;
- start - starting of numeration, could be -1, -2 to start as in formula2 node; breck - to make breckets, as used in formula2 node]
for more details see files mentioned above
Utils folder has:
- CADmodule - to provide lines intersection
- IndexViewerDraw - to provide OpenGL drawing of INDXview node in basics
- sv_bmeshutils - self say name
- sv_tools - it is toolbox in node area for update button, upgrade button and for layers visibility buttons, also update node and upgrade functional to automate this process.
- text_editor_plugins - for sandbox node scripted node (SN) to implement Ctrl+I auto complete function
- text_editor_submenu - templates of SN
- upgrade - to avoid breaking old layouts. Defines new simplified interface override. if you change some property in def draw_buttons() than just bring new properties here to avoid break old layout
- viewer_draw - for draw and handle OpenGL of Viewer Draw node (have to be remaked)
- voronoi - for delaunai and voronoi functions of correspond nodes
Node scripts folder for every template for SN (see utils-e.)
Nodes folder for categorized nodes. not forget to write your nodes to init.py there
- To use enumerate property you have to assign index to items, never change the index of items added,
it will break if you add more functions.
Not make many nodes if you can do less multifunctional.
Use levels, findout how it works and use level IntProperty in draw to define what level is to operate. We operate with 1,2,3 - standart and additional 4... infinity. make sure, that your levels limited, dropped down by levelsOflist as maximum value
Keep order in node’ update definition as if output: if input. To count input only if you have output socket assembled.
Look at todo list to know what is happening on and what you can do. use your nodes and test them.
There is no reason to auto wrap or make less levels of wrapping, than needed to proceed in other nodes. So, for now canonical will be [[0,1,2,3]] for simple data and [[[0,1,2,3]]] for real data as edge, vertex, matrix other cases may be more nasty, but not less nesty and wrapping need to be grounded on some reasons to be provided.
Do not use is_linked to test if socket is linked in
def update(self), check links. In
to CHANGE some node, please, follow next:
- Put old node file to ../old_nodes add the corresponding bl_idname in __init__.py in the table. (there is README file also);
- Make new changed node as mk2(3,4...n) and place to where old node was placed with all changes as new node, change name and bl_idname (look ‘To create a node:’ in current instructions).