Create/Export .stl file from a mesh
84 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Askic V
le 15 Sep 2022
Réponse apportée : Cris LaPierre
le 15 Sep 2022
Hello,
I have created a model and used generateMesh function that created a mesh and stored it to a model object.
smodel = createpde('structural', 'static-solid');
importGeometry(smodel, 'SquareBeam.STL');
msh = generateMesh(smodel, 'GeometricOrder','linear','Hmin',50);
pdemesh(msh);
Now, I'd like to write this structure to a stl file. I have found stlWrite function in the File Exchange but this function takes faces and vertices as input parameters.
https://www.mathworks.com/matlabcentral/fileexchange/20922-stlwrite-write-ascii-or-binary-stl-files
Is there any way I can extract this data from msh object created in the code above?
Thank you.
0 commentaires
Réponse acceptée
Cris LaPierre
le 15 Sep 2022
You can use the stlwrite function that ships with MATLAB. However, you do need to turn your mesh into a triangulation opject first. I'm not sure I found the best way to do this, but my solution is based on this answer:
smodel = createpde('structural', 'static-solid');
importGeometry(smodel, 'SquareBeam.stl');
pdegplot(smodel)
msh = generateMesh(smodel, 'GeometricOrder','linear','Hmin',50);
pdemesh(msh)
% Extract the edge nodes
N = findNodes(msh,"region","Edge",1:smodel.Geometry.NumEdges);
% Convert to alphashape
shp = alphaShape(msh.Nodes(:,N)');
figure
plot(shp)
% Create triangulation
[T, P] = boundaryFacets(shp);
TR = triangulation(T, P);
stlwrite(TR, 'myMesh.stl');
% check result
bmodel = createpde('structural', 'static-solid');
importGeometry(bmodel, 'myMesh.stl');
pdegplot(bmodel)
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Surface and Mesh Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!