MATLAB: Cannot load simple STL file

error messagePartial Differential Equation Toolboxstl file

Hi,
the STL file (uploaded as txt file) in the attachment, consisting of two juxtaposed cuboids of different size and having in total only 22 surfaces, fails at importGeometry. The geometry is very simple, and there are no tolerance problems to be seen (only coordinates with 120, 100 80 40 and 0 values)!
How to fix it?
Best regards
Urs
Cuboids;
Small Program:
model = createpde('structural','static-solid');
importGeometry(model,'…\cuboids.stl');
generateMesh(model);
figure(1)
pdegplot(model,'FaceLabels','on');
Error message:
Error using pde.DiscreteGeometry
Failed to create geometry, the input does not form a closed volume.
This may be due to missing faces or gaps in the input.
Error in pde.EquationModel/importGeometry (line 60)
gm = pde.DiscreteGeometry(geofilename);
Error in Cuboid (line 14)
importGeometry(model,'….\cuboids.stl');

Best Answer

The issue is the shared wall between your two cuboids. The inner volume must be completely open. This comes up all the time in 3D printing, as STL files are typically the accepted file format for this application. You can google around to find an STL repair service.
If you are creating the geometry yourself, see if you can't remove that shared face yourself.
I ran your stl through a service I've used in the past and found that, once repaired, your code works fine (attached, extension changed to txt)