Cheatsheet
Quick lookup for the public SCPF authoring API.
Model classes
class Example: … build(self)
Write a Python model. No main() or show() is required.
class SimpleBox:
def build(self):
return Box(40, 30, 10)Model parameters
Numeric model fields become named SolidCraft parameters.
length = 40.0
Box(self.length, 30, 10)Shapes and sketches
Box(length, width, height, *, anchor=CENTER)
Native Box centred on XYZ by default; choose anchor=BOTTOM for a bottom-face datum at Z=0.
Box(40, 30, 10)Rectangle2D(width, depth)
Planar XY profile authored inside a Sketch.
with Sketch(plane='XY') as sketch:
Rectangle2D(100, 60)Circle2D(d=…)
A round 2D profile authored inside a Sketch.
with Sketch(plane='XY') as sketch:
Circle2D(d=8)Polygon2D(points, plane=…)
A closed profile on XY, XZ or YZ.
Polygon2D([(0,0), (40,0), (0,30)], plane='XZ')Cylinder(d=…, h=…, axis=…, anchor=CENTER)
Native cylinder centred by default; choose an axial anchor such as BOTTOM or LEFT when that end should define the datum.
Cylinder(d=24, h=14, axis=Axis.X, anchor=LEFT)Sphere(radius, *, anchor=CENTER)
Native sphere centred by default; cardinal anchors select tangent datums.
Sphere(12, anchor=LEFT)Sheet metal
Sketch.sheet_metal(…)
Create a new native flat sheet body from one closed Sketch and define its shared material rule.
sheet = sketch.sheet_metal(thickness=2, bend_radius=2, k_factor=0.5)Shape.fold(…)
Fold existing sheet material along one straight line; material values come from the active sheet rule.
sheet = sheet.fold(line=((20,-20,0),(20,20,0)), angle=90, fixed=(-30,0,0))Shape.flange(…)
Grow a native flange from one or more fixed existing-sheet edge picks.
sheet = sheet.flange(edges=[(40,0,2)], height=20, angle=90)Shape.contour_flange(…)
Create a new native sheet body from a finished connected open Sketch chain.
sheet = contour.contour_flange(distance=50, thickness=2.5, bend_radius=2.5)Shape.hem(…)
Fold an existing sheet edge back while inheriting the active material rule.
sheet = sheet.hem(edges=[(40,0,2)], length=12, gap=4)Shape.path_flange(…)
Add a native flange to an existing edge using a finished line-only open Sketch path.
sheet = sheet.path_flange(edge=(40,0,2), path=path, radius=3)Shape.perforate(…)
Apply a native whole-sheet manufacturing perforation field without repeated solid hole cuts.
sheet = sheet.perforate(diameter=5, pitch=10, margin=5, pattern='square')Features and placement
sketch.extrude(distance)
Extrude an explicitly authored Sketch into editable native solid history.
with Sketch(plane='XY') as sketch:
Rectangle2D(80, 50)
plate = sketch.extrude(8)sketch.extrude(…, profiles=[…])
Extrude or cut only the closed Sketch regions selected by fixed sketch-local points.
cut = sketch.extrude(Depth.THROUGH_ALL, profiles=[(-30, 0), (30, 0)], exact_regions=True)Sketch.rectangular_pattern(…)
Repeat a profile or earlier Sketch result as a native rectangular sketch pattern.
row = sketch.rectangular_pattern(seed, count=4, spacing=25, direction=Axis.X)Sketch.mirror(…)
Mirror a profile, pattern result or earlier mirror result over the Sketch X or Y axis.
sketch.mirror(row, axis=Axis.Y)Hole(d=…, depth=…)
A native hole. THROUGH_ALL follows the target body.
Hole(d=8, depth=Depth.THROUGH_ALL)shape.rectangular_pattern(…)
Repeat an already-applied native feature in one or two linear directions.
plate.rectangular_pattern(hole, count=4, spacing=20, direction=Axis.X)shape.circular_pattern(…)
Repeat an already-applied native feature around a fixed axis.
plate.circular_pattern(hole, count=6, axis=Axis.Z)shape.at(target, anchor=…, child=…)
Place a direct CSG shape anchor on another shape anchor; CENTER-to-CENTER is supported first.
Cylinder(d=8, h=50, axis=Axis.X).at(body)shape.on(target, face=…)
Express feature placement with the shared cardinal Faces vocabulary; TOP/BOTTOM placement is currently qualified.
Hole(d=8, depth=Depth.THROUGH_ALL).on(plate, face=Faces.TOP)TOP + LEFT / BOTTOM + RIGHT
Combine cardinal directions to identify one edge of an axis-aligned rectangular solid.
body.fillet(2, edges=[BOTTOM + LEFT, BOTTOM + RIGHT])Box(…).at(…, anchor=…)
Place a native Box by a face, edge or corner anchor without creating a Sketch.
Box(80, 50, 12).at(0, 0, 0, anchor=FRONT + BOTTOM)Edges.from_faces(…)
Select the complete native boundary of one or more cardinal Faces without supplying XYZ edge picks.
body.chamfer(1.5, edges=Edges.from_faces(Faces.FRONT, Faces.BACK))shape.fillet(…)
Round selected edges of a feature-based body.
body.fillet(2, edges=Edges.VERTICAL)shape.chamfer(…)
Bevel selected edges; add distance2 for SolidCraft’s native asymmetric two-distance chamfer.
body.chamfer(0.18, distance2=0.65, edges=Edges.VERTICAL)shape.shell(…)
Create an open-sided shell (supported feature trees only).
Box(80, 50, 30).shell(2, open=Faces.TOP)a + b / a - b / a & b
Join, cut or intersect supported shapes; operation support depends on the shape types.
body + Hole(d=8).at(0, 0, 10)Reusable components
copy(placement=Placement(…))
Create another occurrence of the same component definition at a declared pose.
second = first.copy(placement=Placement(x=40))model.attach(…)
Fix one reusable component to another through explicit attachment references.
right = Block().attach(left, parent=Anchor.RIGHT, child=Anchor.LEFT)attach(offset=(u, v))
Keep an in-plane attachment offset associative; parameter expressions become native planar-joint values.
part.attach(base, parent=Anchor.FRONT_TOP_LEFT, child=mount, offset=(0, -wall + 12))attach(kind=“revolute”, …)
Create a native bounded revolute relationship while reusing the normal attachment-reference model.
moving.attach(fixed, parent="hinge_axis", child="hinge_axis", kind="revolute", value=60, limits=(0, 180), name="Hinge")assembly.with_exploded_view(…)
Store a native automatic or explicit exploded presentation without changing normal occurrence placements.
assembly.with_exploded_view('Service', scale=1.25).show_exploded('Service')assembly.show_assembled()
Return presentation to the normal assembled occurrence placements.
assembly.show_assembled()assembly.with_anchor(…) / anchor(…)
Expose a semantic attachment datum owned by an assembly without adding application-specific anchors to a generic component.
frame = (left + right).with_anchor("front_top_left", left, ref)
parent = frame.anchor("front_top_left")corner anchors
Use one of the eight rectangular corner references when attaching components.
marker = Marker().attach(base, parent=Anchor.FRONT_TOP_RIGHT, child=Anchor.BACK_TOP_RIGHT)AnchorFrame
Define an oriented local attachment frame. Return it from anchors() when the datum belongs to the reusable component, or pass it directly to attach() when it belongs only to the assembly.
mount = AnchorFrame(origin=(0,0,-12), z=(0,1,0), x=(0,0,-1))
part.attach(base, parent=Anchor.FRONT_TOP_LEFT, child=mount)AnchorTopology
Keep a named or assembly-local attachment reference on a planar-face edge or one of its endpoints so SolidCraft can follow changing geometry.
def anchors(self):
return {"mount": AnchorTopology(edge=(0,10,5), on=(0,10,10), corner=(0,0,5))}Placement(rotation=(axis, degrees))
Give a component occurrence one absolute axis-angle orientation.
second = first.copy(placement=Placement(x=40, rotation=(Z, 180)))Drawings
model.with_drawing(…)
Attach a native SolidCraft engineering drawing to the completed design; ISO A4 landscape is the default.
part.with_drawing(name='Sample Plate Drawing')DrawingView(at=…, scale=…, visual_style=…)
Place one native standard view in paper millimetres; ‘shaded’ is the qualified pictorial override while omission keeps the normal line view.
DrawingView(at=(220, 128), scale='1:1', visual_style='shaded')DrawingDimension.faces(…)
Dimension two real planar model faces; prefer this for overall sizes when fillets remove corners.
DrawingDimension.faces('front', (-40,0,4), (40,0,4), direction='horizontal', offset_mm=12)DrawingDimension.linear(…)
Create a native linear dimension between two model-space point/corner picks.
DrawingDimension.linear('front', (0,0,0), (20,0,0), direction='horizontal')DrawingDimension.radial(…)
Create a native radial/diameter dimension from a circular model-edge pick; override_text may form a hole callout.
DrawingDimension.radial('top', (-25.17,2.83,8), diameter=True, override_text='2× {value} THRU')DrawingNote(…)
Add native sheet notes at an explicit paper position.
DrawingNote('NOTES\n1. ALL DIMENSIONS IN MM.', at=(156,88), cap_mm=2.5)DrawingRevision(…)
Add one native revision row and drive matching title-block revision fields.
DrawingRevision(revision='A', description='Initial drawing', designer='Forge', checker='CI')properties=… / title_block=…
Populate native drawing properties and explicit cells in the selected SolidCraft title-block template.
properties={'part_number':'BRK-001'}, title_block={'title':'Bracket','material':'PETG'}template=‘iso-a3-part’
Select native ISO A3 explicitly when the documented part needs more sheet area; Forge keeps it landscape.
part.with_drawing(name='Large part', template='iso-a3-part')Native PDF + PNG + inspect JSON
builder-scpf publishes vector PDF, static native sheet PNG and final native drawing.inspect evidence; Pages loads only the PNG.
drawings/Sample-Plate-Drawing.{pdf,png,json}Compile and inspect
python -m scpf … –out
Compile a model to SolidCraft command JSON; no SolidCraft app needed.
python -m scpf examples/simple-box/scpf/model.py --out output/box.jsonpython -m scpf replay …
Send existing command JSON to an open SolidCraft session; does not recompile.
python -m scpf replay output/box.jsonpython -m scpf … –connect
Execute a model in an open SolidCraft GUI document.
python -m scpf examples/simple-box/scpf/model.py --connectDisplay appearance
shape.with_appearance("#RRGGBB")
Give the finished body a visual color without changing material/BOM semantics.
body.with_appearance("#FFD21A")Configuration tables
Configure(design, active=…, columns=…, rows=…)
Author one editable native SolidCraft configuration table.
Configure(design, active="Medium",
columns=(Param(self.width), Suppress(hole)),
rows={"Medium": ("80 mm", True),
"Large": ("100 mm", False)})Shape.export_feature(…) + Occurrence.feature(…)
Let a parent configuration suppress one exact authored feature inside a reusable child definition.
@component
class Coupler:
def build(self):
body = Box(40, 24, 12, anchor=Anchor.BOTTOM)
cut = Hole(d=5).at(0, 0, 12).export_feature("panel_pin")
return body - cut
coupler = Coupler()
Configure(coupler, active="Small",
columns=(Suppress(coupler.feature("panel_pin")),),
rows={"Small": (True,), "Large": (False,)})ConfigRule(…, condition=Always(), effect=DriveParameter(…))
Keep an Installed/Free physical state independent from Small/Medium/Large rows.
Configure(design, active="Medium",
columns=(Param(self.width), Param(self.fit_diameter)),
rows={"Small": ("60 mm", "20.4 mm"),
"Medium": ("80 mm", "20.4 mm"),
"Large": ("100 mm", "20.4 mm")},
rules=(ConfigRule(
"installed", "Installed",
condition=Always(),
effect=DriveParameter(self.fit_diameter, self.tube_d)),))Symbolic CAD math
cadmath.min / max / sqrt / abs / round / floor / atan
Keep non-linear and quantized derived dimensions native and configuration-driven.
g = cadmath.min(self.rounding, self.wall / 2 - 0.05)
tip = cadmath.sqrt((self.radius - g) ** 2 - (self.radius - self.wall + g) ** 2)Shifted native revolve
AxisLine(direction, origin=…)
Author one shifted/custom native axis with parameter-driven XYZ origin.
axis = AxisLine(Axis.Y, origin=(self.pin_x, 0, self.pin_z))
cut = profile.revolve(axis=axis)