Combining multiple STL files

4

I have a collection of STL files, each containing a separate moving part of an object I want to print. (Imagine a set of gears, or similar, that prints as a single object with multiple moving parts.)

My plan was to import them all into Cura, then hit print, then take my fully assembled object off the build plate. However, Cura ignores the coordinate system in the STL files and automatically separates the components from each other on the build plate. This is usually helpful, but it isn't what I want in this case.

So I'm looking for a quick and simple way to combine my multiple STL files into a single STL file. I know that the objects don't overlap, so I don't need to do a CSG union operation - it's enough just to concatenate the objects.

I tried OpenSCAD, which works, but it takes a really long time, because the meshes are fairly complex and it does the full Boolean operation. Is there another quick and simple way to perform this task?

I'd prefer a command line utility, but I'd also be happy if there's a quick and simple way to do it in some free graphical software. (However, I don't want to spend time manually positioning the objects - they're already in the right places in the STL files, so I just want to import them and go.)

Edit I've accepted Trish's answer (use Blender), but I'd still appreciate a command-line option if anyone knows one.

Nathaniel

Posted 2019-10-13T14:54:44.200

Reputation: 1 449

How would you expect the 3D printer to print the parts movable and at their position at the same time? If they are not placed on the build platform there will be a lot of support needed. – Klaus D. – 2019-10-13T17:45:55.297

@KlausD. they are all in contact with the build platform and none of them have overhangs that would need support. However, they nevertheless interlock with each other in 3D space in such a way that they can't be separated. – Nathaniel – 2019-10-13T17:46:26.347

