Python reference
cadkit is the Python library that ships with Prism. It needs only the standard library. Parameters are written in snake_case and matched to on-screen labels by partial text, so cad.box(width=40) sets Width and cad.flange(bend_radius=3) sets Bend radius (inside). Objects can be passed by name or as the Obj a call returned.
import cadkit as cadEvery function that makes something goes through run(), so anything missing here can still be reached with cad.run("command_name", ...). See the command reference for every command name.
Connection
CadError
class CadErrorThe application refused a request; the message is the one shown in the application.
connect
cad.connect(port=None, token=None)Point cadkit at an application instance. Normally not needed: it finds the running one by itself.
call
cad.call(tool, **args)Call any application tool by name (the same tools the MCP bridge offers) and return its result.
tools
cad.tools()Return the application automation tools and their argument schemas.
Document
Obj
class ObjAn object in the document. Returned by every modeling call; pass it (or its name) to the next one.
| Member | Description |
|---|---|
to_dict(self) | Everything the application reported about this object (bounds, size, volume, faces ...). |
json(self) | |
size | Property. |
bounds | Property. |
refresh(self) | |
rename(self, new_name) | |
delete(self) |
objects
cad.objects()Every object in the document.
get
cad.get(name)Look up one object by name and return it as an Obj.
state
cad.state()The full document state: objects, selection, active command, sketch, camera and status messages.
undo
cad.undo(count=1)Undo the last count steps.
redo
cad.redo(count=1)Redo the last count undone steps.
delete
cad.delete(*objs)Delete the given objects (names or Obj).
select
cad.select(*objs)Replace the selection with the given objects, faces or edges.
save
cad.save(path)Save the document to path (.prism).
view
cad.view(name=None, fit=False)Set the camera to a standard view ("front", "top", "iso" ...); fit=True zooms to everything.
screenshot
cad.screenshot(wait_ms=250)Capture the application window (the application answers with the picture data).
history
with cad.history(label='Script'):Group everything inside the block into one undo step: with cad.history("Make bracket"): ...
show
cad.show(*things)Print objects or results as compact JSON: the most complete thing an agent can read back.
Dialogs
ask
cad.ask(title='Parameters', **defaults)The quick way to ask for numbers and options. The kind of field follows the default you give: cad.ask("Plate", width=60, depth=40, name="Plate 1", rounded=True, material=["Steel", "Aluminum"]). Returns a dict of the answers (numbers keep int or float as given), or None if cancelled.
dialog
cad.dialog(title, fields)Show a dialog and wait for OK. fields are dicts: {"key", "label", "type": "number|text|check|choice", "value", ...}. Returns {key: value} or None if the user cancelled.
Any command
run
cad.run(command, slots=None, preview=False, points=None, **params)Run any modeling command: run("fillet", slots={"Edges": [...]}, radius=2). Returns the new Obj list.
commands
cad.commands(query='')Names run() accepts, optionally those containing query.
describe
cad.describe(command)The slots (what to select) and parameters (name, type, default, range, options) of a command, as JSON.
help
cad.help(query='')Search the commands and the cadkit functions for query and print a short answer.
Find and check geometry
faces
cad.faces(obj, **filters)Find faces by geometry instead of index: faces(b, type="Plane", facing=(0, 0, 1)). Returns the tool's JSON (indices are 1-based, ready for fillet/chamfer/shell/hole slots). See help("solid_find") for every filter.
edges
cad.edges(obj, **filters)Find edges by geometry: edges(b, direction=(0, 0, 1), min_size=10). Same filters as faces().
check
cad.check(obj, other=None, **kw)Verify a body (validity, volume, closed, thin walls ...), or measure between obj and other. Returns JSON.
Sketches
sketch
cad.sketch(plane='XY', offset=0)Start a sketch on 'XY', 'XZ', 'YZ', a construction plane's name, or a face {"object": "Box 1", "face": 6}.
Primitives
box
cad.box(width=20, depth=20, height=20, **p)Create a box and return it. Extra keyword arguments set other Box settings, such as position_x.
cylinder
cad.cylinder(radius=10, height=20, **p)Create a cylinder and return it.
sphere
cad.sphere(radius=10, **p)Create a sphere and return it.
cone
cad.cone(radius=10, height=20, **p)Create a cone and return it.
torus
cad.torus(major_radius=20, minor_radius=5, **p)Create a torus and return it.
Features
extrude
cad.extrude(profile, distance=20, extent=None, operation=None, **p)Extrude a sketch or face. extent can be "Two sides", "Symmetric", "To object", "Through all" ...; operation "Cut" etc.
revolve
cad.revolve(profile, angle=360, axis='World Z', **p)Revolve a sketch or face about an axis ("World Z" by default).
sweep
cad.sweep(profile, path, **p)Sweep a profile along a path.
loft
cad.loft(sections, rails=None, **p)Loft through ordered sections, optionally along guide rails.
fillet
cad.fillet(edges, radius=2)edges as in {"object": "Box 1", "edge": 3} or a list of them (edge numbers start at 1).
chamfer
cad.chamfer(edges, distance=1.5)Chamfer edges by distance. Edges are given like fillet().
shell
cad.shell(faces, thickness=2, **p)Hollow a solid, removing faces, with the given wall thickness.
holes
cad.holes(target, points, diameter=6, depth=None, **params)Drill holes at world coordinates. target is a body (holes enter from the top, along world Z, by default) or a face; points is a list of (x, y) or (x, y, z). Through all unless depth is given. Returns the body after the last hole. Other command parameters pass through, e.g. direction="World X", hole_type="Threaded (modeled)", metric_size="M6".
rib
cad.rib(sketch, thickness=2, height=10, **p)Add a rib from a sketched line or open profile to the body it touches.
thicken
cad.thicken(surface, thickness=3, **p)Give a surface a thickness to make a solid.
split_body
cad.split_body(body, tool)Split a body with a plane, face, surface or another solid.
Combine and transform
union
cad.union(body, *tools)Join tools into body.
subtract
cad.subtract(body, *tools)Cut tools out of body.
intersect
cad.intersect(body, *tools)Keep only where body and tools overlap.
move
cad.move(objs, x=0, y=0, z=0)Move objects by x, y, z millimetres.
rotate
cad.rotate(objs, angle, axis='Z')Rotate objects by angle degrees about a world axis.
scale
cad.scale(objs, factor)Scale objects by factor.
mirror
cad.mirror(objs, plane='XY')Mirror objects across a world plane ("XY", "XZ" or "YZ").
linear_pattern
cad.linear_pattern(objects, count=4, spacing=20, direction='X axis', count2=1, spacing2=20, direction2='Y axis', **p)Copy objects along one or two directions. Directions are "X axis", "Y axis" or "Z axis". Returns the new objects.
circular_pattern
cad.circular_pattern(objects, count=6, angle=360, axis='Z axis', **p)Copy objects around an axis through the world origin (axis_passes_through="Center of the objects" to use their centre). result="Join into a body" or "Cut from a body" fuses or cuts the copies instead of leaving new bodies.
Direct edits
push_pull
cad.push_pull(faces, distance=10)Move planar faces along their normal: positive pulls out, negative pushes in.
move_face
cad.move_face(faces, x=0, y=0, z=0, tilt=0)Move faces by x, y, z and optionally tilt them; the body follows.
delete_face
cad.delete_face(faces)Remove faces (a hole, fillet or pocket) and heal the body.
Sheet metal, layouts and drawings
flange
cad.flange(profile, thickness=2, bend_radius=2, width=30, **p)Bent sheet metal from a sketch of the cross-section (straight lines, sharp corners).
flat_pattern
cad.flat_pattern(body, k_factor=0.44)Unfold a sheet metal body into its flat pattern.
flatten
cad.flatten(source, **params)Create a persistent flat layout. Select it later with refold() to return.
refold
cad.refold(pattern, geometry=None, target=None, **params)Refold a saved layout; optionally wrap curves, sheets or solids onto it.
wrap
cad.wrap(geometry, reference, target, **params)Map geometry between a planar reference and a surface, or between curves.
U/V/normal scales and offsets, mirror_u, swap_uv, flip_normal, keep_input_geometry and curve_tolerance are accepted keyword arguments.
drawing
cad.drawing(path, **options)Write an engineering drawing (.svg, .pdf or .dxf); see the drawing_export tool for the options.
image
cad.image(path, on='Front plane (XZ)', width=200, opacity=60, **p)Put a picture on a plane as a reference. on is "Front plane (XZ)", "Top plane (XY)" or "Right plane (YZ)".
edit_image
cad.edit_image(img, **p)Change a picture: opacity, width, turn, move_right, move_up, mirror_left_to_right ...
Freeform
form_box
cad.form_box(**params)Create an editable subdivision box; accepts width, depth, height, faces_x/y/z.
form_cylinder
cad.form_cylinder(**params)Create an editable cylinder cage; accepts radius, height, sides, rings, caps.
form_loft
cad.form_loft(sections, **params)Loft an editable cage through ordered curve/sketch sections.
form_pipe
cad.form_pipe(path, **params)Build an editable round tube along a curve/edge.
form_info
cad.form_info(obj, summary=False, only=None)Read a cage and its topology diagnostics; component indices are zero-based.
form_op
cad.form_op(obj, op, **options)Undoable cage edit: e.g. bridge, set_vertices, inset, crease, move or insert_loop.
form_to_nurbs
cad.form_to_nurbs(obj)Convert a cage to NURBS in place; save the editable form first if needed.
Manufacturing
cam_setup
cad.cam_setup(body, name='Setup 1', **p)Stock, work zero and default tool for machining a body: stock_allowance_xy, top_allowance, tool_diameter, cutting_feed ...
cnc_profile
cad.cnc_profile(outlines, depth=None, **p)Cut along outlines. depth = total cutting depth; also tool_diameter, cutting_feed, depth_per_pass, cut="..."
cnc_pocket
cad.cnc_pocket(outlines, depth=None, **p)Clear the inside of closed outlines to depth, leaving islands.
cnc_adaptive
cad.cnc_adaptive(outlines, depth=None, **p)Pocket with even tool load (faster, deeper).
cnc_drill
cad.cnc_drill(holes, depth=None, **p)Drill the picked holes to depth.
cnc_face
cad.cnc_face(depth=None, **p)Face the stock top.
cnc_rough
cad.cnc_rough(model, depth=None, **p)Layered 3D roughing of setup stock with a flat end mill and finishing allowance.
cnc_finish
cad.cnc_finish(model, depth=None, **p)3D parallel finishing over a model (cutter="Ball nose" by default).
cnc_post
cad.cnc_post(machine='GRBL', save_to='', **p)Write G-code for the toolpaths in the document. machine: "GRBL", "Mach3" or "LinuxCNC".
cnc_design_check
cad.cnc_design_check(model, **p)Screen top-down access, reach and wall thickness.
cnc_stock_review
cad.cnc_stock_review(model, **p)Sample visible milling paths in the active setup and program order.
fdm_check
cad.fdm_check(model, **p)Screen a CAD body or mesh for bed fit, nozzle walls and overhangs.
resin_check
cad.resin_check(model, **p)Sample resin cavities, potential cups, islands and thin features; sampling_size sets grid resolution.
print_export
cad.print_export(folder, name='part', format='3MF', open_in='Save only', **p)Write the model for a slicer. format: "3MF", "STL", "OBJ" or "PLY"; open_in: "Bambu Studio", "OrcaSlicer", "PrusaSlicer" or "Save only". Same file name each time, so the slicer can reload from disk.
resin_export
cad.resin_export(folder, name='part', format='3MF', open_in='Save only', **p)Export for an external resin slicer; supports/exposure are configured there.
Other
run_report
cad.run_report(command, slots=None, preview=False, points=None, **params)Run a command with the same arguments as run(), returning the full command or preview report.
fold
cad.fold(sketch, thickness=2, bend_radius=2, angle=90, **p)Fold a flat sketch into sheet metal and return the folded solid. The sketch holds the outline (normal lines, holes as loops) and each bend as a construction line across it. angle is in degrees. angle_of_each_bend="90, -90" and radius_of_each_bend="3, 80" set signed angles and inside radii bend by bend. The flat pattern is also made beside the part; pass also_make_the_flat_pattern_beside_the_part=False to skip it. fixed_region="The region over the sketch origin" holds that region still instead of the largest.
edge_flange
cad.edge_flange(face, length=20, angle=90, bend_radius=2, **p)Add a flange along the edge of a sheet-metal body. face is the thin end face of the sheet as {"object": "Plate 1", "face": 3}. fold_toward="Down (the lower face)" folds the flange the other way.