topology_to_solid
Reconstruct a FreeCAD solid from a topology-optimization density field by thresholding and merging 2D/3D grid cells into extruded boxes.
Instructions
Reconstruct a FreeCAD solid from a topology-optimization density field — the
modeller-side close of the loop opened by topology_optimize_submit, whose
density this consumes. 2-D (nely×nelx grid): thresholds (a cell is solid when
density ≥ threshold), run-length-merges each row into solid spans, tiles each
span as a cell_mm box extruded thickness_mm in Z (row 0 at the top). 3-D (a
nelz×nely×nelx voxel field from the nelz mode): greedy-merges solid voxels into
maximal boxes at (i·cx, j·cy, k·cz) — j=0 at the bottom, thickness_mm ignored.
Fuses into one static Part::Feature. cell_mm is a scalar or [cx, cy(, cz)] mm;
thickness_mm defaults to the smaller cell edge; placement is an optional
[x, y, z] mm origin offset; name names the object. Runs synchronously (it builds
geometry — no jobs.py poll).
Returns {handle, name, volume (mm³), solid_cells, total_cells, mass_fraction (== solid_cells/total_cells — must be ≤ keep_fraction within one cell), n_solids (disjoint bodies; >1 means a split load path), threshold, nelx, nely, nelz (None for 2-D), bbox_mm}. Gate it with mass_properties (mass ≤ keep_fraction·original) and interference_check against keep-out regions, per SIMULATION_EXAMPLES §5.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | No | ||
| cell_mm | No | ||
| density | Yes | ||
| placement | No | ||
| threshold | No | ||
| thickness_mm | No |