Skip to content

Commit

Permalink
index to mask output numpy prop (#3985)
Browse files Browse the repository at this point in the history
  • Loading branch information
vicdoval authored Mar 24, 2021
1 parent bd2bb73 commit 4c9c125
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion nodes/list_masks/index_to_mask.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,20 @@
name="Data masking",
description="Use data to define mask length",
default=False))

node.props.is_topo_mask = NodeProperties(
bpy_props=BoolProperty(
name="Topo mask",
description="data consists of verts or polygons / edges. "
"Otherwise the two vertices will be masked as [[[T, T, T], [F, F, F]]] instead of [[T, F]]",
default=False))

node.props.output_numpy = NodeProperties(
bpy_props=BoolProperty(
name="Output NumPy",
description="Output Numpy arrays in stead of regular python lists",
default=False))

node.props.index = NodeProperties(bpy_props=IntProperty(name="Index"))
node.props.mask_size = NodeProperties(bpy_props=IntProperty(name='Mask Length', default=10, min=2))

Expand Down Expand Up @@ -76,6 +84,13 @@ def draw_buttons(self, context, layout):
if self.data_to_mask:
col.prop(self, "is_topo_mask", toggle=True)

def draw_buttons_ext(self, context, layout):
self.draw_buttons(context, layout)
layout.prop(self, 'output_numpy')

def rclick_menu(self, context, layout):
layout.prop(self, 'output_numpy')

def process(self):
if not node.props.data_to_mask:
mask = np.zeros(node.inputs.mask_size[0], dtype=bool)
Expand All @@ -87,4 +102,7 @@ def process(self):
mask = np.zeros_like(node.inputs.data_to_mask, dtype=bool)

mask[node.inputs.index] = True
node.outputs.mask = mask.tolist()
if node.props.output_numpy:
node.outputs.mask = mask
else:
node.outputs.mask = mask.tolist()

0 comments on commit 4c9c125

Please sign in to comment.