Importing STL file with 4 objects turning into 1

Hi! I have a simple object comprised of four blocks as shown in the CAD below. I'm modeling it as 4 separate objects with different material properties. My problem is that when I import it in matlab using the code below, it turns it into a single object, as shown
Is there a way for the stl file to accurately be imported?
Is there a quick way to edit this object in matlab to mirror the CAD file?
structuralmodel = createpde('structural','modal-solid');
importGeometry(structuralmodel, 'plateproblem2.stl');
figure
pdegplot(structuralmodel,'EdgeLabels','on');
view(100,100)

3 Comments

I think you should import each body separately
Tried, but as expected, assemblies of models aren't currently supported. Thanks anyway
Ammiel Barros, how is it now? multiple bodies cant be assembled into the Matlab PDE Modeler?
Best regards
Bastiaan Pierik

Sign in to comment.

 Accepted Answer

Cris LaPierre
Cris LaPierre on 22 Mar 2021
Edited: Cris LaPierre on 22 Mar 2021
Perhaps the tip on the importGeometry page is applicable here:
The STL format approximates the boundary of a CAD geometry by a collection of triangles, and the importGeometry function reconstructs the faces and edges from this data. Reconstruction from STL data is not precise and can result in a loss of edges and, therefore, the merging of adjacent faces. Typically, lost edges are the edges between two adjacent faces meeting at a small angle, or smooth edges bounding blend surfaces. Usually, the loss of such edges does not affect the analysis workflow.
Can you share your stl? You'll have to either change the extension or zip it first, then attach it using the paperclip icon.

7 Comments

Hi Cris! Thanks for the response. I see what you mean.
"Usually, the loss of such edges does not affect the analysis workflow." - Do you think this is the reason why there's no AddEdge function?
Attached is the stl file. This is generated using export from AutoCAD.
Thanks.
Your issue appears to be with how you have exported your stl. It is a solid body, so you likely lost any internal faces when exported. When I view the slt in an stl viewer, it does not detect any internal faces.
In other words, MATLAB has not removed the faces. AutoCAD did.
I see. Let me see how I can export it properly, and then import it in MATLAB. I'll get back to you afterwards.
Thank you!
Hi Cris, I edited the stl file before importing it. Solved my problem. Appreciate the help.
That's looking more like it.
I have a similar problem I get this error message from matlab
Error using pde.DiscreteGeometry
Failed to create geometry. The stl file is invalid, more than two facets share an edge.
I have created the stl file from FreeCAD of three separate parts that fit together. Stl file of one part works just with more than one part. Can I import a number of parts and join them? Any help much appreciated.
Julian
You will need to combine your stl files in FreeCAD. A quick google search shows there are results for this. I obvioulsy can't comment on if this is a valid solution for you or not, but here's one result that looked promising: https://grabcad.com/tutorials/how-to-combine-stl-files-freecad-combine-stl-files-stl-format-stl-3d-printing

Sign in to comment.

More Answers (0)

Products

Release

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!