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

Operações do BadBit CAD

cad.block.parameter_add

Põe um parâmetro na definição de um bloco dinâmico (BPARAMETER).

  • Programa: BadBit CAD
  • Tipo de ação: Altera o desenho
  • Altera o desenho
  • Desde a versão 2027.0.0-beta.8

Cria no bloco name, sem abrir o editor de blocos, o parâmetro parameter_type (point, linear, polar, xy, rotation, alignment, flip, visibility, lookup, base_point) em base_location e, nos tipos de dois pontos, end_location, com o rótulo, a descrição, a paleta, o encadear, os valores aceitos (value_set: value_list ou increment com minimum e maximum; ângulos em graus), o lugar do rótulo e os grips, como o BPARAMETER. Sem rótulo, o padrão numerado do idioma da interface. Um bloco tem no máximo uma visibilidade e um ponto base. As inserções do bloco são refeitas guardando os valores delas. Um passo do desfazer. Devolve o node do parâmetro.

Parâmetros

NomeTipoObrigatórioDescrição
base_anglenumber | nullNãoO ângulo base da rotação, em graus (a linha de referência do editor).
base_at_middleboolean | nullNãoA base do linear no meio (os dois lados andam a metade).
base_locationarray<number>SimO primeiro ponto [x, y] do parâmetro, nas coordenadas do bloco: a base, o centro da rotação, o lugar do grip.
chain_actionsboolean | nullNãoEncadeia ações: levado por uma ação de outro parâmetro, dispara as dele.
default_anglenumber | nullNãoO ângulo padrão da rotação, em graus (sem ele, o do raio dado).
end_locationarray<number> | nullNãoO segundo ponto [x, y] do parâmetro: o fim do linear e do polar, o canto do XY, o raio da rotação, a direção do alinhamento, o fim da linha de reflexão.
grip_countinteger | nullNãoQuantos grips: 0 ou 1; 2 no linear e no polar; 4 no XY.
label_locationarray<number> | nullNãoO lugar [x, y] do rótulo no editor de blocos.
namestringSimNome (da camada, da variável de sistema ou do comando, conforme a operação).
parameter_descriptionstring | nullNãoA descrição do parâmetro (a dica da paleta).
parameter_labelstring | nullNãoO rótulo do parâmetro: o nome da propriedade na paleta e em cad.block.dynamic_set.
parameter_label2string | nullNãoO segundo rótulo (o ângulo do polar, o Y do XY).
parameter_object_namestring | nullNãoO nome do objeto parâmetro (o Name do BPARAMETER).
parameter_typeDynParameterTypeSimO tipo do parâmetro: point, linear, polar, xy, rotation, alignment, flip, visibility, lookup, base_point (nos resultados, também property_table).
perpendicularboolean | nullNãoO alinhamento perpendicular (falso: tangente).
show_in_paletteboolean | nullNãoMostra a propriedade na paleta Propriedades.
value_setDynValueSet | nullNãoOs valores aceitos: value_list, ou increment com minimum e maximum (sem nada, qualquer valor; ângulos em graus).
value_set2DynValueSet | nullNãoOs valores aceitos da segunda parte (o ângulo do polar, o Y do XY).

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.
conflict-32004O estado atual não permite isso agora.
failed-32005A operação falhou.

Exemplo

MCP

JSON
{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "arguments": {
        "base_location": [
          0,
          0
        ],
        "end_location": [
          900,
          0
        ],
        "name": "Door",
        "parameter_label": "Width",
        "parameter_type": "linear",
        "value_set": {
          "increment": 100,
          "maximum": 1200,
          "minimum": 600
        }
      },
      "operation": "cad.block.parameter_add"
    },
    "name": "badbit_call_operation"
  }
}

Python

Python
import badbit

result = badbit.cad.block.parameter_add(base_location=[0, 0], end_location=[900, 0], name="Door", parameter_label="Width", parameter_type="linear", value_set={"increment": 100, "maximum": 1200, "minimum": 600})

LISP

