Open feature request

Modelling DSL: offset/face sketches, cut direction, multi-profile sketches, appearance

Michael · 8d ago
enhancementdslconfirmed

Summary

I modelled a standard LEGO 2x4 brick through swx_run_script as a first real test of the bridge. It worked, and the final geometry was exact, but the DSL's current op set forced a workaround-heavy build: 19 boss extrudes and 3 cuts for a part that takes 4–5 features by hand. The resulting feature tree is hard for a person to edit afterwards.

Requests below are ordered by how much each would have simplified this build.

Requested DSL additions

  1. Sketch on an offset plane or on a face. sketch_rect / sketch_circle only accept Front Plane | Top Plane | Right Plane, and extrudes/cuts always start at the sketch plane. Anything that starts at an offset — studs on top of a block, a pocket in the bottom face — can't be modelled directly. Something like "plane": {"offsetFrom": "Top Plane", "offsetMm": 9.6} or "face": {"atPointMm": [x, y, z]} would cover it.
  2. Cut direction control. cut accepts depthMm and throughAll but no reverse. Measured: a cut from Top Plane always removes material on the −Y side. With the body on the +Y side, a blind cut and throughAll: true both returned feature: null and removed nothing. A reverse flag (as extrude has) or two-direction / midPlane would fix it.
  3. Multiple profiles per sketch. Each sketch_* step creates its own sketch, and extrude uses the last one. Measured: two concentric circles (r 3.255 and r 2.4) followed by extrude produced a solid r 2.4 cylinder, not a ring. A way to add several entities to one sketch (e.g. a sketch op holding a list of rect/circle entities) would allow rings, walls in one feature, and patterns of holes.
  4. Set appearance / colour. There's set_material but no way to set appearance. I wanted "red plastic" on the brick and the only route was swx_run_macro. Something like {"op": "set_appearance", "rgb": [200, 0, 0]} or a named appearance from the library.
  5. Documented coordinate conventions. I worked these out by testing, and they'd be worth stating in opArgs:
    • sketch_rect xMm/yMm is the corner, not the centre.
    • On Top Plane, sketch +Y maps to model −Z.
    • Cuts go along the plane's −normal.

Nice to have later: linear/circular patterns, fillets/chamfers, shell.

How I built it with the current ops

To show what the workarounds look like, the brick's top face was placed on Top Plane and everything was built downward:

  • top plate, 4 walls and 3 tubes as separate extrude {reverse:true} steps;
  • tube bores cut from Top Plane through the full height, then the 3 holes this left in the top plate filled back in with 1.0 mm extrude {reverse:true} circles;
  • 8 studs as separate extrude steps upward.

Result checked with swx_inspect_bodies: one solid body, 31.8 × 15.8 × 11.3 mm, volume 2073.362 mm³, matching a hand calculation of 2073.36 mm³.

Environment

  • solidworks-bridge 0.9.26 (installed via bridge_install from the wiki manifest)
  • Adom Bridge 2.1.168
  • SOLIDWORKS: COM reports 29.5.1; registry lists SOLIDWORKS 2021 (note bridge.json declares solidworks >=2024)
  • Windows 11 Pro 10.0.26200

3 Replies

Drew Owens · 6d ago

