Build regions from a spec
build_regionsBuild region STLs and a problem YAML from a part specification, defining design spaces, fixed regions, loads, keep-out zones, and solid bodies for topology optimization.
Instructions
Build region STLs and a problem YAML from a part spec given as data.
Use it when the user describes a part in words. Define the design space, fixed regions, loads (force vectors in N), keep-out regions (if any) and solid bodies (solid, forced solid).
It already returns check and warnings. Call check_problem only after you edit the YAML, or for your own STLs. Next: state your assumptions, then run_topopt. If the user gave no load (no object, no mass and no force), ask before the run. A guard stop names an override: read the memory estimate against the RAM (a run above it can freeze the machine), raise the guard in the spec or take a larger voxel, and report what, why and the price.
Writes /runs//. Reply keys: resource topopt://replies/build_regions (the meaning of each key). Use yaml_rel with run_topopt. On a wrong spec: {"ok": false, "error": one line that names the key path}. ok is false also when the builder fails (builder_ok false): problems gives the builder errors, and the files stay.
name: folder and file name; default is spec["name"].
spec: a dict (or YAML text) with the schema of the part-to-topopt skill (spec.yaml): regions (design, fixed, load, solid, keep_out; primitives box, cylinder, sphere, capsule, bowl, prism, stl and screw_ring (see find_features), subtract), load_cases, material (E, nu, density or filament), settings (voxel_size may be "auto"; optional min_member_mm, filter_solid_neighbours, stop_rules (as in the YAML: a mapping turns the stop rules on, and time_budget_s, the user's own time budget, ends the run at the first pass after it; enabled: false keeps the rules off; the check warns when the estimate is above the budget) and perimeter_max_mm2: a bound on the surface area of the part in mm2). Units mm, N, MPa. settings.volume_fraction (default 0.25) is the mean density of the FREE design voxels; the fixed, load and solid voxels are solid on top. The YAML keeps your value. A mass in grams that the user asks for goes to settings.target_mass_g in place of volume_fraction (one of the two keys; both is an error): the engine derives the fraction from the grid.
The report and derived.volume give the free and the forced-solid voxels, the target volume in mm3 and the target mass in g (the same numbers as check_problem).
Loads: a force entry can also have moment in N mm and at in mm, and a case can have pressures of {region, value_mpa}.
A fixed_axes mapping (fixed name -> axes) makes a roller of a fixed region.
A springs list of {region, stiffness: [kx, ky, kz]} (N/mm, total; or stiffness_per_area) makes an elastic support on a load region; fixed may then be empty.
A joints list of {region, to: [x, y, z], section: {kind: round, d: ..}} (mm; kinds round, tube, rect, props) bonds the faces of a load region to a rigid body and joins it with a beam to the fixed point to; fixed may then be empty.
A flat face of a region whose plane is not on a voxel face (a voxel belongs to a region when its centre is inside) moves to the nearest voxel face. When such planes change the part, the report has ONE note: line (also in warnings) with the voxel size, the grid origin, an item for each plane (the region, the plane, larger or smaller than your shape) and the options. check.region_planes has all planes, with offsets in mm and voxels, and changes_part (false when the layer is under a region of higher priority or outside the part).
Items in one region join (union).
Optional spec key mirror: a list of up to 3 axis-aligned planes with distinct axes, each {normal: x|y|z, at_mm: }, align: auto|face|centre optional. The tools return facts about it (parity, orphans, load asymmetry).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | No | ||
| spec | Yes |