Content-Length: 289549 | pFad | http://github.com/davidlatwe/nuke-knobby

BF GitHub - davidlatwe/nuke-knobby: Parsing back and forth between dict and node knobs in Nuke
Skip to content

Parsing back and forth between dict and node knobs in Nuke

License

Notifications You must be signed in to change notification settings

davidlatwe/nuke-knobby

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 

Repository files navigation

nuke-knobby

Parsing back and forth between dict and node knobs in Nuke.

Features

  • Convert dict data into Nuke node knobs.
  • Extract knob values back into dict.
  • Won't have duplicated knobs in multiple imprints to same node.
  • Knob name will be prefixed with parent tab name.

Examples

Imprint

Parsing dict into knobs under a tab

import nuke
from collections import OrderedDict
from knobby import util

node = nuke.createNode("NoOp")
data = OrderedDict([
    # Regular type of attributes
    ("options", ["x", "y", "z"]),
    ("enable", True),
    ("width", 100.15),
    ("count", 5),

    # Manual nice knob naming
    (("speach", "My Speach"), "Hello World!"),

    # Creating non-default imprint type of knob
    ("filePath", util.Knobby("File_Knob", "/file/path")),
    (("divider1", ""), util.Knobby("Text_Knob", "")),

    # dict type will be created as knob group
    (
        "KnobGroup",
        OrderedDict([
            ("knob1", 5),
            ("knob2", "hello"),
            ("knob3", ["a", "b"]),
        ])
    ),

    (("divider2", ""), util.Knobby("Text_Knob", "")),

    # Nested dict will be created as tab group
    (
        "TabGroup",
        OrderedDict([
            ("tab1", {"count": 5}),
            ("tab2", {"isGood": True}),
            ("tab3", {"direction": ["Left", "Right"]}),
        ]),
    ),
])

util.imprint(node, data, tab="Demo")

Read

Parsing user knobs with filter and put into dict

import nuke
from knobby import util

node = nuke.createNode("NoOp")
util.imprint(node, {"value": 5}, tab="this")
util.imprint(node, {"value": 2}, tab="that")

def get_value(name):
    tab, name, *args = name.split(":")[:2]
    return name if tab == "this" and name == "value" else None

heights = util.read(node, filter=get_value)
assert heights == {"value": 5}

Mold

Parsing user knobs by tab and put into dict with tab hierarchy preserved

import nuke
from knobby import util

node = nuke.createNode("NoOp")
data = {
    "data": {
        "david": {
            "age": 31,
            "height": 172.9,
            "weight": 78,
        },
        "tom": {
            "age": 27,
            "height": 165.9,
            "weight": 68,
        },
    }
}
util.imprint(node, data, tab="person")

mold = util.mold(node)
assert mold == {"person": data}

mold = util.mold(node, tab="person")
assert mold == data

mold = util.mold(node, tab="person:data:tom")
assert mold == {
    "age": 27,
    "height": 165.9,
    "weight": 68,
}

About

Parsing back and forth between dict and node knobs in Nuke

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages









ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/davidlatwe/nuke-knobby

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy