Skip to content

Instantly share code, notes, and snippets.

@nortikin
Created May 20, 2023 11:01
Show Gist options
  • Save nortikin/01cd2f57b28179e303d499ba94662d03 to your computer and use it in GitHub Desktop.
Save nortikin/01cd2f57b28179e303d499ba94662d03 to your computer and use it in GitHub Desktop.
Sverchok.v1.2.0-alpha | Blender.3.3.1 | endtraight | 2023.05.20 | 14:01 | license: CC BY-SA
{
"export_version": "1.0",
"main_tree": {
"nodes": {
"Polygon Grid": {
"attributes": {
"location": [
-780.0,
140.0
],
"width": 170.0
},
"properties": {
"gridType": "TRIANGLE",
"gridLayout": "TRIANGLE",
"level": 7
},
"inputs": {
"Radius": {
"bl_idname": "SvStringsSocket",
"name": "Radius",
"properties": {
"prop_name": "radius"
}
},
"Scale": {
"bl_idname": "SvStringsSocket",
"name": "Scale",
"properties": {
"prop_name": "scale"
}
},
"Angle": {
"bl_idname": "SvStringsSocket",
"name": "Angle",
"properties": {
"prop_name": "angle"
}
},
"Level": {
"bl_idname": "SvStringsSocket",
"name": "Level",
"properties": {
"prop_name": "level"
}
}
},
"outputs": {
"Centers": {
"bl_idname": "SvVerticesSocket",
"name": "Centers"
},
"Vertices": {
"bl_idname": "SvVerticesSocket",
"name": "Vertices"
},
"Edges": {
"bl_idname": "SvStringsSocket",
"name": "Edges"
},
"Polygons": {
"bl_idname": "SvStringsSocket",
"name": "Polygons"
}
},
"bl_idname": "SvPolygonGridNode"
},
"Polygon Boom": {
"attributes": {
"location": [
-260.0,
60.0
]
},
"inputs": {
"vertices": {
"bl_idname": "SvVerticesSocket",
"name": "vertices"
},
"edg_pol": {
"bl_idname": "SvStringsSocket",
"name": "edg_pol"
}
},
"outputs": {
"vertices": {
"bl_idname": "SvVerticesSocket",
"name": "vertices"
},
"edg_pol": {
"bl_idname": "SvStringsSocket",
"name": "edg_pol"
}
},
"bl_idname": "PolygonBoomNode"
},
"Scripted Node Lite": {
"attributes": {
"location": [
-60.0,
120.0
],
"color": [
0.0,
0.6000000238418579,
0.800000011920929
],
"use_custom_color": true
},
"properties": {
"n_id": "-7068772039551306019",
"script_name": "enstraignt.py",
"script_str": "\"\"\"\nin vers v d=[[]] n=0\nin pols s d=[[]] n=0\nin \u0434\u043e\u043f\u0443\u0441\u043a s d=0.01 n=2\nout vers_out v\nout edgs_out s\nout pols_out s\nout rads_out v\n\"\"\"\n\nfrom mathutils import Vector as V\nfrom sverchok.utils.sv_mesh_utils import polygons_to_edges\n\nvers_out, edgs_out, pols_out = [], [], [] # \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u044b\nrads_out = []\nfor ver, pol in zip(vers,pols): # \u043e\u0431\u044a\u0435\u043a\u0442\u044b\n v_out, p_out, e_out = [], [], [] # \u043e\u0431\u044a\u0435\u043a\u0442\u044b\n icount = []\n for po in pol: # \u043f\u043e\u043b\u0438\u0433\u043e\u043d\u044b\n\n # \u0432\u043d\u0443\u0442\u0440\u0438 \u043f\u043e\u043b\u0438\u0433\u043e\u043d\u0430 \u043d\u0430\u0447\u0430\u043b\u043e \u043e\u0442\u0441\u0435\u0432\u0430 \u0441\u043e\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0445\n stack = 0 # \n radius = [] #\u0435\u0441\u043b\u0438 5 \u0432\u0435\u0440\u0448\u0438\u043d - \u044d\u0442\u043e \u0441\u0447\u0438\u0442\u0430\u0435\u043c \u0440\u0430\u0434\u0438\u0443\u0441\n pout = [] # \u043d\u043e\u0432\u044b\u0439 \u043f\u043e\u043b\u0438\u0433\u043e\u043d\n for i in range(len(po)): # \u0442\u043e\u0447\u043a\u0438\n if i != len(po)-1:\n pl = V(ver[po[i-1]])\n p0 = V(ver[po[i]])\n pr = V(ver[po[i+1]])\n else:\n pl = V(ver[po[i-1]])\n p0 = V(ver[po[i]])\n pr = V(ver[po[0]])\n n1 = (pl-p0)\n n1.normalize()\n n2 = (p0-pr)\n n2.normalize()\n if (n1-n2).length >= \u0434\u043e\u043f\u0443\u0441\u043a:\n v_out.append(list(p0))\n pout.append(po[i])\n stack = 0\n else:\n stack += 1\n if stack > 2:\n radius.append(ver[po[i]])\n icount.append(po[i])\n # \u0432\u043d\u0443\u0442\u0440\u0438 \u043f\u043e\u043b\u0438\u0433\u043e\u043d\u0430 \u043a\u043e\u043d\u0435\u0446\n\n p_out.append(sorted(pout))\n if len(radius)>4:\n rads_out.append(radius)\n\n def pop_shift_pol(p_out):\n # \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0445 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u0432\u0435\u0440\u0448\u0438\u043d \u0432 \u043f\u043e\u043b\u0438\u0433\u043e\u043d\u0435\n # \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u0438\u0441\u043a\u043b\u044e\u0447\u0451\u043d\u043d\u044b\u043c\u0438\n out = []\n for pout in p_out: # \u043e\u0431\u044a\u0435\u043a\u0442\n out_ = []\n for p in pout: # \u043f\u043e\u043b\u0438\u0433\u043e\u043d\n if p>=i: out_.append(p-1)\n else: out_.append(p)\n out.append(out_)\n return out\n\n for i in sorted(icount,reverse=True):\n p_out = pop_shift_pol(p_out)\n\n # for p in p_out: # \u043e\u0431\u044a\u0435\u043a\u0442\u044b\n # print('SNL \u041f\u043e\u043b\u0438\u0433\u043e\u043d ',p_out[0])\n # e_out.append(p_out)\n\n vers_out.append(v_out)\n pols_out.append(p_out)\n\nedgs_out.extend(polygons_to_edges(pols_out, unique_edges=True))"
},
"inputs": {
"vers": {
"bl_idname": "SvVerticesSocket",
"name": "vers"
},
"pols": {
"bl_idname": "SvStringsSocket",
"name": "pols"
},
"\u0434\u043e\u043f\u0443\u0441\u043a": {
"bl_idname": "SvStringsSocket",
"name": "\u0434\u043e\u043f\u0443\u0441\u043a",
"properties": {
"use_prop": true,
"default_float_property": 0.009999999776482582
}
}
},
"outputs": {
"vers_out": {
"bl_idname": "SvVerticesSocket",
"name": "vers_out"
},
"edgs_out": {
"bl_idname": "SvStringsSocket",
"name": "edgs_out"
},
"pols_out": {
"bl_idname": "SvStringsSocket",
"name": "pols_out"
},
"rads_out": {
"bl_idname": "SvVerticesSocket",
"name": "rads_out"
}
},
"bl_idname": "SvScriptNodeLite"
},
"Viewer Draw.001": {
"attributes": {
"location": [
140.0,
140.0
]
},
"inputs": {
"Vertices": {
"bl_idname": "SvVerticesSocket",
"name": "Vertices",
"properties": {
"custom_draw": "draw_property_socket"
}
},
"Edges": {
"bl_idname": "SvStringsSocket",
"name": "Edges",
"properties": {
"custom_draw": "draw_property_socket"
}
},
"Polygons": {
"bl_idname": "SvStringsSocket",
"name": "Polygons"
},
"Matrix": {
"bl_idname": "SvMatrixSocket",
"name": "Matrix"
},
"Vector Color": {
"bl_idname": "SvColorSocket",
"name": "Vector Color",
"properties": {
"custom_draw": "draw_color_socket",
"prop_name": "vector_color"
}
},
"Edge Color": {
"bl_idname": "SvColorSocket",
"name": "Edge Color",
"properties": {
"custom_draw": "draw_color_socket",
"prop_name": "edge_color"
}
},
"Polygon Color": {
"bl_idname": "SvColorSocket",
"name": "Polygon Color",
"properties": {
"custom_draw": "draw_color_socket",
"prop_name": "polygon_color"
}
},
"attrs": {
"bl_idname": "SvStringsSocket",
"name": "attrs",
"attributes": {
"hide": true
},
"properties": {
"quick_link_to_node": "SvVDAttrsNodeMk2"
}
}
},
"bl_idname": "SvViewerDrawMk4"
},
"Subdivide": {
"attributes": {
"location": [
-500.0,
180.0
]
},
"properties": {
"cuts": 2,
"show_options": true,
"grid_fill": false
},
"inputs": {
"Vertices": {
"bl_idname": "SvVerticesSocket",
"name": "Vertices"
},
"Edges": {
"bl_idname": "SvStringsSocket",
"name": "Edges"
},
"Faces": {
"bl_idname": "SvStringsSocket",
"name": "Faces"
},
"FaceData": {
"bl_idname": "SvStringsSocket",
"name": "FaceData"
},
"EdgeMask": {
"bl_idname": "SvStringsSocket",
"name": "EdgeMask"
},
"Cuts": {
"bl_idname": "SvStringsSocket",
"name": "Cuts",
"properties": {
"prop_name": "cuts"
}
},
"Smooth": {
"bl_idname": "SvStringsSocket",
"name": "Smooth",
"properties": {
"prop_name": "smooth"
}
},
"Fractal": {
"bl_idname": "SvStringsSocket",
"name": "Fractal",
"properties": {
"prop_name": "fractal"
}
},
"AlongNormal": {
"bl_idname": "SvStringsSocket",
"name": "AlongNormal",
"properties": {
"prop_name": "along_normal"
}
},
"Seed": {
"bl_idname": "SvStringsSocket",
"name": "Seed",
"properties": {
"prop_name": "seed"
}
}
},
"outputs": {
"Vertices": {
"bl_idname": "SvVerticesSocket",
"name": "Vertices"
},
"Edges": {
"bl_idname": "SvStringsSocket",
"name": "Edges"
},
"Faces": {
"bl_idname": "SvStringsSocket",
"name": "Faces"
},
"FaceData": {
"bl_idname": "SvStringsSocket",
"name": "FaceData"
},
"NewVertices": {
"bl_idname": "SvVerticesSocket",
"name": "NewVertices",
"attributes": {
"hide": true
}
},
"NewEdges": {
"bl_idname": "SvStringsSocket",
"name": "NewEdges",
"attributes": {
"hide": true
}
},
"NewFaces": {
"bl_idname": "SvStringsSocket",
"name": "NewFaces",
"attributes": {
"hide": true
}
},
"OldVertices": {
"bl_idname": "SvVerticesSocket",
"name": "OldVertices",
"attributes": {
"hide": true
}
},
"OldEdges": {
"bl_idname": "SvStringsSocket",
"name": "OldEdges",
"attributes": {
"hide": true
}
},
"OldFaces": {
"bl_idname": "SvStringsSocket",
"name": "OldFaces",
"attributes": {
"hide": true
}
}
},
"bl_idname": "SvSubdivideNodeMK2"
},
"Viewer Draw": {
"attributes": {
"location": [
-260.0,
400.0
]
},
"properties": {
"display_faces": false
},
"inputs": {
"Vertices": {
"bl_idname": "SvVerticesSocket",
"name": "Vertices",
"properties": {
"custom_draw": "draw_property_socket"
}
},
"Edges": {
"bl_idname": "SvStringsSocket",
"name": "Edges",
"properties": {
"custom_draw": "draw_property_socket"
}
},
"Polygons": {
"bl_idname": "SvStringsSocket",
"name": "Polygons"
},
"Matrix": {
"bl_idname": "SvMatrixSocket",
"name": "Matrix"
},
"Vector Color": {
"bl_idname": "SvColorSocket",
"name": "Vector Color",
"properties": {
"custom_draw": "draw_color_socket",
"prop_name": "vector_color"
}
},
"Edge Color": {
"bl_idname": "SvColorSocket",
"name": "Edge Color",
"properties": {
"custom_draw": "draw_color_socket",
"prop_name": "edge_color"
}
},
"Polygon Color": {
"bl_idname": "SvColorSocket",
"name": "Polygon Color",
"properties": {
"custom_draw": "draw_color_socket",
"prop_name": "polygon_color"
}
},
"attrs": {
"bl_idname": "SvStringsSocket",
"name": "attrs",
"attributes": {
"hide": true
},
"properties": {
"quick_link_to_node": "SvVDAttrsNodeMk2"
}
}
},
"bl_idname": "SvViewerDrawMk4"
},
"Matrix In": {
"attributes": {
"location": [
-500.0,
400.0
],
"label": "Matrix"
},
"properties": {
"location_": [
10.679999351501465,
0.0,
0.0
]
},
"inputs": {
"Location": {
"bl_idname": "SvVerticesSocket",
"name": "Location",
"properties": {
"prop_name": "location_",
"expanded": true
}
},
"Scale": {
"bl_idname": "SvVerticesSocket",
"name": "Scale",
"properties": {
"prop_name": "scale"
}
},
"Quaternion": {
"bl_idname": "SvQuaternionSocket",
"name": "Quaternion",
"attributes": {
"hide": true
},
"properties": {
"prop_name": "quaternion"
}
},
"Angle X": {
"bl_idname": "SvStringsSocket",
"name": "Angle X",
"attributes": {
"hide": true
},
"properties": {
"prop_name": "angle_x"
}
},
"Angle Y": {
"bl_idname": "SvStringsSocket",
"name": "Angle Y",
"attributes": {
"hide": true
},
"properties": {
"prop_name": "angle_y"
}
},
"Angle Z": {
"bl_idname": "SvStringsSocket",
"name": "Angle Z",
"attributes": {
"hide": true
},
"properties": {
"prop_name": "angle_z"
}
},
"Axis": {
"bl_idname": "SvVerticesSocket",
"name": "Axis",
"properties": {
"prop_name": "axis"
}
},
"Angle": {
"bl_idname": "SvStringsSocket",
"name": "Angle",
"properties": {
"prop_name": "angle"
}
}
},
"outputs": {
"Matrices": {
"bl_idname": "SvMatrixSocket",
"name": "Matrices"
}
},
"bl_idname": "SvMatrixInNodeMK4"
}
},
"links": [
{
"from_node": "Subdivide",
"from_socket": "Vertices",
"to_node": "Polygon Boom",
"to_socket": "vertices"
},
{
"from_node": "Subdivide",
"from_socket": "Faces",
"to_node": "Polygon Boom",
"to_socket": "edg_pol"
},
{
"from_node": "Polygon Boom",
"from_socket": "vertices",
"to_node": "Scripted Node Lite",
"to_socket": "vers"
},
{
"from_node": "Polygon Boom",
"from_socket": "edg_pol",
"to_node": "Scripted Node Lite",
"to_socket": "pols"
},
{
"from_node": "Scripted Node Lite",
"from_socket": "vers_out",
"to_node": "Viewer Draw.001",
"to_socket": "Vertices"
},
{
"from_node": "Scripted Node Lite",
"from_socket": "edgs_out",
"to_node": "Viewer Draw.001",
"to_socket": "Edges"
},
{
"from_node": "Scripted Node Lite",
"from_socket": "pols_out",
"to_node": "Viewer Draw.001",
"to_socket": "Polygons"
},
{
"from_node": "Polygon Grid",
"from_socket": "Vertices",
"to_node": "Subdivide",
"to_socket": "Vertices"
},
{
"from_node": "Polygon Grid",
"from_socket": "Edges",
"to_node": "Subdivide",
"to_socket": "Edges"
},
{
"from_node": "Polygon Grid",
"from_socket": "Polygons",
"to_node": "Subdivide",
"to_socket": "Faces"
},
{
"from_node": "Subdivide",
"from_socket": "Vertices",
"to_node": "Viewer Draw",
"to_socket": "Vertices"
},
{
"from_node": "Subdivide",
"from_socket": "Edges",
"to_node": "Viewer Draw",
"to_socket": "Edges"
},
{
"from_node": "Subdivide",
"from_socket": "Faces",
"to_node": "Viewer Draw",
"to_socket": "Polygons"
},
{
"from_node": "Matrix In",
"from_socket": "Matrices",
"to_node": "Viewer Draw",
"to_socket": "Matrix"
}
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment