Closed portnov closed 7 years ago
oh cool!! did you check _object_inlite ? stores a single mesh in json/restores from json in gist.
Yes, probably that feature will be needed too.
@zeffii I have a question about evaluating expressions in Profile node and similar (for example, Formula node). Do we really need own parser and evaluator? Can't we use smth like http://effbot.org/zone/librarybook-core-eval.htm ?
it's up to you @portnov , but try to avoid external modules.. or make a platform independent way to ensure a module's availability if it's not part of std.
@zeffii Python has builtin eval() function, so we could use it with several precautions. But it is possible for "hacker" to use it for some "evil" things. I.e. one can run "rm -rf ~/*" with it. I'm trying to understand, why we implemented own parser in Profile node? Is it for security reasons?
Write a DSL then @portnov.
we use eval/exec in several nodes, do a search in the repo :) We also discussed the dangers a long time ago.
why we implemented own parser in Profile node?
profile node, i like writing parsers :) -- plus Profile node isn't real SVG, just similar syntax - meaning some parsing was needed anyway to add features i wanted. The downside might be that adding features can be non-trivial (even for me)
Ok Currently I'm using python's ast+eval for parsing/evaluating expressions, and a simple trick with passing builtins = {} in environment, and restricted number of "safe" functions, to be more or less secure.
@portnov I tried this node. It gives me nothing.
I kind of expect the output of this node to work with Text In JSON.
@enzyme69 please provide json that you tried and it did not work.
Later today I can provide some examples that are working for me.
And yes, this node obviously needs documentation. I hope to write it this week.
@enzyme69 Trivial plane example:
{
"faces": [
[
0,
1,
3,
2
]
],
"edges": [
[
0,
2
],
[
0,
1
],
[
1,
3
],
[
2,
3
]
],
"vertices": [
[
"-Size",
"-Size",
0.0
],
[
"Size",
"-Size",
0.0
],
[
"-Size",
"Size",
0.0
],
[
"Size",
"Size",
0.0
]
]
}
Nontrivial example:
https://gist.github.com/zeffii/e1652e817f5ca22a07752c3464752c95
Any JSOn did not work in Viewer, I tried, not sure if I should pull git.
@enzyme69 Maybe the problem is that you did not connect anything to inputs? The node currently needs all inputs (variables) to be connected; you can for example plug Float nodes.
Спасибо за узел, не хватало его Thanks for Uzel, ne hvatalo ego
the node should really be in extended generators, i think..
also, to make it clearer to the user that the node has indeed read the json, i think it makes sense to wrap the updateNode function attached to self.filename
, to do a self.adjust_inputs()
-- else sockets aren't added until the user clicks a socket somewhere..
Need at least 1 variable?
I can make Live Noding on this node. Powerful!
However, it would be nice if we can have this Mesh Evaluate Node to pass Mesh Data even without any attribute. Cleaner.
But this is very cool and allows for lots of possibilities I cannot think of.
It's also kind of unfortunate that it cannot accept "var" + 1, or ("var" * -1).
I think this kind of Mesh Eval node can become like Intermediate node.
@enzyme69 It accepts expressions, but they all should be enclosed in quotes. For example, "-1*a".
MeshEval node, when exported out as GIST and imported back in, The Text is no longer pretty JSON, it become a single line text, but I think that's ok for now.
@enzyme69 https://github.com/nortikin/sverchok/blob/master/nodes/generator/mesh_eval.py#L251
read the docs for json.dumps
@portnov , you probably want store the mesh's json in Gists exactly as it appears in the datablock (regarding newlines), ..so flattened string, and restore from Gist using the string too.
@zeffii @portnov I tested both approach Objects In Lite - Text Out, and also MeshEvalNode. What would be nice:
Thanks!
All the mentioned nodes work complementary and have their own usecase.. the json edited with mesh eval doesn't make sense to load it with textin .
I do agree mesheval should not modify formatting when stored/retrieved in a gist., maybe even have a nicer initial formatting to begin with.
Well, I'll try to take notes in this thread into account and provide some fixes this weekend.
Please see #1387. :)
Dodecahedron: https://gist.github.com/portnov/79630a99cc5d6fd549ef0124c4d243f1
So this node can be useful also to make primitives like this and share them. So for example we do not actually need "dodecahedron" node anymore :)
makes me wish that items in the defaults
could reference other defaults already defined..
{
"defaults": {
"A": 0.5773502588272095,
"B": 0.35682210326194763,
"C": 0.9341723322868347,
"amp": 1.0,
},
"vertices": [
[ "A * amp", "A * amp", "A * amp" ],
[ "A * amp", "A * amp", "-A * amp" ],
[ "A * amp", "-A * amp", "A * amp" ],
[ "A * amp", "-A * amp", "-A * amp" ],
[ "-A * amp", "A * amp", "A * amp" ],
[ "-A * amp", "A * amp", "-A * amp" ],
[ "-A * amp", "-A * amp", "A * amp" ],
[ "-A * amp", "-A * amp", "-A * amp" ],
[ "B * amp", "C * amp", 0.0 ],
[ "-B * amp", "C * amp", 0.0 ],
[ "B * amp", "-C * amp", 0.0 ],
[ "-B * amp", "-C * amp", 0.0 ],
[ "C * amp", 0.0, "B * amp" ],
[ "C * amp", 0.0, "-B * amp" ],
[ "-C * amp", 0.0, "B * amp" ],
[ "-C * amp", 0.0, "-B * amp" ],
[ 0.0, "B * amp", "C * amp" ],
[ 0.0, "-B * amp", "C * amp" ],
[ 0.0, "B * amp", "-C * amp" ],
[ 0.0, "-B * amp", "-C * amp" ]
],
"edges": [ ],
"faces": [
[0,12,13,1,8],
[0,8,9,4,16],
[0,16,17,2,12],
[8,1,18,5,9],
[9,5,15,14,4],
[4,14,6,17,16],
[2,17,6,11,10],
[2,10,3,13,12],
[3,19,18,1,13],
[5,18,19,7,15],
[3,10,11,7,19],
[6,14,15,7,11]
]
}
can close this unless there's something else to be added
hey @enzyme69 , how can im trying to open your sushi vault ( https://github.com/enzyme69/blendersushi ) , but the .json doesnt open with the Mesh Expression node. How can i import those .json files corectly in SV and AN?
@rdrgodavi which vault example? We can store Mesh as Mesh Expression and modify it by hand on the code, but which example is this?
JSON can be anything for Sverchok: preset, or maybe something you can load as node tree....
Try also posting this question at my Github?
Initial idea. To create useful meshes, it would be nice to get a mesh modelled "by hand", and parametrize it.
Proposed implementation. Step 1: get selected mesh object and store it, for example, in JSON format (dict with "vertices", "edges" and "faces" keys). Step 2: replace some numbers in "vertices" list with variable names. Step 3: load resulting JSON and plug variable values as node inputs.
Initial implementation is in https://github.com/portnov/sverchok/tree/mesh_from_json.