Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'constant' data value input nodes #3899

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions comfy_extras/nodes_constant_values,.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
class _CONSTANT_BASE:
teward marked this conversation as resolved.
Show resolved Hide resolved
def __init__(self):
pass

@classmethod
def INPUT_TYPES(s) -> dict:
raise NotImplementedError

RETURN_TYPES: tuple = ()
RETURN_NAMES: tuple = ()

CATEGORY: str = "constants"

FUNCTION: str = "process"

OUTPUT_NODE: bool = False

def process(self, value) -> tuple:
return (value,)


class ConstantFloat(_CONSTANT_BASE):
@classmethod
def INPUT_TYPES(s) -> dict:
return {
"required": {
"value": ("FLOAT", {"default": 0.0})
}
}

RETURN_TYPES = ("FLOAT",)
RETURN_NAMES = ("float",)


class ConstantInteger(_CONSTANT_BASE):
@classmethod
def INPUT_TYPES(s) -> dict:
return {
"required": {
"value": ("INT", {"default": 0})
}
}

RETURN_TYPES = ("INT",)
RETURN_NAMES = ("int",)


class ConstantString(_CONSTANT_BASE):
@classmethod
def INPUT_TYPES(s) -> dict:
return {
"required" : {
"value": ("STRING", {"multiline": False})
}
}

RETURN_TYPES = ("STRING",)
RETURN_NAMES = ("string",)


class ConstantStringMultiline(_CONSTANT_BASE):
@classmethod
def INPUT_TYPES(s) -> dict:
return {
"required": {
"value": ("STRING", {"multiline": True})
}
}

RETURN_TYPES = ("STRING",)
RETURN_NAMES = ("string",)


NODE_CLASS_MAPPINGS = {
"ConstantFloat": ConstantFloat,
"ConstantInteger": ConstantInteger,
"ConstantString": ConstantString,
"ConstantStringMultiline": ConstantStringMultiline,
}
1 change: 1 addition & 0 deletions nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2090,6 +2090,7 @@ def init_builtin_extra_nodes():
"nodes_controlnet.py",
"nodes_hunyuan.py",
"nodes_flux.py",
"nodes_constant_values.py",
]

import_failed = []
Expand Down
Loading