Skip to content

.bd file internals

Peter Corke edited this page Aug 6, 2024 · 4 revisions

bdedit supports models expressed in JSON format, which have the extension .bd. These contain a full description of the model as arrays of dicts:

  • blocks, a list of dicts, one per block, that contains the block parameters.
    • Inputs and outputs are described by lists of dicts, inputs and outputs, and each dict has an id attribute which references a socket on a wire
  • wires, a list of dicts, one per wire, where each wire has a unique identifier id and a start_socket and an end-socket id. The socket id matches the input or output id of a block.

    "blocks": [
        {
            "id": 140596124728768,
            "block_type": "GAIN",
            "title": "Gain Block",
            "inputsNum": 1,
            "outputsNum": 1,
            "inputs": [
                {
                    "id": 140596124784720,
                    "index": 0,
                    "multi_wire": true,
                    "position": 1,
                    "socket_type": 1
                }
            ],
            "outputs": [
                {
                    "id": 140596124784768,
                    "index": 0,
                    "multi_wire": true,
                    "position": 3,
                    "socket_type": 2
                }
            ],
            "parameters": [
                [
                    "K",
                    10
                ],
                [
                    "premul",
                    false
                ]
            ]
        },
        ...
    ],
    "wires": [
        {
            "id": 140596130377056,
            "start_socket": 140596130326896,
            "end_socket": 140596124784720,
            "wire_type": 3,
            "custom_routing": false,
            "wire_coordinates": []
        },
        {
            "id": 140596130449008,
            "start_socket": 140596124784768,
            "end_socket": 140596130327424,
            "wire_type": 3,
            "custom_routing": false,
            "wire_coordinates": []
        },
        ...
}

bdedit is the primary way to create these files, in which case blocks have additional parameters such as position (position_x, position_y), width and height. Wires are drawn as poly lines with at most five segments, and are described by a list of wire_coordinates. The file also has a list of labels and grouping_boxes.