-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathList_Extractor.py
More file actions
26 lines (22 loc) · 972 Bytes
/
List_Extractor.py
File metadata and controls
26 lines (22 loc) · 972 Bytes
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
from .sup import AlwaysEqualProxy
class ExtractFromListNode:
def __init__(self):
self.title = "Extract From List"
self.inputs = [{"name": "input_data", "type": AlwaysEqualProxy("*")}, {"name": "value", "type": "int"}]
self.outputs = [{"name": "output_data", "type": AlwaysEqualProxy("*")}]
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"input_data": (AlwaysEqualProxy("*"),), # 通配符类型,允许任意输入
"value": ("INT", {"default": 0, "min": 0}), # int类型,默认值为0
},
}
RETURN_TYPES = ("*",) # 输出类型可以是任意类型
FUNCTION = "process"
CATEGORY = "CGAnimittaTools"
def process(self, input_data, value):
if isinstance(input_data, list) and len(input_data) > value:
return (input_data[value],)
else:
return (None,) # 如果索引超出范围,返回None