Pular para o conteúdo
BadBit Documentação
Entrar Baixar o beta

Operações do BadBit CAD

cad.select.filter

Acha os objetos que passam num filtro de seleção (FILTER).

  • Programa: BadBit CAD
  • Tipo de ação: Lê o desenho
  • Só leitura
  • Desde a versão 2027.0.0-beta.8

Devolve os objetos visíveis do espaço atual (ou só entre ids) que passam no filtro, como o Aplicar da janela FILTER: filter é a lista de itens na ordem, cada um um teste (property, operator e value) ou o começo (begin_group) ou o fim (end_group) de um grupo and, or, xor ou not; fora de grupo, os testes valem juntos. Ou filter_name, um filtro nomeado (cad.select.filter_list). As propriedades: object (o tipo: line, circle, insert...), layer, color, linetype, lineweight (mm), radius, length, area, x, y, text, text_height, text_style, block, attribute_tag, attribute_value e rotation (graus). Os operadores: eq (o padrão; nos textos com * e ?), ne, lt, le, gt, ge e any (qualquer valor); os de ordem só nas medidas, nas cores e nas espessuras. Só devolve os identificadores: a seleção da pessoa não muda.

Parâmetros

NomeTipoObrigatórioDescrição
filterarray<FilterItem> | nullNãoOs itens do filtro, na ordem: testes (property, operator, value) e grupos (begin_group, end_group).
filter_namestring | nullNãoO nome do filtro de seleção.
idsarray<string> | nullNãoIdentificadores de objetos (32 dígitos hexadecimais cada).

Erros

CódigoJSON-RPCO que significa
invalid_params-32602Os parâmetros não seguem o esquema ou uma regra da operação.
not_found-32001O objeto, a operação, o arquivo ou o nome não existe.
permission_denied-32002O pedido não é aceito (o detalhe diz por quê).
conflict-32004O estado atual não permite isso agora.

Exemplo

MCP

JSON
{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "arguments": {
        "filter": [
          {
            "property": "object",
            "value": "circle"
          },
          {
            "operator": "ge",
            "property": "radius",
            "value": 5
          }
        ]
      },
      "operation": "cad.select.filter"
    },
    "name": "badbit_call_operation"
  }
}

Python

Python
import badbit

result = badbit.cad.select.filter(filter=[{"property": "object", "value": "circle"}, {"operator": "ge", "property": "radius", "value": 5}])

LISP

LISP
(badbit-call "cad.select.filter" '(("filter" . ((("property" . "object") ("value" . "circle")) (("operator" . "ge") ("property" . "radius") ("value" . 5))))))

JSON-RPC

JSON
{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "badbit/call",
  "params": {
    "arguments": {
      "filter": [
        {
          "property": "object",
          "value": "circle"
        },
        {
          "operator": "ge",
          "property": "radius",
          "value": 5
        }
      ]
    },
    "operation": "cad.select.filter"
  }
}

Comandos que fazem o mesmo

FILTER

Esquema completo

JSON Schema 2020-12, com as descrições em inglês.

Parâmetros (entrada)
JSON
{
  "$defs": {
    "FilterGroup": {
      "oneOf": [
        {
          "const": "and",
          "type": "string"
        },
        {
          "const": "or",
          "type": "string"
        },
        {
          "const": "xor",
          "type": "string"
        },
        {
          "const": "not",
          "type": "string"
        }
      ]
    },
    "FilterItem": {
      "additionalProperties": false,
      "properties": {
        "begin_group": {
          "anyOf": [
            {
              "$ref": "#/$defs/FilterGroup"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Starts a group: and, or, xor or not."
        },
        "end_group": {
          "anyOf": [
            {
              "$ref": "#/$defs/FilterGroup"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Closes the open group (the same name as the start)."
        },
        "operator": {
          "anyOf": [
            {
              "$ref": "#/$defs/FilterOperator"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The operator: eq (the default), ne, lt, le, gt, ge or any (any value)."
        },
        "property": {
          "anyOf": [
            {
              "$ref": "#/$defs/FilterProperty"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The tested property: object, layer, color, linetype, lineweight, radius, length, area, x, y, text, text_height, text_style, block, attribute_tag, attribute_value or rotation."
        },
        "value": {
          "anyOf": [
            {
              "$ref": "#/$defs/FilterValue"
            },
            {
              "type": "null"
            }
          ],
          "description": "The value: of the system variable (text as typed in SETVAR, or a number), of the measurement, of the calculation or of the filter test (number, angle in degrees, color, lineweight in mm, object type or text with * and ?)."
        }
      },
      "type": "object"
    },
    "FilterOperator": {
      "oneOf": [
        {
          "const": "eq",
          "type": "string"
        },
        {
          "const": "ne",
          "type": "string"
        },
        {
          "const": "lt",
          "type": "string"
        },
        {
          "const": "le",
          "type": "string"
        },
        {
          "const": "gt",
          "type": "string"
        },
        {
          "const": "ge",
          "type": "string"
        },
        {
          "const": "any",
          "type": "string"
        }
      ]
    },
    "FilterProperty": {
      "oneOf": [
        {
          "const": "object",
          "type": "string"
        },
        {
          "const": "layer",
          "type": "string"
        },
        {
          "const": "color",
          "type": "string"
        },
        {
          "const": "linetype",
          "type": "string"
        },
        {
          "const": "lineweight",
          "type": "string"
        },
        {
          "const": "radius",
          "type": "string"
        },
        {
          "const": "length",
          "type": "string"
        },
        {
          "const": "area",
          "type": "string"
        },
        {
          "const": "x",
          "type": "string"
        },
        {
          "const": "y",
          "type": "string"
        },
        {
          "const": "text",
          "type": "string"
        },
        {
          "const": "text_height",
          "type": "string"
        },
        {
          "const": "text_style",
          "type": "string"
        },
        {
          "const": "block",
          "type": "string"
        },
        {
          "const": "attribute_tag",
          "type": "string"
        },
        {
          "const": "attribute_value",
          "type": "string"
        },
        {
          "const": "rotation",
          "type": "string"
        }
      ]
    },
    "FilterValue": {
      "anyOf": [
        {
          "format": "double",
          "type": "number"
        },
        {
          "type": "string"
        }
      ]
    }
  },
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "additionalProperties": false,
  "properties": {
    "filter": {
      "description": "The filter items, in order: tests (property, operator, value) and groups (begin_group, end_group).",
      "items": {
        "$ref": "#/$defs/FilterItem"
      },
      "maxItems": 10000,
      "type": [
        "array",
        "null"
      ]
    },
    "filter_name": {
      "default": null,
      "description": "The name of the selection filter.",
      "maxLength": 255,
      "minLength": 1,
      "type": [
        "string",
        "null"
      ]
    },
    "ids": {
      "default": null,
      "description": "Object identifiers (32 hexadecimal digits each).",
      "items": {
        "type": "string"
      },
      "maxItems": 200000,
      "minItems": 1,
      "type": [
        "array",
        "null"
      ]
    }
  },
  "type": "object"
}
Resultado (saída)
JSON
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "properties": {
    "ids": {
      "description": "Object identifiers (32 hexadecimal digits each).",
      "items": {
        "type": "string"
      },
      "type": "array"
    },
    "total": {
      "description": "How many items match the filters (in all pages).",
      "format": "uint",
      "minimum": 0,
      "type": "integer"
    },
    "truncated": {
      "description": "The lists were cut at the limit.",
      "type": "boolean"
    }
  },
  "required": [
    "ids",
    "total",
    "truncated"
  ],
  "type": "object"
}
Buscar na documentação