Define Block
block_defineCreate validated AutoCAD block definition with geometry and attribute definitions, preventing malformed specs from writing partial data. Optionally overwrite existing blocks or create missing layers.
Instructions
Create a block definition with attribute definitions from typed specs.
The whole request is validated before anything is written: one malformed
entry refuses the call and leaves no definition behind. Refusals: a
malformed primitive or ATTDEF (names entities[i]/attdefs[i] and the
key), a non-finite base point (names base_x/base_y), a name clash
without overwrite, an anonymous * name, and a primitive layer that
is not in the drawing's layer table (names the missing layers) unless
create_layers=true, which creates them and lists them in
layers_created. overwrite=true replaces the contents of an existing
block so its INSERTs keep pointing at the name and show the new geometry;
replaced reports it. Geometry inside the block is ByBlock so the
INSERT's layer supplies colour and lineweight. Insert with
block_insert(attributes={TAG: value}).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | New block definition name | |
| base_x | No | Block base point X | |
| base_y | No | Block base point Y | |
| attdefs | No | Attribute definitions: {tag, x, y, height, prompt?, default?, rotation_deg?, align?, invisible?} | |
| entities | Yes | Primitives in block-local coordinates. type=line {x1,y1,x2,y2} | circle {cx,cy,r} | arc {cx,cy,r,start_deg,end_deg} | polyline {points,closed,bulges?} | text {text,x,y,height,rotation_deg?,align?} | solid {points (3-4)}. Optional layer (default 0). | |
| overwrite | No | Replace the contents of an existing definition of this name | |
| create_layers | No | Create primitive layers that do not exist yet (default: refuse and name them) |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||