Skip to content
BadBit Documentation
Sign in Download the beta

BadBit CAD operations

cad.block.lookup_table

Builds the lookup table of a lookup action (BLOOKUPTABLE).

  • Program: BadBit CAD
  • Type of action: Changes the drawing
  • Changes the drawing
  • Since version 2027.0.0-beta.8

Replaces the table of the lookup action dynamic_action of the block name (without it, the block's only one): lookup_inputs are the input parameters, lookup_outputs the lookup parameters (lookup type) and lookup_rows the rows (input_values checked against each parameter, output_values the list text); reverse_lookup, per lookup column, allows choosing the row from the list (default: read only), like BLOOKUPTABLE. One undo step. Returns what changed.

Parameters

NameTypeRequiredDescription
dynamic_actionDynNodeRef | nullNoThe dynamic block action: the node or the name.
lookup_inputsarray<DynNodeRef>YesThe lookup table input parameters (the node or the label; in results, the node).
lookup_outputsarray<DynNodeRef>YesThe lookup parameters (lookup type) of the table.
lookup_rowsarray<DynLookupRow>YesThe lookup table rows, with input_values and output_values.
namestringYesName (of the layer, of the system variable or of the command, depending on the operation).
reverse_lookuparray<boolean>NoPer lookup column: allows choosing the row from the list (false: read only).

Errors

CodeJSON-RPCMeaning
invalid_params-32602The parameters do not follow the schema or a rule of the operation.
not_found-32001The object, operation, file or name does not exist.
conflict-32004The current state does not allow this now.
failed-32005The operation failed.

Example

MCP

JSON
{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "arguments": {
        "lookup_inputs": [
          "Width"
        ],
        "lookup_outputs": [
          "Size"
        ],
        "lookup_rows": [
          {
            "input_values": [
              "700"
            ],
            "output_values": [
              "Small"
            ]
          },
          {
            "input_values": [
              "900"
            ],
            "output_values": [
              "Large"
            ]
          }
        ],
        "name": "Door"
      },
      "operation": "cad.block.lookup_table"
    },
    "name": "badbit_call_operation"
  }
}

Python

Python
import badbit

result = badbit.cad.block.lookup_table(lookup_inputs=["Width"], lookup_outputs=["Size"], lookup_rows=[{"input_values": ["700"], "output_values": ["Small"]}, {"input_values": ["900"], "output_values": ["Large"]}], name="Door")

LISP

LISP
(badbit-call "cad.block.lookup_table" '(("lookup_inputs" . ("Width")) ("lookup_outputs" . ("Size")) ("lookup_rows" . ((("input_values" . ("700")) ("output_values" . ("Small"))) (("input_values" . ("900")) ("output_values" . ("Large"))))) ("name" . "Door")))

JSON-RPC

JSON
{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "badbit/call",
  "params": {
    "arguments": {
      "lookup_inputs": [
        "Width"
      ],
      "lookup_outputs": [
        "Size"
      ],
      "lookup_rows": [
        {
          "input_values": [
            "700"
          ],
          "output_values": [
            "Small"
          ]
        },
        {
          "input_values": [
            "900"
          ],
          "output_values": [
            "Large"
          ]
        }
      ],
      "name": "Door"
    },
    "operation": "cad.block.lookup_table"
  }
}

Commands that do the same

BLOOKUPTABLE

Full schema

JSON Schema 2020-12.

Parameters (input)
JSON
{
  "$defs": {
    "DynLookupRow": {
      "additionalProperties": false,
      "properties": {
        "input_values": {
          "description": "The row input values, one per input parameter.",
          "items": {
            "type": "string"
          },
          "maxItems": 100,
          "type": "array"
        },
        "output_values": {
          "description": "The row lookup values (the list text), one per lookup parameter.",
          "items": {
            "type": "string"
          },
          "maxItems": 100,
          "type": "array"
        }
      },
      "required": [
        "input_values",
        "output_values"
      ],
      "type": "object"
    },
    "DynNodeRef": {
      "anyOf": [
        {
          "format": "uint32",
          "minimum": 0,
          "type": "integer"
        },
        {
          "type": "string"
        }
      ]
    }
  },
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "additionalProperties": false,
  "properties": {
    "dynamic_action": {
      "anyOf": [
        {
          "$ref": "#/$defs/DynNodeRef"
        },
        {
          "type": "null"
        }
      ],
      "description": "The dynamic block action: the node or the name."
    },
    "lookup_inputs": {
      "description": "The lookup table input parameters (the node or the label; in results, the node).",
      "items": {
        "$ref": "#/$defs/DynNodeRef"
      },
      "maxItems": 100,
      "type": "array"
    },
    "lookup_outputs": {
      "description": "The lookup parameters (lookup type) of the table.",
      "items": {
        "$ref": "#/$defs/DynNodeRef"
      },
      "maxItems": 100,
      "minItems": 1,
      "type": "array"
    },
    "lookup_rows": {
      "description": "The lookup table rows, with input_values and output_values.",
      "items": {
        "$ref": "#/$defs/DynLookupRow"
      },
      "maxItems": 10000,
      "type": "array"
    },
    "name": {
      "description": "Name (of the layer, of the system variable or of the command, depending on the operation).",
      "type": "string"
    },
    "reverse_lookup": {
      "default": [],
      "description": "Per lookup column: allows choosing the row from the list (false: read only).",
      "items": {
        "type": "boolean"
      },
      "maxItems": 100,
      "type": "array"
    }
  },
  "required": [
    "name",
    "lookup_inputs",
    "lookup_outputs",
    "lookup_rows"
  ],
  "type": "object"
}
Result (output)
JSON
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "properties": {
    "created": {
      "description": "Identifiers of the objects created.",
      "items": {
        "type": "string"
      },
      "type": "array"
    },
    "deleted": {
      "description": "The identifiers of what was deleted.",
      "items": {
        "type": "string"
      },
      "type": "array"
    },
    "document_changed": {
      "description": "The drawing on screen is another one (opened, closed or changed tab): the lists of changes do not apply.",
      "type": "boolean"
    },
    "inserts_changed": {
      "description": "How many inserts of the block changed.",
      "format": "uint",
      "minimum": 0,
      "type": "integer"
    },
    "modified": {
      "description": "Whether there are unsaved changes; in results of changes, the identifiers of the objects changed.",
      "items": {
        "type": "string"
      },
      "type": "array"
    },
    "node": {
      "description": "The node number of the parameter or action (what the other dynamic block operations use).",
      "format": "uint32",
      "minimum": 0,
      "type": [
        "integer",
        "null"
      ]
    },
    "skipped_locked": {
      "description": "Objects left as they were because they are on locked layers.",
      "format": "uint",
      "minimum": 0,
      "type": "integer"
    },
    "truncated": {
      "description": "The lists were cut at the limit.",
      "type": "boolean"
    }
  },
  "required": [
    "inserts_changed",
    "created",
    "modified",
    "deleted",
    "document_changed",
    "truncated"
  ],
  "type": "object"
}
Search the documentation