Открыть боковую панель
nikitronn
sverchok
Коммиты
3e752737
Коммит
3e752737
создал
Янв 16, 2019
по автору
Victor Doval
Просмотр файлов
renamed to Path Length
владелец
aa05b554
Изменения
4
Скрыть пробелы
Построчно
Рядом
docs/nodes/analyzers/analyzers_index.rst
Просмотр файла @
3e752737
...
...
@@ -14,7 +14,6 @@ Analyzers
image_components
kd_tree
kd_tree_edges_mk2
length
mesh_filter
mesh_select
select_similar
...
...
@@ -23,6 +22,7 @@ Analyzers
normals
bvh_overlap_polys
object_insolation
path_length
points_inside_mesh
polygons_centers
polygons_centers_mk3
...
...
docs/nodes/analyzers/length.rst
→
docs/nodes/analyzers/
path_
length.rst
Просмотр файла @
3e752737
Length
=====
Path
Length
=====
======
Functionality
-------------
Length node is one of the analyzer type. It is used to get the length of any path, no matter the number of its vertices or its world position.
Path
Length node is one of the analyzer type. It is used to get the length of any path, no matter the number of its vertices or its world position.
Inputs / Parameters
...
...
@@ -18,7 +18,7 @@ Inputs / Parameters
+------------------+---------------+-------------+--------------------------------------------------+
| **Edges** | Strings | None | Edges referenced to vertices |
+------------------+---------------+-------------+--------------------------------------------------+
| **
by Edges
** | Boolean | True | output
individual edge
s length or
the
sum
of all
|
| **
Segment
**
| Boolean | True | output
the segment
s length
s
or
its
sum
|
+------------------+---------------+-------------+--------------------------------------------------+
In the N-Panel you can use the toggle **Output NumPy** to get NumPy arrays in stead of regular lists (makes the node faster).
...
...
@@ -32,12 +32,17 @@ Outputs
Example of usage
----------------
.. image:: https://user-images.githubusercontent.com/10011941/5
0869102-f52d3d80-13b2-11e9-8316-01106c61e8d7
.png
:alt: LengthDemo1.PNG
.. image:: https://user-images.githubusercontent.com/10011941/5
1251936-c4449e00-199a-11e9-89a7-557cc7e93731
.png
:alt:
Path
LengthDemo1.PNG
Measuring a Bender curve with the default vertices, with a higher interpolation and by edges
.. image:: https://user-images.githubusercontent.com/10011941/5
0869357-f317ae80-13b3-11e9-88a0-05888e9bc2c6
.png
:alt: LengthDemo2.PNG
.. image:: https://user-images.githubusercontent.com/10011941/5
1251933-c4449e00-199a-11e9-99b8-fa53c8586484
.png
:alt:
Path
LengthDemo2.PNG
Using the length node to know the linear distance needed to build a 3 meter radius geodesic dome
Using the node to know the linear distance needed to build a 3 meter radius geodesic dome
.. image:: https://user-images.githubusercontent.com/10011941/51251931-c4449e00-199a-11e9-9e75-69ead34fad64.png
:alt: PathLengthDemo2.PNG
Using the *Path Length* node to place circles of one meter of diameter along a given curve
\ Нет новой строки в конце файла
index.md
Просмотр файла @
3e752737
...
...
@@ -49,7 +49,7 @@
SvVolumeNode
AreaNode
DistancePPNode
SvLengthNode
Sv
Path
LengthNode
CentersPolsNodeMK2
CentersPolsNodeMK3
GetNormalsNode
...
...
nodes/analyzer/length.py
→
nodes/analyzer/
path_
length.py
Просмотр файла @
3e752737
...
...
@@ -20,7 +20,7 @@
import
bpy
from
bpy.props
import
BoolProperty
from
sverchok.node_tree
import
SverchCustomTreeNode
from
sverchok.data_structure
import
updateNode
,
match_long_repeat
from
sverchok.data_structure
import
updateNode
,
match_long_repeat
,
get_edge_list
import
numpy
as
np
...
...
@@ -39,7 +39,6 @@ def edges_length(meshes, gates, result):
for
vertices
,
edges
in
zip
(
*
meshes
):
np_verts
=
np
.
array
(
vertices
)
print
(
np_verts
.
shape
)
if
type
(
edges
[
0
])
in
(
list
,
tuple
):
np_edges
=
np
.
array
(
edges
)
else
:
...
...
@@ -55,26 +54,26 @@ def edges_length(meshes, gates, result):
return
result
class
SvLengthNode
(
bpy
.
types
.
Node
,
SverchCustomTreeNode
):
class
Sv
Path
LengthNode
(
bpy
.
types
.
Node
,
SverchCustomTreeNode
):
'''
Triggers: Path / Edges length
Tooltip:
Deformation between to states, edge elong a area variation
Tooltip:
Masseuses the length of a path or the length of it's segments
'''
bl_idname
=
'SvLengthNode'
bl_label
=
'Length'
bl_idname
=
'Sv
Path
LengthNode'
bl_label
=
'
Path
Length'
bl_icon
=
'MOD_SIMPLEDEFORM'
output_numpy
=
BoolProperty
(
name
=
'Output NumPy'
,
description
=
'output NumPy arrays'
,
default
=
False
,
update
=
updateNode
)
s
um_lengths
=
BoolProperty
(
name
=
'
by Edge
'
,
description
=
'
individual
length
s
or the sum of them'
,
s
egment
=
BoolProperty
(
name
=
'
Segment
'
,
description
=
'
Get segments
length or the sum of them'
,
default
=
True
,
update
=
updateNode
)
def
draw_buttons
(
self
,
context
,
layout
):
'''draw buttons on the Node'''
layout
.
prop
(
self
,
"s
um_lengths
"
,
toggle
=
False
)
layout
.
prop
(
self
,
"s
egment
"
,
toggle
=
False
)
def
draw_buttons_ext
(
self
,
context
,
layout
):
'''draw buttons on the N-panel'''
...
...
@@ -85,7 +84,7 @@ class SvLengthNode(bpy.types.Node, SverchCustomTreeNode):
'''create sockets'''
sinw
=
self
.
inputs
.
new
sonw
=
self
.
outputs
.
new
sinw
(
'VerticesSocket'
,
"Verts"
)
sinw
(
'VerticesSocket'
,
"Vert
ice
s"
)
sinw
(
'StringsSocket'
,
"Edges"
)
sonw
(
'StringsSocket'
,
"Length"
)
...
...
@@ -93,24 +92,28 @@ class SvLengthNode(bpy.types.Node, SverchCustomTreeNode):
def
get_data
(
self
):
'''get all data from sockets'''
si
=
self
.
inputs
vertices
=
si
[
'Verts'
].
sv_get
(
default
=
[[]])
edges_in
=
si
[
'Edges'
].
sv_get
(
default
=
[[]])
if
len
(
edges_in
[
0
])
<
1
:
vertices
=
si
[
'Vertices'
].
sv_get
()
if
si
[
'Edges'
].
is_linked
:
edges_in
=
si
[
'Edges'
].
sv_get
()
else
:
edges_in
=
edges_aux
(
vertices
)
return
match_long_repeat
([
vertices
,
edges_in
])
def
process
(
self
):
'''main node function called every update'''
si
=
self
.
inputs
so
=
self
.
outputs
if
not
(
so
[
0
].
is_linked
and
si
[
0
].
is_linked
):
if
not
(
so
[
'Length'
].
is_linked
):
return
result
=
[]
gates
=
[]
gates
.
append
(
self
.
output_numpy
)
gates
.
append
(
self
.
s
um_lengths
)
gates
.
append
(
self
.
s
egment
)
meshes
=
self
.
get_data
()
result
=
edges_length
(
meshes
,
gates
,
result
)
...
...
@@ -120,9 +123,9 @@ class SvLengthNode(bpy.types.Node, SverchCustomTreeNode):
def
register
():
'''register class in Blender'''
bpy
.
utils
.
register_class
(
SvLengthNode
)
bpy
.
utils
.
register_class
(
Sv
Path
LengthNode
)
def
unregister
():
'''unregister class in Blender'''
bpy
.
utils
.
unregister_class
(
SvLengthNode
)
bpy
.
utils
.
unregister_class
(
Sv
Path
LengthNode
)
Редактирование
Предварительный просмотр
Поддерживает Markdown
0%
Попробовать снова
или
прикрепить новый файл
.
Отмена
You are about to add
0
people
to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Отмена
Пожалуйста,
зарегистрируйтесь
или
войдите
чтобы прокомментировать