Operações do BadBit CAD
cad.block.action_add
Põe uma ação num parâmetro de um bloco dinâmico (BACTION, BACTIONTOOL).
- 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 a ação action_type (move, scale, stretch, polar_stretch, rotate, flip, array, lookup; uma das que o parâmetro aceita) ligada ao parameter, com o conjunto de seleção selection_items (os índices de cad.block.definition) e selection_parameters, como o BACTION: key_point, stretch_frame (o contorno do esticar; os outros parâmetros com um ponto dentro vão junto), rotate_only_items, distance_multiplier, angle_offset em graus, xy_type, action_base_point (sem ele, o do parâmetro), column_offset e row_offset da matriz e icon_location. A ação de consulta começa com a tabela vazia (preencha com cad.block.lookup_table). Um passo do desfazer. Devolve o node da ação.
Parâmetros
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
action_base_point | array<number> | null | Não | O ponto base próprio [x, y] de escalar e girar (Independente; sem ele, o do parâmetro). |
action_type | DynActionType | Sim | O tipo da ação: move, scale, stretch, polar_stretch, rotate, flip, array ou lookup. |
angle_offset | number | null | Não | O deslocamento do ângulo da ação, em graus. |
column_offset | number | null | Não | A distância entre as colunas da matriz (padrão: o comprimento do parâmetro). |
distance_multiplier | number | null | Não | O multiplicador da distância da ação. |
icon_location | array<number> | null | Não | O lugar [x, y] do ícone da ação no editor de blocos (padrão: o fim do parâmetro). |
key_point | DynKeyPoint | null | Não | O ponto do parâmetro que a ação move: base ou end (o padrão). |
name | string | Sim | Nome (da camada, da variável de sistema ou do comando, conforme a operação). |
parameter | DynNodeRef | Sim | O parâmetro do bloco dinâmico: o node ou o rótulo. |
rotate_only_items | array<integer> | Não | Os itens que só giram no esticar polar. |
row_offset | number | null | Não | A distância entre as linhas da matriz (parâmetro XY; padrão: a altura). |
selection_items | array<integer> | Não | Os itens da definição (os índices de cad.block.definition). |
selection_parameters | array<DynNodeRef> | Não | Os parâmetros que entram no conjunto de seleção da ação (ela os leva junto). |
stretch_frame | array<array<number>> | Não | O contorno do esticar [[x, y], …] (pelo menos 3 pontos): o que está todo dentro anda, do que cruza só os pontos de dentro. |
xy_type | DynXyType | null | Não | A componente do parâmetro XY que a ação usa: xy, x ou y. |
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
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"arguments": {
"action_type": "stretch",
"name": "Door",
"parameter": "Width",
"selection_items": [
0,
1,
2
],
"stretch_frame": [
[
850,
-50
],
[
950,
-50
],
[
950,
2150
],
[
850,
2150
]
]
},
"operation": "cad.block.action_add"
},
"name": "badbit_call_operation"
}
}Python
import badbit
result = badbit.cad.block.action_add(action_type="stretch", name="Door", parameter="Width", selection_items=[0, 1, 2], stretch_frame=[[850, -50], [950, -50], [950, 2150], [850, 2150]])LISP
(badbit-call "cad.block.action_add" '(("action_type" . "stretch") ("name" . "Door") ("parameter" . "Width") ("selection_items" . (0 1 2)) ("stretch_frame" . ((850 -50) (950 -50) (950 2150) (850 2150)))))JSON-RPC
{
"id": 1,
"jsonrpc": "2.0",
"method": "badbit/call",
"params": {
"arguments": {
"action_type": "stretch",
"name": "Door",
"parameter": "Width",
"selection_items": [
0,
1,
2
],
"stretch_frame": [
[
850,
-50
],
[
950,
-50
],
[
950,
2150
],
[
850,
2150
]
]
},
"operation": "cad.block.action_add"
}
}Comandos que fazem o mesmo
Esquema completo
JSON Schema 2020-12, com as descrições em inglês.
Parâmetros (entrada)
{
"$defs": {
"DynActionType": {
"oneOf": [
{
"const": "move",
"type": "string"
},
{
"const": "scale",
"type": "string"
},
{
"const": "stretch",
"type": "string"
},
{
"const": "polar_stretch",
"type": "string"
},
{
"const": "rotate",
"type": "string"
},
{
"const": "flip",
"type": "string"
},
{
"const": "array",
"type": "string"
},
{
"const": "lookup",
"type": "string"
}
]
},
"DynKeyPoint": {
"oneOf": [
{
"const": "base",
"type": "string"
},
{
"const": "end",
"type": "string"
}
]
},
"DynNodeRef": {
"anyOf": [
{
"format": "uint32",
"minimum": 0,
"type": "integer"
},
{
"type": "string"
}
]
},
"DynXyType": {
"oneOf": [
{
"const": "xy",
"type": "string"
},
{
"const": "x",
"type": "string"
},
{
"const": "y",
"type": "string"
}
]
}
},
"$schema": "https://json-schema.org/draft/2020-12/schema",
"additionalProperties": false,
"properties": {
"action_base_point": {
"default": null,
"description": "The own base point [x, y] for scale and rotate (Independent; without it, the parameter's).",
"items": {
"format": "double",
"type": "number"
},
"maxItems": 2,
"minItems": 2,
"type": [
"array",
"null"
]
},
"action_type": {
"$ref": "#/$defs/DynActionType",
"description": "The action type: move, scale, stretch, polar_stretch, rotate, flip, array or lookup."
},
"angle_offset": {
"default": null,
"description": "The action angle offset, in degrees.",
"format": "double",
"type": [
"number",
"null"
]
},
"column_offset": {
"default": null,
"description": "The distance between array columns (default: the parameter length).",
"format": "double",
"type": [
"number",
"null"
]
},
"distance_multiplier": {
"default": null,
"description": "The action distance multiplier.",
"format": "double",
"type": [
"number",
"null"
]
},
"icon_location": {
"default": null,
"description": "The location [x, y] of the action icon in the block editor (default: the parameter end).",
"items": {
"format": "double",
"type": "number"
},
"maxItems": 2,
"minItems": 2,
"type": [
"array",
"null"
]
},
"key_point": {
"anyOf": [
{
"$ref": "#/$defs/DynKeyPoint"
},
{
"type": "null"
}
],
"default": null,
"description": "The parameter point the action moves: base or end (the default)."
},
"name": {
"description": "Name (of the layer, of the system variable or of the command, depending on the operation).",
"type": "string"
},
"parameter": {
"$ref": "#/$defs/DynNodeRef",
"description": "The dynamic block parameter: the node or the label."
},
"rotate_only_items": {
"default": [],
"description": "The items that only rotate in the polar stretch.",
"items": {
"format": "uint32",
"minimum": 0,
"type": "integer"
},
"maxItems": 100000,
"type": "array"
},
"row_offset": {
"default": null,
"description": "The distance between array rows (XY parameter; default: the height).",
"format": "double",
"type": [
"number",
"null"
]
},
"selection_items": {
"default": [],
"description": "The definition items (the indexes from cad.block.definition).",
"items": {
"format": "uint32",
"minimum": 0,
"type": "integer"
},
"maxItems": 100000,
"type": "array"
},
"selection_parameters": {
"description": "The parameters in the action selection set (it moves them along).",
"items": {
"$ref": "#/$defs/DynNodeRef"
},
"maxItems": 1000,
"type": "array"
},
"stretch_frame": {
"default": [],
"description": "The stretch frame [[x, y], …] (at least 3 points): what is fully inside moves; of what crosses it, only the points inside.",
"items": {
"items": {
"format": "double",
"type": "number"
},
"maxItems": 2,
"minItems": 2,
"type": "array"
},
"maxItems": 10000,
"type": "array"
},
"xy_type": {
"anyOf": [
{
"$ref": "#/$defs/DynXyType"
},
{
"type": "null"
}
],
"default": null,
"description": "The XY parameter component the action uses: xy, x or y."
}
},
"required": [
"name",
"parameter",
"action_type"
],
"type": "object"
}Resultado (saída)
{
"$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"
}