Exporting Multiple Meshes to one STL...

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
zardozer
Posts: 24
Joined: Sat Nov 07, 2020 2:35 am

Re: Exporting Multiple Meshes to one STL...

Postby zardozer » Sat Nov 21, 2020 1:25 am

TedM wrote:
Sat Nov 21, 2020 12:55 am
This is odd. I have no problems exporting multiple objects in a single STL file and Cura opens it and shows the objects spaced as I had them in FreeCAD. I've actually been doing this for quite a while. I simply select the objects and then do File->Export as an STL file.
I think OP wanted to have them recognized as separate meshes if they were to be imported into another program. As far as Cura (or any slicer for that matter) is concerned, if you have two meshes that are separate in space but from one stl, it still considers them one "object." As to WHY the OP really needs this, I have no idea. Maybe he wants two objects to be exactly X spaced apart when when imported into the slicer, but he still needs them to be recognized as two separate objects? I don't know.
jeno
Posts: 868
Joined: Sun Jun 29, 2014 10:41 am

Re: Exporting Multiple Meshes to one STL...

Postby jeno » Sat Nov 21, 2020 6:56 am

zardozer wrote:
Sat Nov 21, 2020 1:25 am
TedM wrote:
Sat Nov 21, 2020 12:55 am
This is odd. I have no problems exporting multiple objects in a single STL file and Cura opens it and shows the objects spaced as I had them in FreeCAD. I've actually been doing this for quite a while. I simply select the objects and then do File->Export as an STL file.
I think OP wanted to have them recognized as separate meshes if they were to be imported into another program. As far as Cura (or any slicer for that matter) is concerned, if you have two meshes that are separate in space but from one stl, it still considers them one "object." As to WHY the OP really needs this, I have no idea. Maybe he wants two objects to be exactly X spaced apart when when imported into the slicer, but he still needs them to be recognized as two separate objects? I don't know.
Maybe he wants to assign different materials or colors to the meshes.
wmayer
Site Admin
Posts: 16852
Joined: Thu Feb 19, 2009 10:32 am

Re: Exporting Multiple Meshes to one STL...

Postby wmayer » Sat Nov 21, 2020 10:07 am

Is this a limitation of the STL file format or a limitation of Freecad?
It's a limitation of the file format.
A clever program could import such triangles and separate objects by finding all triangles that are in something I would call the "connectivity hull".
As long as the combined triangles don't form non-manifold surfaces FreeCAD is able to split the single mesh into its components. When you import an STL with several objects and go in the context-menu to "Display components" you can graphically see the different objects. At the moment there is only a way via Python to split a mesh into several components but a GUI command is missing.
This is only partially true. STL-Ascii can describe multiple solids, STL-Binary not. But most programms ignore this. It works like this
I don't know if this is officially supported. At least the article on WP does not mention it that an ASCII STL can have several objects: https://en.wikipedia.org/wiki/STL_(file_format)

The only format I know that intentionally supports several objects is OBJ.
I've just tried exporting as an AST and as a Wavefront Obj file and in both instances, Freecad combined all the meshes into one homogeneous blob...
There are two OBJ exporters. One is from the Mesh module (Alias Mesh) and the other from the Arch module (Wavefront OBJ). You must use the former.
wmayer
Site Admin
Posts: 16852
Joined: Thu Feb 19, 2009 10:32 am

Re: Exporting Multiple Meshes to one STL...

Postby wmayer » Sat Nov 21, 2020 10:48 am

jeno
Posts: 868
Joined: Sun Jun 29, 2014 10:41 am

Re: Exporting Multiple Meshes to one STL...

Postby jeno » Sat Nov 21, 2020 1:24 pm

wmayer wrote:
Sat Nov 21, 2020 10:07 am
...
This is only partially true. STL-Ascii can describe multiple solids, STL-Binary not. But most programms ignore this. It works like this
I don't know if this is officially supported. At least the article on WP does not mention it that an ASCII STL can have several objects: https://en.wikipedia.org/wiki/STL_(file_format)
...
I also did not found a really proof for this. But at least three.js and numpy-stl supports it. Also here a thread in Rhino forum. Solid Edge also seems to deal with it. See note in first paragraph.
Seems not very common but you can find examples here and there. And I have no idea what else could be the reason for these

Code: Select all

solid some_name
...
endsolid
tags in the file

Regards
wmayer
Site Admin
Posts: 16852
Joined: Thu Feb 19, 2009 10:32 am

Re: Exporting Multiple Meshes to one STL...

Postby wmayer » Sat Nov 21, 2020 2:27 pm

Well, it's always a bit problematic to extend the capabilities of a format that isn't (or doesn't seem to be) part of the specification. You can do nice things as long as you only use SW that supports it but as soon as you use other SW that strictly implements the official specification the problems start.

It's very similar to the unofficial extensions of the binary STL where e.g. the 80 bytes long header or the two-byte pad after each triangle is used to save some additional information like colors.