feat: script to update blender node types
This commit is contained in:
@@ -169,3 +169,11 @@ For each changes, simply refresh the comfyui page to see the changes.
|
||||
}
|
||||
```
|
||||
</details>
|
||||
|
||||
## Update blender node types
|
||||
|
||||
To update blender operations input and output types (stored in `blender/input_types.txt`), run:
|
||||
|
||||
```bash
|
||||
python generate_blender_types.py
|
||||
```
|
||||
|
||||
+22
-14
@@ -17,6 +17,7 @@ with open(f"{os.path.dirname(__file__)}/input_types.txt") as f:
|
||||
node_cls, node_types = input_type.split("|")
|
||||
node_input_types[node_cls] = json.loads(node_types)
|
||||
|
||||
type_generation = os.getenv('TYPE_GENERATION', 0)
|
||||
|
||||
class ObjectOps:
|
||||
@classmethod
|
||||
@@ -48,22 +49,29 @@ class ObjectOps:
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return node_input_types[cls.__name__]
|
||||
if type_generation:
|
||||
import global_bpy
|
||||
|
||||
# import global_bpy
|
||||
# bpy = global_bpy.get_bpy()
|
||||
# result = {
|
||||
# "required": {},
|
||||
# "optional": {
|
||||
# **cls.get_base_input_types(bpy),
|
||||
# **cls.get_extra_input_types(bpy)
|
||||
# }
|
||||
# }
|
||||
bpy = global_bpy.get_bpy()
|
||||
result = {
|
||||
"required": {},
|
||||
"optional": {
|
||||
**cls.get_base_input_types(bpy),
|
||||
**cls.get_extra_input_types(bpy),
|
||||
},
|
||||
}
|
||||
|
||||
# with open("input_types.txt", "a") as f:
|
||||
# f.write(cls.__name__ + "|" + json.dumps(result) + "\n")
|
||||
|
||||
# return result
|
||||
return result
|
||||
elif cls.__name__ in node_input_types:
|
||||
return node_input_types[cls.__name__]
|
||||
else:
|
||||
return {
|
||||
"required": {},
|
||||
"optional": {
|
||||
**cls.get_base_input_types(None),
|
||||
**cls.get_extra_input_types(None),
|
||||
},
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def NODE_CLASS_MAPPINGS(cls):
|
||||
|
||||
@@ -1,16 +1,3 @@
|
||||
AvatarMainOutput|{"required": {}, "optional": {"BPY_OBJ": ["BPY_OBJ"], "BPY_OBJS": ["BPY_OBJS"], "open_in_blender": ["BOOLEAN", {"default": false}], "auto_save": ["BOOLEAN", {"default": false}], "blender_path_override": ["STRING", {"multiline": false, "default": ""}], "filename": ["STRING", {"multiline": false, "default": "out"}], "model_type": [["AVA", "GLB", "GLTF_EMBEDDED"]], "write_mode": [["Overwrite", "Increment"]], "SHAPE_FLOW": ["SHAPE_FLOW"]}}
|
||||
EditOps|{"required": {}, "optional": {"BPY_OBJ": ["BPY_OBJ"]}}
|
||||
ContextSet_TransformPivotPoint|{"required": {}, "optional": {"BPY_OBJ": ["BPY_OBJ"], "pivot": [["BOUNDING_BOX_CENTER", "CURSOR", "INDIVIDUAL_ORIGINS", "MEDIAN_POINT", "ACTIVE_ELEMENT"]]}}
|
||||
GetImageWidthHeight|{"required": {}, "optional": {"image": ["IMAGE"], "scale": ["FLOAT", {"default": 1.0}]}}
|
||||
Object_AddShapeKeys|{"required": {}, "optional": {"BPY_OBJ": ["BPY_OBJ"], "shape_keys": ["STRING", {"default": "key1,key2", "multiline": true}], "from_mix": ["BOOLEAN", {"default": false}]}}
|
||||
Object_AssignTexture|{"required": {}, "optional": {"BPY_OBJ": ["BPY_OBJ"], "texture": ["IMAGE"], "texture_name": ["STRING", {"multiline": false, "default": "my_image"}]}}
|
||||
AssignVertexGroupOps|{"required": {}, "optional": {"BPY_OBJ": ["BPY_OBJ"], "name": ["STRING", {"multiline": false, "default": "Group"}]}}
|
||||
Object_CreateMeshLayer|{"required": {}, "optional": {"image": ["IMAGE"], "convex_hull": ["BOOLEAN", {"default": true}], "shape_threshold": ["FLOAT", {"display": "number", "default": 0.7}], "mesh_layer_name": ["STRING", {"default": "mesh_layer"}], "scale_x": ["FLOAT", {"display": "number", "default": 1}], "scale_y": ["FLOAT", {"display": "number", "default": 1}], "extrude_x": ["FLOAT", {"display": "number", "default": 0}], "extrude_y": ["FLOAT", {"display": "number", "default": 0}], "seed": ["INT", {"default": 0, "min": 0, "max": 18446744073709551615}]}}
|
||||
Object_VertexGroupNewWithName|{"required": {}, "optional": {"BPY_OBJ": ["BPY_OBJ"], "name": ["STRING", {"multiline": false, "default": "Group"}], "assign_selected": ["BOOLEAN", {"default": true}]}}
|
||||
GetFirstObjOps|{"required": {}, "optional": {"BPY_OBJS": ["BPY_OBJS"]}}
|
||||
GroupOps|{"required": {}, "optional": {"BPY_OBJ": ["BPY_OBJ"], "BPY_OBJ2": ["BPY_OBJ"]}}
|
||||
Mesh_JoinMesh|{"required": {}, "optional": {"BPY_OBJ": ["BPY_OBJ"], "BPY_OBJ2": ["BPY_OBJ"]}}
|
||||
Object_MatchTextureAspectRatio|{"required": {}, "optional": {"BPY_OBJ": ["BPY_OBJ"], "image": ["IMAGE"], "scale": ["FLOAT", {"default": 0.001, "display": "number", "step": 0.001}]}}
|
||||
Mesh_AttributeSet|{"required": {}, "optional": {"BPY_OBJ": ["BPY_OBJ"], "value_float": ["FLOAT", {"min": -3.4028234663852886e+38, "max": 3.4028234663852886e+38, "default": 0.0}], "value_float_vector_2d": ["B_VECTOR2", {}], "value_float_vector_3d": ["B_VECTOR3", {}], "value_int": ["INT", {"min": -2147483648, "max": 2147483647, "default": 0}], "value_int_vector_2d": ["B_VECTOR2", {}], "value_color": ["B_VECTOR4", {}], "value_bool": ["BOOLEAN", {"default": false}]}}
|
||||
Mesh_AverageNormals|{"required": {}, "optional": {"BPY_OBJ": ["BPY_OBJ"], "average_type": [["CUSTOM_NORMAL", "FACE_AREA", "CORNER_ANGLE"]], "weight": ["INT", {"min": 1, "max": 100, "default": 50}], "threshold": ["FLOAT", {"min": 0.0, "max": 10.0, "default": 0.009999999776482582}]}}
|
||||
Mesh_BeautifyFill|{"required": {}, "optional": {"BPY_OBJ": ["BPY_OBJ"], "angle_limit": ["FLOAT", {"min": 0.0, "max": 3.1415927410125732, "default": 3.1415927410125732}]}}
|
||||
@@ -608,7 +595,3 @@ UV_SphereProject|{"required": {}, "optional": {"BPY_OBJ": ["BPY_OBJ"], "directio
|
||||
UV_Stitch|{"required": {}, "optional": {"BPY_OBJ": ["BPY_OBJ"], "use_limit": ["BOOLEAN", {"default": false}], "snap_islands": ["BOOLEAN", {"default": true}], "limit": ["FLOAT", {"min": 0.0, "max": 3.4028234663852886e+38, "default": 0.009999999776482582}], "static_island": ["INT", {"min": 0, "max": 2147483647, "default": 0}], "active_object_index": ["INT", {"min": 0, "max": 2147483647, "default": 0}], "midpoint_snap": ["BOOLEAN", {"default": false}], "clear_seams": ["BOOLEAN", {"default": true}], "mode": [["VERTEX", "EDGE"]], "stored_mode": [["VERTEX", "EDGE"]], "objects_selection_count": ["B_VECTOR6", {}]}}
|
||||
UV_Unwrap|{"required": {}, "optional": {"BPY_OBJ": ["BPY_OBJ"], "method": [["ANGLE_BASED", "CONFORMAL"]], "fill_holes": ["BOOLEAN", {"default": true}], "correct_aspect": ["BOOLEAN", {"default": true}], "use_subsurf_data": ["BOOLEAN", {"default": false}], "margin_method": [["SCALED", "ADD", "FRACTION"]], "margin": ["FLOAT", {"min": 0.0, "max": 1.0, "default": 0.0010000000474974513}]}}
|
||||
UV_Weld|{"required": {}, "optional": {"BPY_OBJ": ["BPY_OBJ"]}}
|
||||
Object_MeshFromTexture|{"required": {}, "optional": {"image": ["IMAGE"], "seed": ["INT", {"default": 0, "min": 0, "max": 18446744073709551615}]}}
|
||||
Mesh_ModifyShapeKey|{"required": {}, "optional": {"BPY_OBJ": ["BPY_OBJ"], "shape_key_name": ["STRING", {"multiline": false, "default": "EyeBlinkLeft"}], "target_vertex_group": ["STRING", {"multiline": false, "default": ""}], "scale_x": ["FLOAT", {"default": 1.0, "min": -10.0, "max": 10.0, "step": 0.01, "display": "number"}], "scale_y": ["FLOAT", {"default": 1.0, "min": -10.0, "max": 10.0, "step": 0.01, "display": "number"}], "offset_x": ["FLOAT", {"default": 0.0, "min": -10.0, "max": 10.0, "step": 0.01, "display": "number"}], "offset_y": ["FLOAT", {"default": 0.0, "min": -10.0, "max": 10.0, "step": 0.01, "display": "number"}], "rotate": ["FLOAT", {"default": 0, "min": -360, "max": 360.0, "step": 0.01, "display": "number"}], "origin_offset_x": ["FLOAT", {"default": 0, "min": -10.0, "max": 10.0, "step": 0.01, "display": "number"}], "origin_offset_y": ["FLOAT", {"default": 0, "min": -10.0, "max": 10.0, "step": 0.01, "display": "number"}], "transform_radius": ["FLOAT", {"default": 1.0, "min": 0, "max": 1, "step": 0.01, "display": "number"}], "falloff": ["FLOAT", {"default": 0, "min": -10.0, "max": 10.0, "step": 0.01, "display": "number"}]}}
|
||||
Object_PlaneTextureUnwrap|{"required": {}, "optional": {"BPY_OBJ": ["BPY_OBJ"], "image": ["IMAGE"], "scale": ["FLOAT", {"default": 1, "display": "number", "step": 0.01}], "texture_name": ["STRING", {"default": "Texture"}]}}
|
||||
ToGroupOps|{"required": {}, "optional": {"BPY_OBJ": ["BPY_OBJ"]}}
|
||||
@@ -0,0 +1,17 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
os.environ["TYPE_GENERATION"] = "1"
|
||||
|
||||
current_dir = os.path.dirname(__file__)
|
||||
blender_dir = os.path.join(current_dir, "blender")
|
||||
sys.path.append(blender_dir)
|
||||
|
||||
import json
|
||||
from blender.ops_mesh import BLENDER_NODES
|
||||
|
||||
|
||||
with open(f"{blender_dir}/input_types.txt", "w") as f:
|
||||
for node in BLENDER_NODES:
|
||||
results = node.INPUT_TYPES()
|
||||
f.write(node.__name__ + "|" + json.dumps(results) + "\n")
|
||||
Reference in New Issue
Block a user