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

Feature request: connectable ints/floats/strings #34

Closed
Maykeye opened this issue Mar 1, 2023 · 4 comments
Closed

Feature request: connectable ints/floats/strings #34

Maykeye opened this issue Mar 1, 2023 · 4 comments

Comments

@Maykeye
Copy link

Maykeye commented Mar 1, 2023

Right now to edit width/height i need to manually edit two fields.

My idea was to make ConstInt node and to connect it to width and height node. Right now it's not possible.

(Also having ability to make integer/float nodes would allow to move Random seed after every generation to specialized seed node).

@GrimblyGorn
Copy link

I stuck this code in the nodes.py file:

class ConstFloat:
    @classmethod
    def INPUT_TYPES(cls):
        return {"required": {"n": ("FLOAT", {"multiline": True, "dynamic_prompt": True, "default": 1.0, "min": -512.0, "max": 512.0})}}

    RETURN_TYPES = ("FLOAT",)
    FUNCTION = "set_float"
    CATEGORY = "Constants"

    def set_float(self, n):
        return (n,)

class ConstInt:
    @classmethod
    def INPUT_TYPES(cls):
        return {"required": {"n": ("INT", {"multiline": True, "dynamic_prompt": True, "default": 1, "min": -512, "max": 512})}}

    RETURN_TYPES = ("INT",)
    FUNCTION = "set_int"
    CATEGORY = "Constants"

    def set_int(self, n):
        return (n,)

class ConstString:
    @classmethod
    def INPUT_TYPES(cls):
        return {"required": {"n": ("STRING", {"multiline": True, "dynamic_prompt": True, "default": ""})}}

    RETURN_TYPES = ("STRING",)
    FUNCTION = "set_string"
    CATEGORY = "Constants"

    def set_string(self, n):
        return (n,)

I stuck it in just above this "NODE_CLASS_MAPPINGS = { "KSampler": KSampler,...".

Then at the bottom of the NODE_CLASS_MAPPINGS list, I extended it with these:

    "ConstFloat": ConstFloat,
    "ConstInt": ConstInt,
    "ConstString": ConstString,

They seem to work fine so far. Likely my hacked together code could be improved, but this should get you started.

@jordanbtucker
Copy link

Piggybacking on this idea, it would be great if these nodes had inputs and outputs for parameters like seed. That way, one sampler could generate a random seed and pass that on to additional samplers.

@WASasquatch
Copy link
Contributor

Piggybacking on this idea, it would be great if these nodes had inputs and outputs for parameters like seed. That way, one sampler could generate a random seed and pass that on to additional samplers.

Yeah this is a important feature for like HR fix workflows to retain the overall theme without it going too rogue on HR pass.

@comfyanonymous
Copy link
Owner

Fixed with: #243

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants