Add STL/STEP file to a 3MF from the command line?

I want to use a template and add a STEP file or STL file to create a 3MF file from the command line. Basically

  1. Create an empty 3MF as a template from the BambuStudio GUI
  2. Run a script (Python and the build123d module) to create maybe 20 STEP files
  3. Run a script that runs “BambuStudio” from the command line that create 20 3MF files from the 20 STEP files, with the settings from the template

I have experimented with the --export-3mf flag but it crashes every time I try it, with something like

studio=/Applications/BambuStudio.app/Contents/MacOS/BambuStudio
$studio --debug 5 --outputdir $(pwd)/outdir --export-3mf out.3mf $(pwd)/in.3mf $(pwd)/in.stl

This is using BambuStudio-02.04.00.70 on MacOS 15.7.2

do you want to automate a once-in-lifetime tedious operation? maybe test something like a macro recorder instead? (if you are in Windows, macro recorder jitbit is nice)

I’m from my work life very used to tedious operations working with software, just wondered if someone successfully had automated it :wink:

It would not be a once-in-lifetime operation. The nice thing with creating 3D models using coding is that you can generate lots of variants. In this case it is about armchair leg risers that I want to generate variants fitting different leg dimensions and upload the 3MF file to MakerWorld.

But as this seems to be hard to automate, especially since 3MF is not very standardized between vendors, I will go the manual way, maybe one 3MF with many plates. I can partially automate it, let the script output strings to copy and paste in as plate names.

I so wish that Bambu Lab part of their release process tested the command line usage on all supported platforms. But they likely have more important stuff to test out before release :blush:

in that case I think scad is slightly more appropiate to create variants and export and coding. I would assume nobody has wanted/needed this functionality in bambustudio so it wont ever be added

I have no problem to create the variants if the model itself as I work in build123d. The problem is to export where I set filament type, infill type, infill percentage and other slicer settings. Something I could not find out how to do in build123d or other package or command line tool, especially since it is not well standardized. Making me think that creating a 3MF as a template and just add a STEP or STL to it would be the easiest way.

But maybe I missed that it can be done in OpenSCAD, I will take a look. I have experimented with doing it in Python by unzipping the 3MF (it is basically a ZIP file with files and XML information). Maybe I push forward with that and make the tool myself.

Sorry if I misunderstood your answer. In any case thanks for responding which made me rethink that doing it manually for up to 30 models is not that bad considering I worked as a release engineer all my life and is used to repetitive work when not got time or energy to automate :blush:

If you can’t get the command line to work then the two methods I have got to work are

  1. Use python to modify the 3mf files - to in your case replace the mesh 20 times - its quite tricky though.
  2. On a mac - use keyboard maestro to drive Bambu Studio to run the commands necessary to replace the stl’s - possibly with some direct file renaming. Keyboard automation is tricky with Bambu Studio - so I have found mouse clicks and moves based on found images to be fairly reliable.

I’ve spent quite a lot of time developing both methods - but have ended up using none of this sort of stuff day to day.

Another method might just be to setup 20 plates in one or more files and just use ‘reload from disk’ 20 times which might end up being fairly quick as long as you use the same 20 filenames and locations.

2 Likes

ah yes, if is the automation of that part then is what @Ukdavewood say plus if you need it for windows, my suggestion of “jitbit macro recorder” could work as keyboard maestro