yonta.new_document(name?, body?)
Command: app.new_document · New document
Create a new document and make it active.
Example
doc = yonta.new_document("Bracket")Everything the UI does, a script can do. This list is generated from the application's command catalog, so it is the same list the command palette uses.
Import yonta from the Python console inside the application or from a standalone script. Every command is one undo step and is recorded by the macro recorder as the Python call shown here.
A parameter marked ? is optional. Methods on Document and Sketch are called on an object, so their document parameter is implied. The same list as JSON: commands.json.
import yonta
doc = yonta.new_document("Bracket")
sketch = doc.new_sketch(plane="XY", name="Body")
sketch.add_circle((0, 0), 20.0)
body = doc.pad(sketch, 10.0)
doc.recompute()
doc.export("bracket.step")
doc.save("bracket.yonta")
yonta.new_document(name?, body?)Command: app.new_document · New document
Create a new document and make it active.
Example
doc = yonta.new_document("Bracket")yonta.open_document(path, name?, background?, copy?)Command: app.open_document · Open document
Open a .yonta file as a new document.
Example
doc = yonta.open_document("bracket.yonta")yonta.close_document(document?)Command: app.close_document · Close document
Close a document without saving.
Example
yonta.close_document(doc)yonta.set_active_document(document)Command: app.set_active_document · Switch document
Make an open document the active one.
Example
yonta.set_active_document(doc)Document.add_object(document?, type, name?)Command: doc.add_object · Add object
Add an object of a registered type.
Example
sketch = doc.add_object("yonta.sketch.sketch")Document.remove_object(document?, object)Command: doc.remove_object · Remove object
Remove an object.
Example
doc.remove_object(body)Document.set_visible(document?, objects, visible)Command: doc.set_visible · Set visible
Show or hide objects in the 3D view: one undo step, saved with the document, no recompute.
Example
doc.set_visible([body], False)Document.set_suppressed(document?, objects, suppressed?)Command: doc.set_suppressed · Suppress
Suppress objects: they are not computed, each passing its base's solid through; or bring them back.
Example
doc.set_suppressed([body])Document.rollback(document?, object?)Command: doc.set_rollback · Rollback
Roll the model back to an object, or forward to the end: what follows is not computed.
Example
doc.rollback()Document.move_object(document?, object, before?)Command: doc.move_object · Move in tree
Move an object to another place in the model tree; a feature takes its new place in the solid chain.
Example
doc.move_object(body)Document.rename(document?, object, name)Command: doc.rename · Rename
Give an object another name; links to it keep working.
Example
doc.rename(body, "Base")Document.set_label(document?, object, label)Command: doc.set_label · Set label
Set the name the window shows for an object; its name in Python and the file stays.
Example
doc.set_label(body, "Base plate")Document.set_property(document?, object, property, value)Command: doc.set_property · Set property
Set a property of an object.
Example
doc.set_property(body, "Length", 10.0)Document.add_parameter(document?, name, expression, quantity?, group?, minimum?, maximum?, comment?, before?)Command: doc.add_parameter · Add parameter
Add a parameter to the document's table; the first one makes the table.
Example
doc.add_parameter("Body", expression)Document.set_parameter(document?, name, expression)Command: doc.set_parameter · Set parameter
Give a parameter another expression; what reads it follows in the same step.
Example
doc.set_parameter("Body", expression)Document.edit_parameter(document?, name, quantity?, group?, minimum?, maximum?, comment?)Command: doc.edit_parameter · Edit parameter
Change a parameter's kind, group, limits or comment.
Example
doc.edit_parameter("Body")Document.move_parameter(document?, name, before?)Command: doc.move_parameter · Move parameter
Move a parameter to another place in the table.
Example
doc.move_parameter("Body")Document.rename_parameter(document?, old, new)Command: doc.rename_parameter · Rename parameter
Give a parameter another name; every expression that uses it is written anew.
Example
doc.rename_parameter(old, new)Document.remove_parameter(document?, name, keep_values?)Command: doc.remove_parameter · Delete parameter
Remove a parameter that nothing uses, or turn what uses it into values.
Example
doc.remove_parameter("Body")Document.set_expression(document?, object, property, expression)Command: doc.set_expression · Set expression
Give a numeric property of an object an expression.
Example
doc.set_expression(body, "Length", expression)Document.clear_expression(document?, object, property)Command: doc.clear_expression · Clear expression
Take a property's expression away; its last value stays.
Example
doc.clear_expression(body, "Length")Document.recompute(document?, background?)Command: doc.recompute · Recompute
Recompute a document.
Example
doc.recompute()Document.undo(document?)Command: doc.undo · Undo
Undo the last change of a document.
Example
doc.undo()Document.redo(document?)Command: doc.redo · Redo
Redo the last undone change of a document.
Example
doc.redo()Document.save(document?, path?, rename?, force?)Command: doc.save · Save
Save a document to a .yonta file.
Example
doc.save("bracket.yonta")Document.export(document?, path, objects?, schema?, stl_format?, unit?, resolution?, y_up?)Command: doc.export · Export
Export solids to STEP or STL.
Example
doc.export("bracket.step")Document.import_step(document?, path, name?)Command: doc.import_step · Import STEP
Import a STEP file: one solid object per root or leaf instance.
Example
imported = doc.import_step("housing.step")Document.copy_sketch(document?, sketch, plane?, source?, name?)Command: doc.copy_sketch · Copy sketch
Copy a sketch, with every constraint, onto a base plane, from this document or another.
Example
doc.copy_sketch(sketch)Document.new_sketch(document?, plane?, support?, face?, name?)Command: part.new_sketch · New sketch
Add a sketch on a base plane or a planar face.
Example
sketch = doc.new_sketch(plane="XY", name="Body")Document.pad(document?, profile?, length?, name?, through_all?, reversed?, symmetric?, side?, second_length?, extent?, up_to?, up_to_element?, offset?, profile_edge?, new_body?, support?, face?, thin?)Command: part.pad · Pad
Extrude a closed sketch into a solid, joined to the tip solid.
Example
body = doc.pad(sketch, 10.0)Document.pocket(document?, profile?, length?, name?, through_all?, reversed?, symmetric?, side?, second_length?, extent?, up_to?, up_to_element?, offset?, profile_edge?, support?, face?)Command: part.pocket · Pocket
Cut a closed sketch into the tip solid.
Example
body = doc.pocket(sketch, 5.0)Document.revolve(document?, profile, angle?, axis?, name?, new_body?)Command: part.revolve · Revolve
Revolve a closed sketch about an axis, joined to the tip solid.
Example
body = doc.revolve(sketch, 2 * math.pi)Document.groove(document?, profile, angle?, axis?, name?)Command: part.groove · Groove
Revolve a closed sketch about an axis and cut it from the tip solid.
Example
body = doc.groove(sketch, math.pi / 2)Document.fillet(document?, edges, radius?, base?, name?, sizes?, chains?)Command: part.fillet · Fillet
Round edges of the tip solid with a radius.
Example
body = doc.fillet([edge], 1.0)Document.chamfer(document?, edges, size?, base?, name?, sizes?, chains?)Command: part.chamfer · Chamfer
Bevel edges of the tip solid by a distance.
Example
body = doc.chamfer([edge], 0.5)Document.shell(document?, faces, thickness?, outward?, join?, base?, name?)Command: part.shell · Shell
Hollow the tip solid to a wall, open at the chosen faces.
Example
doc.shell([face], thickness=4.0)Document.draft(document?, faces, angle?, neutral, neutral_element?, pull?, pull_element?, reversed?, base?, name?)Command: part.draft · Draft
Tilt faces of the tip solid about a neutral plane, as a moulded part needs.
Example
body = doc.draft([face], math.radians(2.0), neutral=(body, bottom))Document.primitive(document?, kind, length?, width?, height?, radius?, radius2?, plane?, support?, face?, origin?, new_body?, name?)Command: part.primitive · Primitive
Add a box, cylinder, sphere or cone as a solid.
Example
box = doc.primitive("box", length=40.0, width=20.0, height=10.0)Document.loft(document?, profiles, profile_edges?, ruled?, closed?, new_body?, name?)Command: part.loft · Loft
Build a solid through profiles in order.
Example
doc.loft([sketch, upper])Document.sweep(document?, profile, path, path_edges?, frame?, transition?, profile_edge?, new_body?, name?)Command: part.sweep · Sweep
Sweep a profile along a path into a solid.
Example
body = doc.sweep(profile, path)Document.mirror(document?, plane?, support?, face?, base?, name?, features?, new_body?)Command: part.mirror · Mirror
Join the tip solid with its reflection in a plane or a planar face.
Example
body = doc.mirror(plane="YZ")Document.pattern_linear(document?, features, direction?, count?, spacing?, direction2?, count2?, spacing2?, length?, offset?, end_offset?, symmetric?, reversed?, skip?, base?, name?)Command: part.pattern_linear · Linear pattern
Copy features' tools along a direction: the count includes the original.
Example
row = doc.pattern_linear([hole], direction="X", count=4, spacing=15.0)Document.pattern_circular(document?, features, axis?, count?, angle?, offset?, end_offset?, symmetric?, reversed?, skip?, base?, name?)Command: part.pattern_circular · Polar pattern
Copy features' tools round an axis: the count includes the original.
Example
ring = doc.pattern_circular([hole], axis="Z", count=6, angle=math.radians(60.0))Document.body(document?, name?)Command: part.body · New body
Add an empty body: the next feature with no base joins it.
Example
doc.body()Document.set_material(document?, objects, material?, density?)Command: part.set_material · Material
Set the material of a body's solid (a feature's is its body's): a table material or a custom density; its mass follows.
Example
doc.set_material([body])Document.section_plane(document?, plane?, support?, face?, flip?, offset?, name?)Command: part.section_plane · Section plane
Add the document's section plane on XY, XZ or YZ or on a planar face: the side its normal points to is cut away in the view; no solid changes.
Example
doc.section_plane()Document.boolean(document?, tools, operation?, base?, name?)Command: part.boolean · Boolean
Fuse, cut or intersect other bodies into a body.
Example
doc.boolean("Body001")Document.hole(document?, profile, diameter?, depth?, through_all?, reversed?, base?, name?, type?, standard?, size?, fit?, series?, thread_length?, left_hand?, counterbore?, countersink?, tip?, tip_angle?, depth_to?, end?, support?, up_to_face?, offset?, far_counterbore?)Command: part.hole · Hole
Drill plain holes at a sketch's points and circle centres into the tip solid.
Example
body = doc.hole(sketch, 3.0, 5.0)Document.datum_plane(document?, plane?, support?, face?, offset?, name?, method?, references?, angle?)Command: part.datum_plane · Datum plane
A reference plane on a base plane or a planar face, moved by an offset.
Example
plane = doc.datum_plane(plane="XY", offset=10.0)Document.datum_axis(document?, axis?, support?, edge?, offset?, name?)Command: part.datum_axis · Datum axis
A reference axis along X, Y or Z, or on a straight edge, moved by an offset.
Example
doc.datum_axis()Document.datum_point(document?, support?, vertex?, offset?, name?)Command: part.datum_point · Datum point
A reference point at the origin or a vertex, moved by an offset.
Example
doc.datum_point()Sketch.add_line(document?, sketch, kind, coords, construction?)Command: sketch.add_geometry · Add sketch element
Add a point, line, circle or arc to a sketch.
Example
line = sketch.add_line((0, 0), (10, 0))Sketch.copy(document?, sketch, geometry, offset?, angle?, center?)Command: sketch.copy_geometry · Copy sketch elements
Copy sketch elements moved by an offset or turned about a point, with the constraints among them.
Example
copies = sketch.copy([line], offset=(10.0, 0.0))Sketch.add_external(document?, sketch, object, edge?, edges?)Command: sketch.add_external · Add external geometry
Project an edge of another object into the sketch as fixed construction geometry that follows it.
Example
external = sketch.add_external(body, edge)Sketch.add_constraint(document?, sketch, type, first, second?, value?, value2?, third?, inner?, driving?, expression?)Command: sketch.add_constraint · Constraint
Add a sketch constraint.
Example
sketch.add_constraint("coincident", (line, "end"), (other, "start"))Sketch.set_value(document?, sketch, constraint, value)Command: sketch.set_value · Change dimension
Change a sketch dimension.
Example
sketch.set_value(constraint, 10.0)Sketch.set_label(document?, sketch, constraint, offset?)Command: sketch.set_label · Move dimension label
Place a dimension's label away from its default place; dragging a label does this.
Example
sketch.set_label(constraint)Sketch.set_expression(document?, sketch, constraint, expression)Command: sketch.set_expression · Set dimension expression
Give a driving dimension an expression.
Example
sketch.set_expression(constraint, expression)Sketch.clear_expression(document?, sketch, constraint)Command: sketch.clear_expression · Clear dimension expression
Take a dimension's expression away; its last value stays.
Example
sketch.clear_expression(constraint)Sketch.set_driving(document?, sketch, constraint, driving)Command: sketch.set_driving · Reference dimension
Make a dimension a reference dimension, which measures and is never solved for, or a driving one again.
Example
sketch.set_driving(constraint, False)Sketch.move(document?, sketch, ref, to, grab?)Command: sketch.move · Drag
Drag a point or an element within its constraints; no constraint is added or removed.
Example
sketch.move((line, "end"), (25.0, 5.0))Sketch.set_construction(document?, sketch, geometry, on)Command: sketch.set_construction · Construction geometry
Make elements construction geometry, which guides and constrains but is never part of a profile, or normal geometry again.
Example
sketch.set_construction([line], True)Sketch.trim(document?, sketch, geometry, at)Command: sketch.trim · Trim
Remove the piece of a line, arc or circle between the curves that cut it.
Example
sketch.trim(line, (16.0, 0.0))Sketch.extend(document?, sketch, geometry, end)Command: sketch.extend · Extend
Lengthen a line or an arc from one end to the next curve ahead.
Example
sketch.extend(line, "end")Sketch.offset(document?, sketch, geometry, distance, constraints?)Command: sketch.offset · Offset
Copy elements a distance away, joined where they meet and tied to their sources.
Example
sketch.offset([line], 2.0)Sketch.fillet(document?, sketch, corner?, geometry?, radius, constraints?)Command: sketch.fillet · Sketch fillet
Round a sketch corner with a tangent arc; the corner's dimensions are kept.
Example
sketch.fillet((line, "end"), 3.0)Sketch.transform(document?, sketch, geometry, offset?, angle?, center?)Command: sketch.transform · Move sketch elements
Move or turn sketch elements themselves, keeping their constraints.
Example
sketch.transform([line], angle=math.radians(90.0))Sketch.mirror(document?, sketch, geometry, axis, constraints?)Command: sketch.mirror · Mirror sketch elements
Copy sketch elements mirrored in a line, with their constraints.
Example
sketch.mirror([line], other.id)Sketch.set_polygon_sides(document?, sketch, geometry, sides)Command: sketch.set_polygon_sides · Polygon sides
Give a polygon another number of sides; its circle and its first side's constraints stay.
Example
sketch.set_polygon_sides(circle, 5)Sketch.remove_geometry(document?, sketch, geometry)Command: sketch.remove_geometry · Remove sketch element
Remove a sketch element and its constraints.
Example
sketch.remove_geometry(line)Sketch.remove_constraint(document?, sketch, constraint)Command: sketch.remove_constraint · Remove constraint
Remove a sketch constraint.
Example
sketch.remove_constraint(constraint)