Skip to content

Node setup presets

MrClock edited this page Jul 10, 2022 · 1 revision

Overview

Node setup presets give a quick and simple way to insert frequently used basic setups into the node tree. There are two types of setup presets:

  • Custom: presets that are defined in a custom directory in a specific format
  • Built-in: presets that are included in the addon files

Custom presets

Custom presets are loaded from an external folder which can be specified in the addon preferences.

Custom presets can be created by either manually writing an appropriate JSON file, or using the New custom preset function on the sidebar. They can also be deleted by the Delete custom preset function, located at the same place.

Built-in presets

Built-in presets are defined in the exact same format as custom presets, but are shipped with the addon, and located in one of the own folders of the addon.

Unlike custom presets, built-in presets cannot be created or deleted.

Files

  • presets are defined in .json files
  • only preset files should be in the folder
  • file name does not matter as long as it only contains alphanumeric characters and underscores
  • file names for custom presets are generated in the setuppreset_#STAMP#.json format where #STAMP# is replaced by a YYYYMMDDHHMMSS timestamp to mitigate the chance of file name conflicts (in case it still happens against all odds, the action taken is decided by the addon preferences)

Definition

Presets are defined in json data format, with 9 (+1 generated at runtime when the presets are loaded) data fields. These fields are mandatory, the abscence of one or more fields will raise errors.

The fields are as follows:

"custom" : true

For custom presets, this value should obviously always be true.

"name" : ""

The name value is what is visibly shown in the preset list.

"desc" : ""

The desc value is the description attached to the preset in the preset list.

"nodes" : []

List of nodes to insert as part of the preset, indentified by their python class names as strings.

"x" : []

List of X coordinates of nodes (recommended to be 0 for first node, and then define other nodes relative to that)

"y" : []

List of Y coordinates of nodes (recommended to be 0 for first node, and then define other nodes relative to that)

"settings" : []

List of settings to change on the node before (important for list nodes) creating links. Each item in the list should be a list of three values:

[index of node in nodes field, "name of setting to change", new value of the setting]

"links" : []

List of links to create between the nodes. Each item in the list should be a list of four values:

[index of node with output, index of node with imput, index of output scoket, index of input socket]

(the node indexes are referencing to the nodes field)

"postsettings" : []

List of settings to apply after the creation of links. The format of this field is the same as the settings field.

Example

File name: example.json

File is included in the examples folder of the addon.

{
    "custom": true,
    "name": "Example",
    "desc": "Example preset JSON file",
    "nodes": [
        "MCFG_N_Skeleton",
        "MCFG_N_Model",
        "MCFG_N_BoneList",
        "MCFG_N_Bone",
        "MCFG_N_SectionList"
    ],
    "x": [
        40,
        340,
        -160,
        -360,
        140
    ],
    "y": [
        80,
        80,
        -20,
        -20,
        -120
    ],
    "settings": [],
    "links": [
        [
            0,
            1,
            0,
            2
        ],
        [
            2,
            0,
            0,
            3
        ],
        [
            3,
            2,
            0,
            0
        ],
        [
            4,
            1,
            0,
            3
        ]
    ],
    "postsettings": []
}

Clone this wiki locally