SOLIDWORKS Bridge
Public Made by Adomby adom
Launch, model and quit SOLIDWORKS from any Adom container. Nothing is ever lost.
swx_inspect_bodies reports massKg ~1000x too small
Summary
swx_inspect_bodies reports massKg about 1000× too small. For the same part, swx_mass_properties gives the correct mass.
What I ran
A single-body part with material ABS set via swx_run_script {"op":"set_material","name":"ABS"}, then both read-back verbs on the same document, with no changes in between.
swx_inspect_bodies (excerpt):
"bodies":[{"areaMm2":3776.754,"bbox":{"maxMm":[15.9,1.7,7.9],"minMm":[-15.9,-9.6,-7.9]},"centerOfMassMm":[0.0,-3.407,-0.0],"faceCount":39,"isSolid":true,"massKg":2.0733615208256247e-6,"name":"Boss-Extrude19","sizeMm":{"x":31.8,"y":11.3,"z":15.8},"visible":true,"volumeMm3":2073.362}],"bodyCount":1
swx_mass_properties (excerpt):
"density": 1020.0,
"massKg": 0.0021148287512421367,
"volumeM3": 2.0733615208256243e-6
Expected vs actual
- Expected:
massKg≈ 0.002115 (2073.362 mm³ × 1020 kg/m³). - Actual:
massKg= 2.0733615e-6.
The reported value equals the body's volume in m³ (volumeM3 above) times 1.0. Two likely causes:
- a density read in g/cm³ (or a fallback of 1.0) applied to a volume in m³; or
- the material's density being ignored.
The same thing happened before any material was set: a 4823.424 mm³ block reported massKg 4.823424e-6.
Also noticed (possibly related to ownership tracking)
I created the part with swx_new_document {"type":"part"}; the reply showed scratchFile: true and a path under ...\adom-solidworks-bridge\exports\scratch\. When I then called swx_run_script with that same path, the reply said "bridgeCreatedDocument": false and warned that the document was not bridge-created. The script still ran. I'd expect true for a document the bridge just made.
Environment
- solidworks-bridge 0.9.26
- Adom Bridge 2.1.168
- SOLIDWORKS: COM reports 29.5.1; registry lists SOLIDWORKS 2021
- Windows 11 Pro 10.0.26200