nortikin / sverchok

Sverchok
http://nortikin.github.io/sverchok/
GNU General Public License v3.0
2.26k stars 233 forks source link

Spreadsheet functionality #3639

Closed portnov closed 3 years ago

portnov commented 4 years ago

I'm not sure how exactly useful these things are, so at the moment I've put them to sverchok-extra master. These nodes do not require any dependencies; they can be easily moved to Sverchok, the only question is do we need them.

"Data Item" node.

This is similar to dictionary Out" node, but adopted to work with nested dictionaries. In node UI you select a "path" in the nested dictionary, and the node outputs the item. For example, you can calculate something likemy_dict['Boxes']['MyBox']['Width']`.

Screenshot_20201011_221322

Or, for one (not more than one) of the nested keys you can say "All keys", this will be something like my_dict[*]['Width'] or my_dict['Box1'][*]:

Screenshot_20201011_221423

"Spreadsheet" node.

This is more cumbersome. It allows you to input data in spreadsheet-like interface. Each row ("item") has user-provided name, and each column also. Columns to be used are configured in the N panel of the node. Supported types of columns are: integer, float, vector, boolean, string and formula. Most interesting is, off course, formula. It gives a possibility to do calculations in a way similar to LibreOffice or Excel (without aggregation functions). Python syntax is used, as usual in Sverchok. You can refer to other cells of the same spreadsheet as RowName.ColumnName. You can refer to other columns of the same row just as ColumnName. Special input socket named Input is supported for nested dictionaries input (e.g. you can plug another spreadsheet here); you can refer to items of that dictionary as Input.RowName.ColumnName. Any other variables (apart from well-known functions such as sin or pi) will automatically become additional inputs of the Spreadsheet node.

The node can output data in several ways:

Screenshot_20201011_223706

vicdoval commented 4 years ago

Seems very powerful, allows a not nodal behaviour in a nodal environment... also seems a bit confusing.. How did you create the "Center" item in the Center column? Anyhow we have a Dictionary Category in the menu with only two nodes so it wouldn't harm to have more... so I would say yes to bringing this functionalities to Sverchok

portnov commented 4 years ago

Columns are configured in the N panel: Screenshot_20201011_233426

Durman commented 4 years ago

When I was testing dictionaries I did not like node tree results they was too noddy. Data items nodes would definitely improve the situation but I think it will still require too much work of creating and linking nodes. Optimal solution could be create sockets right in nodes which should process the data. Example how this could look like. add sockets

portnov commented 4 years ago

Well, the problem I tried to address is the following. I noted that every non-trivial node tree consists of the following blocks:

  1. Input parameters. 5-10 "A Number", "Vector In" or similar nodes.
  2. Parameters calculations. 15+ "scalar math", "vector in", "vector math", "formula" nodes, that calculate some values based on input parameters. Width of this should be equal to width of that plus radius of that, X coordinate of this should be half of depth of that, and so on, tons of it.
  3. Geometry generation. 5-10 nodes that create meshes or solids with inputs linked from parts 1 and/or 2.
  4. Geometry processing. 5-10 nodes that modify (and/or multiply) geometry taken from part 3, like adding fillets, doing booleans, extrusions and so on. Input sockets are again linked from parts 1 and/or 2.
  5. Outputs. 1-2-3 nodes like "viewer draw", "solid to mesh" or similar.

In my trees, the most complex, most "noddy" parts are 1 and 2, there are a lot of links between nodes there also. So I thought maybe it is possible to place such inputs and calculations into several spreadsheets. I did not manage to develop a good workflow, how should one usually use spreadsheets to replace or simplify parts 1 or 2. It is obviously possible, but I'm not sure how to do it in the best way.

Durman commented 4 years ago

Just made an example how this could be simplified with node groups. It does not cover all functionality. 2020-10-12_11-32-42

portnov commented 4 years ago

An example of what I'm talking about. Screenshot_20201012_192516

Screenshot_20201012_193513

Here I marked geometry generators with green color, and "geometry modifiers" (like booleans and so on) are yellow. There are 10 input nodes framed in the left part. Collapsed nodes are instances of "scalar math", "vector in" and so on. As you can see there is a lot of them, and they create a mess of node links. If we could somehow simplify such setups it would be good.

One technology that Sverchok already has for it is "wifi nodes", they can help to make more clean layouts. I even have a draft of code somewhere that helps to create such nodes faster...

Durman commented 4 years ago

I'm quite suspicious about wifi nodes. How all output wifi nodes can be identified in a tree? If there are hundreds of nodes in a tree it will be quite difficult task.With links there is no such problem. Also it is not necessary to place all A number nodes in left side of the tree. It is possible to combine them in 3D panel where they can be easily organized.

portnov commented 4 years ago

Yep, it's not necessary, just looks better (imho). Btw, maybe it worth to show the same panel in the N panel of node editor? Maybe even with option: to display all input nodes or just those marked with "to_3d".

Durman commented 4 years ago

Why not but renaming should be done in this case I think. The panel should be renamed to something like Properties set and property should be named to prop set. But it can't be done easily because 3d panel shows properties of all trees but in N panel most likely we would like to have properties only current tree.

nortikin commented 4 years ago

to 3d is shortest and informative name. maybe to 3d panel, but not set. set() множество. What set? What to 3d? to 3d panel more clear

nortikin commented 4 years ago

no conditions? to formula? изображение

nortikin commented 4 years ago

do you have exec function after compile?

                if formula and isinstance(formula, str):
                    result[row_name][col_name] = sv_compile(formula)
    return result
portnov commented 4 years ago

It understands expressions only, not statements. You can do 5 if condition else 3, but not if condition: statement else: ... See https://docs.python.org/3/reference/expressions.html .

nortikin commented 4 years ago

i see now

изображение

portnov commented 1 year ago

@vkter for now, it is in sverchok-extra addon :)