Saltar al contenido
BadBit Documentación
Iniciar sesión Descargar la beta

Operaciones de BadBit CAD

cad.attributes.import

Trae de vuelta los valores de los atributos de un texto separado por tabulaciones (ATTIN).

  • Programa: BadBit CAD
  • Tipo de acción: Actúa fuera del dibujo
  • Modifica el dibujo
  • Desde la versión 2027.0.0-beta.8

Lee, como ATTIN, el texto de ATTOUT (editado en una hoja de cálculo) del archivo path (ruta absoluta de un .txt) o de attributes_text y cambia los valores de los atributos de cada inserción por el HANDLE de la fila (<> no lo toca; las inserciones en capa bloqueada quedan como están). Un paso de deshacer. Devuelve cuántas inserciones y valores cambiaron y cuántas filas no encontraron inserción.

Parámetros

NombreTipoObligatorioDescripción
attributes_textstring | nullNoEl texto separado por tabulaciones de ATTOUT (el encabezado HANDLE, BLOCKNAME y las etiquetas; una fila por inserción).
pathstring | nullNoLa ruta absoluta del archivo (del dibujo, o el que la operación lee o graba).

Errores

CódigoJSON-RPCQué significa
invalid_params-32602Los parámetros no siguen el esquema o una regla de la operación.
not_found-32001El objeto, la operación, el archivo o el nombre no existe.
conflict-32004El estado actual no lo permite ahora.
failed-32005La operación falló.
busy-32006BadBit está abriendo o guardando un archivo; inténtelo de nuevo en un momento.

Ejemplo

MCP

JSON
{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "arguments": {
        "path": "/Users/me/Projects/rooms.txt"
      },
      "operation": "cad.attributes.import"
    },
    "name": "badbit_call_operation"
  }
}

Python

Python
import badbit

result = badbit.cad.attributes.import_(path="/Users/me/Projects/rooms.txt")

LISP

LISP
(badbit-call "cad.attributes.import" '(("path" . "/Users/me/Projects/rooms.txt")))

JSON-RPC

JSON
{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "badbit/call",
  "params": {
    "arguments": {
      "path": "/Users/me/Projects/rooms.txt"
    },
    "operation": "cad.attributes.import"
  }
}

Comandos que hacen lo mismo

ATTIN

Esquema completo

JSON Schema 2020-12, con las descripciones en inglés.

Parámetros (entrada)
JSON
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "additionalProperties": false,
  "properties": {
    "attributes_text": {
      "default": null,
      "description": "The tab-separated ATTOUT text (the header HANDLE, BLOCKNAME and the tags; one row per insert).",
      "type": [
        "string",
        "null"
      ]
    },
    "path": {
      "default": null,
      "description": "The absolute path of the file (of the drawing, or the one the operation reads or writes).",
      "maxLength": 4096,
      "minLength": 1,
      "type": [
        "string",
        "null"
      ]
    }
  },
  "type": "object"
}
Resultado (salida)
JSON
{
  "$defs": {
    "Changes": {
      "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"
        },
        "modified": {
          "description": "Whether there are unsaved changes; in results of changes, the identifiers of the objects changed.",
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        "truncated": {
          "description": "The lists were cut at the limit.",
          "type": "boolean"
        }
      },
      "required": [
        "created",
        "modified",
        "deleted",
        "document_changed",
        "truncated"
      ],
      "type": "object"
    }
  },
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "properties": {
    "changes": {
      "$ref": "#/$defs/Changes",
      "description": "What the request changed in the drawing."
    },
    "inserts_changed": {
      "description": "How many inserts of the block changed.",
      "format": "uint",
      "minimum": 0,
      "type": "integer"
    },
    "missing_handles": {
      "description": "How many rows did not find the insert by HANDLE.",
      "format": "uint",
      "minimum": 0,
      "type": "integer"
    },
    "skipped_locked": {
      "description": "Objects left as they were because they are on locked layers.",
      "format": "uint",
      "minimum": 0,
      "type": "integer"
    },
    "values_changed": {
      "description": "How many attribute values changed.",
      "format": "uint",
      "minimum": 0,
      "type": "integer"
    }
  },
  "required": [
    "inserts_changed",
    "values_changed",
    "missing_handles",
    "skipped_locked",
    "changes"
  ],
  "type": "object"
}
Buscar en la documentación