Thanks Michael. Everything you listed, including the "nice to have later" items, is built, and it is measured on real SOLIDWORKS 2026: 38 of 38 live checks pass (docs/LIVE-RESULTS.md on the page has every check with expected and measured values), and the current release is 0.10.8.

  1. Sketch on an offset plane or a face. "plane": {"offsetFrom": "Top Plane", "offsetMm": 9.6} (negative offsets too), or "face": {"atPointMm": [x, y, z]}. Faces are found from the geometry, not the view, so a bottom or back face works; an extrude from a face goes outward and a cut inward, as in SOLIDWORKS' own UI.
  2. Direction. extrude and cut take reverse, direction: "both" (depthMm the op's own way, depth2Mm the opposite), midPlane and throughAll. A feature that comes back null is now an error naming the step: your Top Plane cut on a body above the plane now fails loudly instead of returning feature: null with nothing removed.
  3. Several shapes in one sketch. {"op": "sketch", "entities": [{"rect": ...}, {"circle": ...}, {"circle": ...}]} makes one sketch: concentric circles extrude as a ring, disjoint shapes as separate bodies.
  4. Appearance. {"op": "set_appearance", "rgb": [200, 0, 0]} for the whole part, one body, or one face picked by a point; swx_inspect_bodies reports appearanceRgb. A material applied after the colour no longer resets it.
  5. Conventions, documented in the op help and the reference: a rectangle's xMm/yMm is its corner (or anchor: "center" / centerMm); on Top Plane, sketch +Y is model -Z; an extrude goes along the plane's +normal, a cut along its -normal.

Also new, also measured: fillet (every edge of a feature, or edges picked by points), chamfer, shell (faces picked by points, hidden ones included), linear_pattern (either direction) and circular_pattern.

Your brick is the acceptance test. examples/lego-2x4.json builds it in 4 features instead of 22, and live on SOLIDWORKS 2026 it measures 2073.362 mm^3, 31.8 x 11.3 x 15.8 mm, 39 faces, red, 0.0021148 kg in ABS: your 2021 numbers exactly, face count included.

The one thing we can't measure ourselves is your version. If you run the brick script and swx_selftest {"level":"write"} (see your other issue) on 2021 and paste the results here, we'll fix anything they turn up.

Drew

Michael · 6d ago

Thanks Drew, that's a big turnaround. I updated to 0.10.9 and ran examples/lego-2x4.json unchanged on SOLIDWORKS 2021 (COM 29.5.1).

It matches your 2026 numbers:

  • 4 features: Boss-Extrude1, Cut-Extrude1, Boss-Extrude2, Boss-Extrude3.
  • One solid body: 2073.362 mm³, bbox [-15.9, 0, -7.9] → [15.9, 11.3, 7.9], 39 faces.
  • Appearance: appearanceRgb [200, 0, 0].
  • Material: ABS. swx_inspect_bodies gives 1020 kg/m³ and 0.0021148 kg, and swx_mass_properties agrees.

In swx_selftest {"level":"write"}, every modelling check passed on 2021, including T24 (the brick), offset and face sketches, both-direction and mid-plane cuts, rings, appearance, fillet, chamfer, shell and both patterns. The full self-test result, including 6 failures that aren't DSL-related, is on #2.

Two small notes:

  • examples/lego-2x4.json still says "status": "UNMEASURED in SOLIDWORKS — asserted only in the bridge's simulator". It's now measured on 2026 and 2021.
  • The results list T01–T22 and T24–T32. There's no T23, in case that's unintended.
Drew Owens · 1d ago

Thank you, Michael, and sorry for the slow follow-up. Your brick on 2021 matching ours on 2026 to the last face is the confirmation we needed; the modelling layer is the same on both versions.

Both notes are fixed since 0.10.10 (current release 0.11.4, published today): the example's status says measured on 2026 and 2021, credited to you, and T23 is back in the self-test rows. The six non-DSL failures from #2 are one bug, fixed in the same release; details there.

What the script has gained since: lines, arcs, tangent arcs, slots, polygons, construction geometry, sketch fillets and chamfers, revolve and revolve-cut, mirror, counterbored and countersunk holes, up-to-next / up-to-surface / offset-from-surface, and a density override. Each is checked against CSWA exam parts with published masses (tools/cswa/ on the page). That benchmark is now the release gate: 0.11.4 shipped only after all 14 parts passed live on SOLIDWORKS 2026 (twelve within 0.002 % of their keys), and it caught two API facts on the way: SOLIDWORKS drafts the opposite way from what its help says for Ddir1, and "up to surface" is end condition 4, not 10, which silently stops at the next face. If there's a part the script can't build yet, say so here and it goes on the list.

Drew

Log in to reply.