BadBit CAD operations
cad.annotate.dim_linear
Linear dimension (DIMLINEAR) between two origins.
- Program: BadBit CAD
- Type of action: Changes the drawing
- Changes the drawing
- Since version 2027.0.0-beta.8
Creates the DIMLINEAR linear dimension from first_origin to second_origin, with the dimension line through dim_line_point, in the current dimension style (and its overrides). orientation horizontal or vertical, or dim_rotation in degrees (the Rotated option); without them, horizontal or vertical by the location, like the cursor in the command. dim_text replaces the text (<> is the measurement) and text_angle rotates the text (degrees). On the current layer. With DIMASSOC 2, each origin given exactly at an endpoint, midpoint, center or intersection of an object links the dimension to it (it follows the object). Returns the identifier, the text the dimension shows and the links. In paper space (a layout on screen, outside the viewports), the coordinates and the measures are in mm; angles and scale factors do not change.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
dim_line_point | array<number> | Yes | A point [x, y] the dimension line (or arc) passes through; in radial and ordinate dimensions, where the text goes. |
dim_rotation | number | null | No | The rotation of the dimension line, in degrees (the Rotated option). |
dim_text | string | null | No | The dimension text (<> is the measurement; without it, the measurement). |
first_origin | array<number> | Yes | The first extension line origin [x, y]. |
orientation | Orientation | null | No | The orientation: on a linear dimension, horizontal or vertical (in the current UCS); on a sheet, portrait or landscape. |
second_origin | array<number> | Yes | The second extension line origin [x, y]. |
text_angle | number | null | No | The angle of the dimension text, in degrees. |
Errors
| Code | JSON-RPC | Meaning |
|---|---|---|
invalid_params | -32602 | The parameters do not follow the schema or a rule of the operation. |
not_found | -32001 | The object, operation, file or name does not exist. |
conflict | -32004 | The current state does not allow this now. |
failed | -32005 | The operation failed. |
Example
MCP
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"arguments": {
"dim_line_point": [
5,
-2
],
"first_origin": [
0,
0
],
"second_origin": [
10,
0
]
},
"operation": "cad.annotate.dim_linear"
},
"name": "badbit_call_operation"
}
}Python
import badbit
result = badbit.cad.annotate.dim_linear(dim_line_point=[5, -2], first_origin=[0, 0], second_origin=[10, 0])LISP
(badbit-call "cad.annotate.dim_linear" '(("dim_line_point" . (5 -2)) ("first_origin" . (0 0)) ("second_origin" . (10 0))))JSON-RPC
{
"id": 1,
"jsonrpc": "2.0",
"method": "badbit/call",
"params": {
"arguments": {
"dim_line_point": [
5,
-2
],
"first_origin": [
0,
0
],
"second_origin": [
10,
0
]
},
"operation": "cad.annotate.dim_linear"
}
}Commands that do the same
Full schema
JSON Schema 2020-12.
Parameters (input)
{
"$defs": {
"Orientation": {
"oneOf": [
{
"const": "horizontal",
"type": "string"
},
{
"const": "vertical",
"type": "string"
}
]
}
},
"$schema": "https://json-schema.org/draft/2020-12/schema",
"additionalProperties": false,
"properties": {
"dim_line_point": {
"description": "A point [x, y] the dimension line (or arc) passes through; in radial and ordinate dimensions, where the text goes.",
"items": {
"format": "double",
"type": "number"
},
"maxItems": 2,
"minItems": 2,
"type": "array"
},
"dim_rotation": {
"default": null,
"description": "The rotation of the dimension line, in degrees (the Rotated option).",
"format": "double",
"type": [
"number",
"null"
]
},
"dim_text": {
"default": null,
"description": "The dimension text (<> is the measurement; without it, the measurement).",
"maxLength": 10000,
"type": [
"string",
"null"
]
},
"first_origin": {
"description": "The first extension line origin [x, y].",
"items": {
"format": "double",
"type": "number"
},
"maxItems": 2,
"minItems": 2,
"type": "array"
},
"orientation": {
"anyOf": [
{
"$ref": "#/$defs/Orientation"
},
{
"type": "null"
}
],
"description": "The orientation: on a linear dimension, horizontal or vertical (in the current UCS); on a sheet, portrait or landscape."
},
"second_origin": {
"description": "The second extension line origin [x, y].",
"items": {
"format": "double",
"type": "number"
},
"maxItems": 2,
"minItems": 2,
"type": "array"
},
"text_angle": {
"default": null,
"description": "The angle of the dimension text, in degrees.",
"format": "double",
"type": [
"number",
"null"
]
}
},
"required": [
"first_origin",
"second_origin",
"dim_line_point"
],
"type": "object"
}Result (output)
{
"$defs": {
"DimLinkOut": {
"properties": {
"definition_point": {
"description": "The linked definition point (the index in definition_points).",
"format": "uint",
"minimum": 0,
"type": "integer"
},
"link_type": {
"description": "Where the point is on the object: endpoint, midpoint, center, quadrant, node, insertion, on_curve, intersection, lines_meet or nearest (any point on the object, from the Nearest snap, which follows the object in the same proportion).",
"type": "string"
},
"object_ids": {
"description": "The objects the point is linked to (at an intersection, both).",
"items": {
"type": "string"
},
"type": "array"
}
},
"required": [
"definition_point",
"object_ids",
"link_type"
],
"type": "object"
}
},
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": {
"dim_texts": {
"description": "The text each dimension shows.",
"items": {
"type": "string"
},
"type": "array"
},
"ids": {
"description": "Object identifiers (32 hexadecimal digits each).",
"items": {
"type": "string"
},
"type": "array"
},
"links": {
"description": "The definition points linked to objects (DIMASSOC 2): when the object changes, the dimension follows. Empty: the dimension is not associative.",
"items": {
"items": {
"$ref": "#/$defs/DimLinkOut"
},
"type": "array"
},
"type": "array"
}
},
"required": [
"ids",
"dim_texts",
"links"
],
"type": "object"
}