LISP
(badbit-call "cad.block.parameter_add" '(("base_location" . (0 0)) ("end_location" . (900 0)) ("name" . "Door") ("parameter_label" . "Width") ("parameter_type" . "linear") ("value_set" . (("increment" . 100) ("maximum" . 1200) ("minimum" . 600)))))

JSON-RPC

JSON
{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "badbit/call",
  "params": {
    "arguments": {
      "base_location": [
        0,
        0
      ],
      "end_location": [
        900,
        0
      ],
      "name": "Door",
      "parameter_label": "Width",
      "parameter_type": "linear",
      "value_set": {
        "increment": 100,
        "maximum": 1200,
        "minimum": 600
      }
    },
    "operation": "cad.block.parameter_add"
  }
}

Comandos que fazem o mesmo

BPARAMETER

Esquema completo

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

Parâmetros (entrada)
JSON
{
  "$defs": {
    "DynParameterType": {
      "oneOf": [
        {
          "const": "point",
          "type": "string"
        },
        {
          "const": "linear",
          "type": "string"
        },
        {
          "const": "polar",
          "type": "string"
        },
        {
          "const": "xy",
          "type": "string"
        },
        {
          "const": "rotation",
          "type": "string"
        },
        {
          "const": "alignment",
          "type": "string"
        },
        {
          "const": "flip",
          "type": "string"
        },
        {
          "const": "visibility",
          "type": "string"
        },
        {
          "const": "lookup",
          "type": "string"
        },
        {
          "const": "base_point",
          "type": "string"
        },
        {
          "const": "property_table",
          "type": "string"
        }
      ]
    },
    "DynValueSet": {
      "additionalProperties": false,
      "properties": {
        "increment": {
          "description": "The increment of the accepted values (greater than zero).",
          "format": "double",
          "type": [
            "number",
            "null"
          ]
        },
        "maximum": {
          "description": "The largest accepted value.",
          "format": "double",
          "type": [
            "number",
            "null"
          ]
        },
        "minimum": {
          "description": "The smallest accepted value.",
          "format": "double",
          "type": [
            "number",
            "null"
          ]
        },
        "value_list": {
          "description": "The list of accepted values (the one in the block drawing always counts).",
          "items": {
            "format": "double",
            "type": "number"
          },
          "maxItems": 10000,
          "type": "array"
        }
      },
      "type": "object"
    }
  },
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "additionalProperties": false,
  "properties": {
    "base_angle": {
      "default": null,
      "description": "The rotation base angle, in degrees (the editor reference line).",
      "format": "double",
      "type": [
        "number",
        "null"
      ]
    },
    "base_at_middle": {
      "default": null,
      "description": "The linear base at the middle (both sides move half).",
      "type": [
        "boolean",
        "null"
      ]
    },
    "base_location": {
      "description": "The first point [x, y] of the parameter, in block coordinates: the base, the rotation center, the grip location.",
      "items": {
        "format": "double",
        "type": "number"
      },
      "maxItems": 2,
      "minItems": 2,
      "type": "array"
    },
    "chain_actions": {
      "default": null,
      "description": "Chains actions: moved by an action of another parameter, it fires its own.",
      "type": [
        "boolean",
        "null"
      ]
    },
    "default_angle": {
      "default": null,
      "description": "The default rotation angle, in degrees (without it, that of the given radius).",
      "format": "double",
      "type": [
        "number",
        "null"
      ]
    },
    "end_location": {
      "default": null,
      "description": "The second point [x, y] of the parameter: the end of linear and polar, the XY corner, the rotation radius, the alignment direction, the end of the reflection line.",
      "items": {
        "format": "double",
        "type": "number"
      },
      "maxItems": 2,
      "minItems": 2,
      "type": [
        "array",
        "null"
      ]
    },
    "grip_count": {
      "default": null,
      "description": "How many grips: 0 or 1; 2 for linear and polar; 4 for XY.",
      "format": "uint8",
      "maximum": 255,
      "minimum": 0,
      "type": [
        "integer",
        "null"
      ]
    },
    "label_location": {
      "default": null,
      "description": "The location [x, y] of the label in the block editor.",
      "items": {
        "format": "double",
        "type": "number"
      },
      "maxItems": 2,
      "minItems": 2,
      "type": [
        "array",
        "null"
      ]
    },
    "name": {
      "description": "Name (of the layer, of the system variable or of the command, depending on the operation).",
      "type": "string"
    },
    "parameter_description": {
      "default": null,
      "description": "The parameter description (the palette tip).",
      "type": [
        "string",
        "null"
      ]
    },
    "parameter_label": {
      "default": null,
      "description": "The parameter label: the property name in the palette and in cad.block.dynamic_set.",
      "type": [
        "string",
        "null"
      ]
    },
    "parameter_label2": {
      "default": null,
      "description": "The second label (the polar angle, the XY Y).",
      "type": [
        "string",
        "null"
      ]
    },
    "parameter_object_name": {
      "default": null,
      "description": "The parameter object name (the BPARAMETER Name).",
      "type": [
        "string",
        "null"
      ]
    },
    "parameter_type": {
      "$ref": "#/$defs/DynParameterType",
      "description": "The parameter type: point, linear, polar, xy, rotation, alignment, flip, visibility, lookup, base_point (in results, also property_table)."
    },
    "perpendicular": {
      "default": null,
      "description": "Perpendicular alignment (false: tangent).",
      "type": [
        "boolean",
        "null"
      ]
    },
    "show_in_palette": {
      "default": null,
      "description": "Shows the property in the Properties palette.",
      "type": [
        "boolean",
        "null"
      ]
    },
    "value_set": {
      "anyOf": [
        {
          "$ref": "#/$defs/DynValueSet"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "The accepted values: value_list, or increment with minimum and maximum (nothing: any value; angles in degrees)."
    },
    "value_set2": {
      "anyOf": [
        {
          "$ref": "#/$defs/DynValueSet"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "The accepted values of the second part (the polar angle, the XY Y)."
    }
  },
  "required": [
    "name",
    "parameter_type",
    "base_location"
  ],
  "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"
}
Buscar na documentação