Operações do BadBit CAD
cad.block.lookup_table
Monta a tabela de consulta de uma ação de consulta (BLOOKUPTABLE).
- Programa: BadBit CAD
- Tipo de ação: Altera o desenho
- Altera o desenho
- Desde a versão 2027.0.0-beta.8
Troca a tabela da ação de consulta dynamic_action do bloco name (sem ela, a única do bloco): lookup_inputs são os parâmetros de entrada, lookup_outputs os de consulta (tipo lookup) e lookup_rows as linhas (input_values conferidos com cada parâmetro, output_values o texto da lista); reverse_lookup, por coluna de consulta, permite escolher a linha pela lista (padrão: somente leitura), como o BLOOKUPTABLE. Um passo do desfazer. Devolve o que mudou.
Parâmetros
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
dynamic_action | DynNodeRef | null | Não | A ação do bloco dinâmico: o node ou o nome. |
lookup_inputs | array<DynNodeRef> | Sim | Os parâmetros de entrada da tabela de consulta (o node ou o rótulo; nos resultados, o node). |
lookup_outputs | array<DynNodeRef> | Sim | Os parâmetros de consulta (do tipo lookup) da tabela. |
lookup_rows | array<DynLookupRow> | Sim | As linhas da tabela de consulta, com input_values e output_values. |
name | string | Sim | Nome (da camada, da variável de sistema ou do comando, conforme a operação). |
reverse_lookup | array<boolean> | Não | Por coluna de consulta: permite escolher a linha pela lista (falso: somente leitura). |
Erros
| Código | JSON-RPC | O que significa |
|---|---|---|
invalid_params | -32602 | Os parâmetros não seguem o esquema ou uma regra da operação. |
not_found | -32001 | O objeto, a operação, o arquivo ou o nome não existe. |
conflict | -32004 | O estado atual não permite isso agora. |
failed | -32005 | A operação falhou. |
Exemplo
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"
}
}Comandos que fazem o mesmo
Esquema completo
JSON Schema 2020-12, com as descrições em inglês.
Parâmetros (entrada)
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"
}Resultado (saída)
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"
}