Nodes/ComfyUI_StringOps/获取整数🐠meeeyo.com
ComfyUI Node

获取整数🐠meeeyo.com

Find the line that contains your key and hand back the int value on it

By MeeeyoAI·Created 2 years ago·Updated about a year ago· 209
获取整数🐠meeeyo.com
    • INT
    • STRING
    input_text
    target_char

    ComfyUI is full of little mismatches where one node hands you text and the next node insists on a number. GetIntParam (获取整数 - "get integer") is the bridge: it scans a text block line by line for the line containing a marker you specify, takes everything after that marker, and hands it back as a real INT - with the raw string kept too. This is the node you reach for when a config file, a batch output, or a prompt list has a seed: 12345-style line and your sampler needs the actual integer.

    How it works

    Two inputs: input_text (a STRING that's wired from another node - it's set to force-input, so you'll connect something into it rather than just typing) and target_char, the marker to hunt for. The logic is the same as FindFirstLineContent from this pack (in fact it reuses the same function): walk lines top to bottom, find the first line containing target_char, and cut everything after it. Then it tries to parse that remainder as an integer.

    Outputs are two: an INT (the parsed value) and a STRING (the raw remainder text). If the value after the marker isn't a number, the int output comes back None - and if the marker isn't found at all, you get the empty string. So the raw-string output is worth wiring up even if you only need the int: it's your debugging window when the parse fails.

    Example: text line seed: 8675309 with target_char = "seed: " → INT 8675309. Mind the space.

    Why it's better than doing it by hand

    Without this, extracting an int from a text line means a Python node, a regex, or a chain of replace nodes - all of which are more moving parts than a one-input scan. It pairs naturally with the pack's text parsers: run ExtractLinesByIndex or FindFirstLineContent upstream, then convert here. And because it matches by containment, it survives reordering - add lines above and it still finds the value.

    Install

    Part of ComfyUI_StringOps - install the pack once:

    cd ComfyUI/custom_nodes
    git clone https://github.com/MeeeyoAI/ComfyUI_StringOps.git
    

    Restart. Or ComfyUI Manager → "ComfyUI_StringOps". No model files; pack deps are the standard requests/numpy/torch/Pillow/openpyxl. Chinese UI (获取整数) with the 🐠meeeyo.com branding and the author's WeChat ad in the description.

    Common issues

    Three gotchas, all inherited from the shared line-scan logic. Whitespace kills the parse: seed: with the value on the same line but preceded by a space - include the space in target_char ("seed: "), or the remainder starts with a space and int parsing of " 42" - actually, int(" 42") is fine, but " 42px" is not. The cleaner rule: whatever's after the marker must be only the number for the int port to fill. Containment matching: data matches metadata; first hit wins, so put enough of the key in your marker to disambiguate. First-match-only: if the marker appears in an early comment, you get that line's value, not the real one.

    And one thing that's not a bug: None on the int port isn't an error state, it's the "couldn't parse" signal - that's exactly why the raw string output exists. Check the string port before blaming the node.

    It's a tiny type-conversion workhorse, and the sort of node that quietly unblocks workflows. Its float sibling GetFloatParam is identical except it returns a FLOAT.

    CategoryMeeeyo/String

    Inputs (2)

    NameTypeDefaultDescription
    input_textSTRING
    target_charSTRING

    Outputs (2)

    NameTypeDescription
    INTINT
    STRINGSTRING