When using CreateSTL, ASCII STL files are generated ignoring mesh names and adding the generic “stlmesh” label after the “solid” and “endsolid” keyword:
The name of each mesh could be used to create separate solids, each with the name associated to the corresponding mesh “mesh.name”, or at least the option of customizing the standard name could be provided (there is one for the file name, but the solid name is hardcoded).
Do you think this would be an acceptable change/improvement?
Hi, it will not be enough, because this “hardcoded” name is outside the for loop, it is need to be inside. Even if I put it inside and use mesh names, later when I imported the stl file in a different app or program there was only one object Everything was merged on import even if I didn’t see this option
But maybe I did something wrong
Let’s ping @Pryme8, STLExport creator
Ohh gorsh, I do not remember the specifics of this it was sooooo long ago. Buuuuut, I can take a look here. Ill just have to go re-read the stl specs and make sure this is a things we can do.
Off the top of my head though I dont think mesh names are supported because but I may be wrong. Stl’s are a very very small set of data and I think was only vertices and faces (if I remember right).
@Pryme8 In the STL specification, the keyword “solid” can be followed by a name See: STL (file format) - Wikipedia There can be multiple in the same file to identify parts.
@MarianG the reason why everything is merged into one solid is that there is only one solid/endsolid group that contains all the information.
To separate in multiple parts, each mesh should be mapped to a
solid mesh_name
// other stuff here
endsolid mesh_name
My question was more along the lines of “will I break anything if I make a change like that” and open a PR?
I already did those changes with naming inside loop as I said and there are independent meshes inside stl file if I open it in editor but if you open it in a cad program they are still merged
The exported STL you shared is actually working correctly, with solids split, in paraview and in my application too. I suspect the STL reader of the CAD you used does not consider separate solids from STLs (which would not be the first time for a CAD ).
Paraview shows nine solids, each identified with its own color:
I would say, if mesh names can be assumed to be unique (they should if one wants to be able to retrieve objects by name), then the name should be sufficient.
In the STL specifications, it is acceptable to have the “solid” keyword without name.
If that is OK for you, the code is fine just removing the addition of the random number.