forked from nortikin/sverchok
-
Notifications
You must be signed in to change notification settings - Fork 0
/
node_VertsDelDoubles.py
51 lines (40 loc) · 1.42 KB
/
node_VertsDelDoubles.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import bpy
from node_s import *
from util import *
class VertsDelDoublesNode(Node, SverchCustomTreeNode):
''' Delete doubles vertices '''
bl_idname = 'VertsDelDoublesNode'
bl_label = 'Delete Double vertices'
bl_icon = 'OUTLINER_OB_EMPTY'
def draw_buttons(self, context, layout):
# if to make button - use name of socket and name of tree
# will be here soon
pass
def init(self, context):
self.inputs.new('VerticesSocket', "vers", "vers")
self.outputs.new('VerticesSocket', "vers", "vers")
def update(self):
if 'vers' in self.outputs and len(self.outputs['vers'].links)>0:
# get any type socket from input:
vers = SvGetSocketAnyType(self, self.inputs['vers'])
# Process data
levs = levelsOflist(vers)
result = self.remdou(vers, levs)
SvSetSocketAnyType(self, 'vers', result)
def remdou(self, vers, levs):
out = []
if levs >= 3:
levs -= 1
for x in vers:
out.append(self.remdou(x,levs))
else:
for x in vers:
if x not in out:
out.append(x)
return out
def register():
bpy.utils.register_class(VertsDelDoublesNode)
def unregister():
bpy.utils.unregister_class(VertsDelDoublesNode)
if __name__ == "__main__":
register()