- Read the STL files to get the nodes and faces.
- Merge the nodes and faces from both geometries.
- Write the combined geometry to a new STL file.
combine two stl into one
62 views (last 30 days)
Show older comments
Alberto Acri
on 22 Jun 2024
Answered: Avni Agrawal
on 28 Jun 2024
I have two 3D geometries ('sol_1.stl' and 'sol_2.stl') and their corresponding nodes and faces.
I would like to combine the two STL geometries into a single geometry, or merge the nodes and faces of the two geometries into one.
- sol_1.st + sol_2.st -> sol_fin.stl
- nodes_sol_1 + nodes_sol_2 -> nodes_sol_fin (simple)
- faces_sol_1 + faces_sol_2 -> faces_sol_fin
0 Comments
Accepted Answer
Avni Agrawal
on 28 Jun 2024
I understand that you are trying to combine two STL geometries into a single geometry by merging their nodes and faces in MATLAB, you can follow these steps:
Below is a MATLAB script that demonstrates how to do this:
% Read the STL files
fv1 = stlread('../sol/sol_1.stl');
fv2 = stlread('../sol/sol_2.stl');
% Extract nodes (vertices) and faces from the first geometry
nodes1 = fv1.Points;
faces1 = fv1.ConnectivityList;
% Extract nodes (vertices) and faces from the second geometry
nodes2 = fv2.Points;
faces2 = fv2.ConnectivityList;
% Merge nodes
% Note: We need to adjust the face indices of the second geometry
% by adding the number of nodes in the first geometry
% Combine nodes
combinedNodes = [nodes1; nodes2];
% Adjust face indices for the second geometry
adjustedFaces2 = faces2 + size(nodes1, 1);
% Combine faces
combinedFaces = [faces1; adjustedFaces2];
% Create a new triangulation object for the combined geometry
combinedGeometry = triangulation(combinedFaces, combinedNodes);
% Write the combined geometry to a new STL file
stlwrite(combinedGeometry, 'combined_geometry.stl');
I hope this helps.
0 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!