Skip to content
BadBit Documentation
Sign in Download the beta

BadBit CAD operations

cad.modify.pedit

Edits polylines (PEDIT).

  • Program: BadBit CAD
  • Type of action: Changes the drawing
  • Deletes
  • Since version 2027.0.0-beta.8

Does one PEDIT option on the polylines ids, in one undo step: action close, open, join (join_ids, fuzz), width (polyline_width), fit, spline, decurve, reverse, linetype_gen (linetype_generation) or, on a single polyline, move_vertex and insert_vertex (vertex, point), straighten and break (vertex, to_vertex) and vertex_width (vertex, start_width, end_width). Vertices count from 0. convert first turns lines, arcs and splines into polylines. Returns what changed. With paper space objects, the coordinates and the measures are in mm (model and paper space objects in the same request are refused); angles and scale factors do not change.

Parameters

NameTypeRequiredDescription
actionPeditActionYesWhat to do (the command option).
convertbooleanNoFirst turns lines, arcs and splines into polylines (the Yes answer of PEDIT).
end_widthnumber | nullNoThe width at the end of the segment.
fuzznumber | nullNoThe fuzz distance: ends within it are joined.
idsarray<string>YesObject identifiers (32 hexadecimal digits each).
join_idsarray<string>NoThe objects joined to the polyline.
linetype_generationboolean | nullNoContinuous linetype generation through the vertices (on or off).
pointarray<number> | nullNoPoint [x, y]. In the answers of suite.command.run it works like a click: the running object snap (OSMODE) applies at the exact point and an associative dimension links to the object; with no snap there, like typed coordinates.
polyline_widthnumber | nullNoWidth of the polyline.
start_widthnumber | nullNoThe width at the start of the segment.
to_vertexinteger | nullNoThe other vertex of the stretch (0 is the first).
vertexinteger | nullNoThe vertex (0 is the first).

Errors

CodeJSON-RPCMeaning
invalid_params-32602The parameters do not follow the schema or a rule of the operation.
not_found-32001The object, operation, file or name does not exist.
conflict-32004The current state does not allow this now.
failed-32005The operation failed.

Example

MCP

JSON
{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "arguments": {
        "action": "close",
        "ids": [
          "0190f3a2b4c5d6e7f8091a2b3c4d5e6f"
        ]
      },
      "operation": "cad.modify.pedit"
    },
    "name": "badbit_call_operation"
  }
}

Python

Python
import badbit

result = badbit.cad.modify.pedit(action="close", ids=["0190f3a2b4c5d6e7f8091a2b3c4d5e6f"])

LISP

LISP
(badbit-call "cad.modify.pedit" '(("action" . "close") ("ids" . ("0190f3a2b4c5d6e7f8091a2b3c4d5e6f"))))

JSON-RPC

JSON
{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "badbit/call",
  "params": {
    "arguments": {
      "action": "close",
      "ids": [
        "0190f3a2b4c5d6e7f8091a2b3c4d5e6f"
      ]
    },
    "operation": "cad.modify.pedit"
  }
}

Commands that do the same

PEDIT

Full schema

JSON Schema 2020-12.

Parameters (input)
JSON
{
  "$defs": {
    "PeditAction": {
      "oneOf": [
        {
          "const": "close",
          "type": "string"
        },
        {
          "const": "open",
          "type": "string"
        },
        {
          "const": "join",
          "type": "string"
        },
        {
          "const": "width",
          "type": "string"
        },
        {
          "const": "fit",
          "type": "string"
        },
        {
          "const": "spline",
          "type": "string"
        },
        {
          "const": "decurve",
          "type": "string"
        },
        {
          "const": "reverse",
          "type": "string"
        },
        {
          "const": "linetype_gen",
          "type": "string"
        },
        {
          "const": "move_vertex",
          "type": "string"
        },
        {
          "const": "insert_vertex",
          "type": "string"
        },
        {
          "const": "straighten",
          "type": "string"
        },
        {
          "const": "break",
          "type": "string"
        },
        {
          "const": "vertex_width",
          "type": "string"
        }
      ]
    }
  },
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "additionalProperties": false,
  "properties": {
    "action": {
      "$ref": "#/$defs/PeditAction",
      "description": "What to do (the command option)."
    },
    "convert": {
      "default": false,
      "description": "First turns lines, arcs and splines into polylines (the Yes answer of PEDIT).",
      "type": "boolean"
    },
    "end_width": {
      "default": null,
      "description": "The width at the end of the segment.",
      "format": "double",
      "type": [
        "number",
        "null"
      ]
    },
    "fuzz": {
      "default": null,
      "description": "The fuzz distance: ends within it are joined.",
      "format": "double",
      "type": [
        "number",
        "null"
      ]
    },
    "ids": {
      "description": "Object identifiers (32 hexadecimal digits each).",
      "items": {
        "type": "string"
      },
      "maxItems": 200000,
      "minItems": 1,
      "type": "array"
    },
    "join_ids": {
      "default": [],
      "description": "The objects joined to the polyline.",
      "items": {
        "type": "string"
      },
      "maxItems": 200000,
      "type": "array"
    },
    "linetype_generation": {
      "default": null,
      "description": "Continuous linetype generation through the vertices (on or off).",
      "type": [
        "boolean",
        "null"
      ]
    },
    "point": {
      "default": null,
      "description": "Point [x, y]. In the answers of suite.command.run it works like a click: the running object snap (OSMODE) applies at the exact point and an associative dimension links to the object; with no snap there, like typed coordinates.",
      "items": {
        "format": "double",
        "type": "number"
      },
      "maxItems": 2,
      "minItems": 2,
      "type": [
        "array",
        "null"
      ]
    },
    "polyline_width": {
      "default": null,
      "description": "Width of the polyline.",
      "format": "double",
      "type": [
        "number",
        "null"
      ]
    },
    "start_width": {
      "default": null,
      "description": "The width at the start of the segment.",
      "format": "double",
      "type": [
        "number",
        "null"
      ]
    },
    "to_vertex": {
      "default": null,
      "description": "The other vertex of the stretch (0 is the first).",
      "format": "uint32",
      "minimum": 0,
      "type": [
        "integer",
        "null"
      ]
    },
    "vertex": {
      "default": null,
      "description": "The vertex (0 is the first).",
      "format": "uint32",
      "minimum": 0,
      "type": [
        "integer",
        "null"
      ]
    }
  },
  "required": [
    "ids",
    "action"
  ],
  "type": "object"
}
Result (output)
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"
    },
    "modified": {
      "description": "Whether there are unsaved changes; in results of changes, the identifiers of the objects changed.",
      "items": {
        "type": "string"
      },
      "type": "array"
    },
    "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": [
    "created",
    "modified",
    "deleted",
    "document_changed",
    "truncated"
  ],
  "type": "object"
}
Search the documentation