Operaciones de BadBit CAD
cad.block.parameter_add
Añade un parámetro a la definición de un bloque dinámico (BPARAMETER).
- Programa: BadBit CAD
- Tipo de acción: Cambia el dibujo
- Modifica el dibujo
- Desde la versión 2027.0.0-beta.8
Crea en el bloque name, sin abrir el editor de bloques, el parámetro parameter_type (point, linear, polar, xy, rotation, alignment, flip, visibility, lookup, base_point) en base_location y, en los tipos de dos puntos, end_location, con la etiqueta, la descripción, la paleta, el encadenamiento, los valores aceptados (value_set: value_list, o increment con minimum y maximum; ángulos en grados), el lugar de la etiqueta y los pinzamientos, como BPARAMETER. Sin etiqueta, la predeterminada numerada en el idioma de la interfaz. Un bloque tiene como máximo una visibilidad y un punto base. Las inserciones del bloque se rehacen guardando sus valores. Un paso de deshacer. Devuelve el node del parámetro.
Parámetros
| Nombre | Tipo | Obligatorio | Descripción |
|---|---|---|---|
base_angle | number | null | No | El ángulo base de la rotación, en grados (la línea de referencia del editor). |
base_at_middle | boolean | null | No | La base del lineal en el medio (los dos lados se mueven la mitad). |
base_location | array<number> | Sí | El primer punto [x, y] del parámetro, en coordenadas del bloque: la base, el centro de la rotación, el lugar del pinzamiento. |
chain_actions | boolean | null | No | Encadena acciones: movido por una acción de otro parámetro, dispara las suyas. |
default_angle | number | null | No | El ángulo predeterminado de la rotación, en grados (sin él, el del radio dado). |
end_location | array<number> | null | No | El segundo punto [x, y] del parámetro: el final del lineal y del polar, la esquina del XY, el radio de la rotación, la dirección de la alineación, el final de la línea de reflexión. |
grip_count | integer | null | No | Cuántos pinzamientos: 0 o 1; 2 en el lineal y el polar; 4 en el XY. |
label_location | array<number> | null | No | El lugar [x, y] de la etiqueta en el editor de bloques. |
name | string | Sí | Nombre (de la capa, de la variable de sistema o del comando, según la operación). |
parameter_description | string | null | No | La descripción del parámetro (la sugerencia de la paleta). |
parameter_label | string | null | No | La etiqueta del parámetro: el nombre de la propiedad en la paleta y en cad.block.dynamic_set. |
parameter_label2 | string | null | No | La segunda etiqueta (el ángulo del polar, la Y del XY). |
parameter_object_name | string | null | No | El nombre del objeto parámetro (el Name de BPARAMETER). |
parameter_type | DynParameterType | Sí | El tipo del parámetro: point, linear, polar, xy, rotation, alignment, flip, visibility, lookup, base_point (en los resultados, también property_table). |
perpendicular | boolean | null | No | La alineación perpendicular (falso: tangente). |
show_in_palette | boolean | null | No | Muestra la propiedad en la paleta Propiedades. |
value_set | DynValueSet | null | No | Los valores aceptados: value_list, o increment con minimum y maximum (sin nada, cualquier valor; ángulos en grados). |
value_set2 | DynValueSet | null | No | Los valores aceptados de la segunda parte (el ángulo del polar, la Y del XY). |
Errores
| Código | JSON-RPC | Qué significa |
|---|---|---|
invalid_params | -32602 | Los parámetros no siguen el esquema o una regla de la operación. |
not_found | -32001 | El objeto, la operación, el archivo o el nombre no existe. |
conflict | -32004 | El estado actual no lo permite ahora. |
failed | -32005 | La operación falló. |
Ejemplo
MCP
{
"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
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
(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
{
"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 hacen lo mismo
Esquema completo
JSON Schema 2020-12, con las descripciones en inglés.
Parámetros (entrada)
{
"$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 (salida)
{
"$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"
}