(If that sounds impossible, imagine that one object is an hourglass and the other is a torus that surrounds it, with only a small gap between the inner surface of the torus and the neck of the egg timer. Both contact the build plate and no overhang is more than 45 degrees, but the hourglass can't be removed from the torus.) – Nathaniel – 2019-10-13T17:50:58.777

@Pᴀᴜʟsᴛᴇʀ2 exactly that. But with the important provision that I know the parts don't overlap, so a Boolean union operation isn't needed. – Nathaniel – 2019-10-13T18:25:01.827

It is funny you ask about this ... Koenigsegg has to 3d print the turbochargers for his ultra-supercars called "One:1". Can it be done, yes. I'd bet it lends back to how it's designed more so than how the print is setup after design.

– Pᴀᴜʟsᴛᴇʀ2 – 2019-10-13T18:30:10.543

@Pᴀᴜʟsᴛᴇʀ2 it's abut how the file is stored. – Trish – 2019-10-13T19:15:22.560

It's trivial to position separate objects in MeshMixer and export the result as a single STL. I think you're trying to force a square solution into a round hole – Carl Witthoft – 2019-10-15T17:42:13.027

@CarlWitthoft the objects are positioned already, just in separate files, and the idea is to not need to reposition them. No square pegs here, just a beautiful round one produced by homegrown C++ code, which needs a little polishing before it will fit. – Nathaniel – 2019-10-15T17:50:33.243

(Well, to the extent that using a C++ library with overly restrictive I/O possibilities is a square solution, I agree that's the case here. Please take that up with the authors of CGAL, not me. It may be a square solution in that respect, but it's the only viable one in my case.) – Nathaniel – 2019-10-15T17:53:47.140

Answers

3

What you try to do is called "Print in Place". However, it is not done by importing several STLs one after another as cura does remove the origin and recenters each imported object upon importing. However, an STL file can contain more than one body.

To generate a PiP model, you need to export your whole project as one STL file containing all the parts and then Cura not only doesn't rip the model apart, it can't do so.

Workaround

If you can't export the whole project in one piece from your design software, you could use a workaround by importing it into a software that can export as one item. Among these is blender, so importing all the parts into blender and then exporting the whole project as one STL is a simple fix. Other options would be TinkerCAD or Fusion360.

The Step by step guide for blender is simple and the general idea of this workflow is the same for other options:

  1. Open blender
  2. New project
  3. delete the cube via entf + enter
  4. Get the files into the workspace via either:
    • Drag & Drop
      1. File > Import > Stl (.stl)
      2. select the file + enter
  5. Possibly reposition the object, till it is in the right position
  6. Repeat 4. to 6. till all parts are imported
  7. File > Export > Stl (.stl) + enter

Trish

Posted 2019-10-13T14:54:44.200

Reputation: 15 633

My issue is that the program I'm using to create the objects is not able to export them as a single file, but only as separate ones. They do indeed need to be in one single STL file, but the question is about how to do that, given that the program will always output them in separate files. – Nathaniel – 2019-10-13T19:16:46.413

Which program? Fusion360 can export a whole project. – Trish – 2019-10-13T19:17:43.387

I wrote the program myself. The C++ library I used does not have the functionality to put more than one object in an STL file. – Nathaniel – 2019-10-13T19:18:06.030

@Nathaniel then you might want to combine via blender by just importing all before exporting. – Trish – 2019-10-13T19:20:05.117

Thanks for the edit. (+1) I'm not a blender user, and it is quite a complicated program - if you have time, step-by-step instructions would be super helpful. – Nathaniel – 2019-10-13T19:20:11.980

@Nathaniel the step by step is simple and added. – Trish – 2019-10-13T19:26:17.423

another option is to import them into Tinkercad, position them, export all in one group. Tinkercad is free and substantially less complex than the magic of Blender – fred_dot_u – 2019-10-13T19:34:53.973

@Trish cool, that worked, thank you. (I didn't need to reposition them, as you said, it respected their positions in the original files.) The only disadvantage is, Blender for some reason uses its own special file dialog, which uses different conventions from my OS and is therefore mildly painful to use. However, I found I could drag to select multiple files, and thus avoid importing them one by one. I'll accept this in a day or two. – Nathaniel – 2019-10-13T19:53:12.043

@Nathaniel Just came back to this question as I was looking for this workflow to link to, thanks for choosing your preferred workflow! – Trish – 2019-12-20T11:40:49.687

5

The operation you want is almost just cat'ing the files together. However you need to remove the 80 byte header from all but the first, and add up the 32-bit triangle count from each file immediately after that. Output should be:

  1. Copy of first 80 bytes of file 1
  2. Sum of int32 from offset 80 of each file.
  3. Bytes 84-end from each file.

See https://en.m.wikipedia.org/wiki/STL_(file_format)

R.. GitHub STOP HELPING ICE

Posted 2019-10-13T14:54:44.200

Reputation: 5 311

2

Similarly to @R..'s answer, you can easily concatenate the contents of each file if you have ASCII .stls.

  1. Make sure the .stls are in ASCII format: Open them in any text editor (like Notepad++). If it's readable, you're fine, proceed to (3)
  2. If not readable, convert them to ASCII .stl format using a converter tool (like this)
  3. Open each ASCII .stl file
  4. Copy together the contents of the files, except for the "solid" and "endsolid" statements where the files meet

towe

Posted 2019-10-13T14:54:44.200

Reputation: 1 059

They're binary unfortunately. I'd have written a Python script to concatenate them otherwise. Sorry to be awkward! – Nathaniel – 2019-10-14T07:39:53.357

1

Import them to Tinkercad and then output your combined file from there. You can go into Tinkercad and on the top right side you will see "import", click that to import your file (you can repeat the process as desired) and it will put the files on the workspace .. on the screen. When you have your workspace all set the way you want select them all the click "export" and it will export all of them to one file for your use.

Nate E.

Posted 2019-10-13T14:54:44.200

Reputation: 11

1Hi Nate and welcome to 3D Printing.SE! Please expand the answer how one would do that, this is too short for an answer. – 0scar – 2019-12-24T08:18:59.817

1My response has been edited per your request. – Nate E. – 2020-01-14T14:41:30.510