Skip to content

ProjectInkfish/Buoyant-Prints

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Buoyant Prints Infill Solver

infill-solver.py solves for Bambu Studio Sparse infill density (%) by re-slicing a configured .3mf and reading predicted mass from G-code metadata.

Use it for neutral/positive/negative buoyancy targets, with optional extra mass and extra displaced volume (for example, line on a finger spool).

How It Works

  • Reads model volume directly from the 3MF mesh (same geometry the slicer uses).
  • Computes target mass: water_density * (volume + extra_volume) - extra_mass and applies optional buoyancy bias.
  • Binary-searches infill density by calling the Bambu Studio CLI and parsing: ; total filament weight [g] : <value>
  • Uses a practical 0.1% infill search resolution.
  • Writes the final infill back into the original .3mf (optional backup flag available).

Requirements

  • Python dependencies: stdlib only (no requirements.txt needed).
  • Docker compose service bambustudio is configured and runs successfully.
  • Wrapper script exists: run-infill-solver.sh.
  • Input .3mf already has print settings finalized except sparse infill density.

Minimal Docker Service

Your docker-compose.yml needs a bambustudio service that can run:

  • Bambu Studio CLI binary (default used by wrapper: /opt/bambustudio/bin/bambu-studio)
  • Python 3
  • Volume mount for this project directory at /data

Quick Start

Run from the host with the wrapper (executes inside the container):

"/media/internal/Development/3D-printing/Buoyant Prints/run-infill-solver.sh" \
  "/media/internal/Development/3D-printing/Buoyant Prints/Finger-Spool.3mf" \
  --water-density 1.0 --buoyancy neutral

Note: --water-density 1.0 overrides the script default (1.025 for salt water).

Extra mass/volume (line on a spool)

"/media/internal/Development/3D-printing/Buoyant Prints/run-infill-solver.sh" \
  "/media/internal/Development/3D-printing/Buoyant Prints/Finger-Spool.3mf" \
  --water-density 1.0 \
  --extra-mass-g 12.4 \
  --extra-volume-cc 9.2

Key Flags

  • --volume-cc: override auto-read 3MF volume
  • --extra-volume-cc: additional displaced volume (cm^3)
  • --extra-mass-g: additional carried mass (g)
  • --water-density: 1.000 for fresh, ~1.025 for salt
  • --tolerance-g: stop when abs(error) <= tolerance (default 0.02 g)
  • --buoyancy: neutral, positive, or negative
  • --bias-g: bias applied for positive/negative buoyancy (default 0.05 g)
  • --backup: writes <model>.3mf.bak before updating the source file
  • --verbose: show Bambu CLI output each iteration
  • --dry-run: print computed target mass and exit (no slicing, no file write)

Example Output

volume from 3MF: 19.0621 cm^3
target mass: 19.0621 g
iter 01: infill= 50.00%  predicted_mass=   20.60 g  target=   19.06 g  err=  +1.54 g
iter 02: infill= 25.00%  predicted_mass=   19.35 g  target=   19.06 g  err=  +0.29 g
iter 03: infill= 12.50%  predicted_mass=   18.72 g  target=   19.06 g  err=  -0.34 g
iter 04: infill= 18.80%  predicted_mass=   19.05 g  target=   19.06 g  err=  -0.01 g

Operational Notes

  • The script updates the source .3mf in place.
  • Use --backup when you want an on-disk rollback point.
  • Close the same project in Bambu Studio while the solver runs to avoid stale UI state.

Known Limitations

  • Uses slicer-predicted mass, not measured print mass; calibration/flow error can shift real results.
  • Assumes monotonic mass vs infill; unusual presets may reduce search quality.
  • 3MF volume extraction is mesh-based and may differ slightly from CAD solid volume.
  • Does not model flooding, trapped-air leaks, deformation, or material water absorption.
  • Multi-plate or process-specific overrides in some projects may still require manual verification in GUI.

About

Create neutrally buoyant 3D prints using BambuStudio CLI

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors