How to export a 3D surface (gyroid) as an stl file

26 次查看(过去 30 天)
Hi,
I'm a final year Mechanical Engineering student and for my final year project I'm studying the deformational behaviour of gyroids under several loading conditions. Currently I have managed to create a the gyroid's surface but I'm struggling to export the surface as an stl file. I've tried using the stlwrite function but it gives an error message saying "Input argument must be a triangulation object". I then tried to triangulate the gyroid surface using several methods but was unsuccessful. Here is the code:
clear all
close all
clc
x_period = 4;
y_period = 4;
z_period = 4;
% Setting meshgrid
[x, y, z] = meshgrid(0:0.1:x_period*pi, 0:0.1:y_period*pi, 0:0.1:z_period*pi)
% Gyroid equation
v = cos(x).*sin(y) + cos(y).*sin(z) + cos(z).*sin(x);
figure(1)
isosurface(x,y,z,v)
axis equal
xlabel ('X')
ylabel ('Y')
zlabel ('Z')
hold on
Any idea how I could save this figure as an stl file?
Thanks
  2 个评论
迪迪 赵
迪迪 赵 2021-11-24
I have the same problem. Have you solved it? Can you tell me how to solve it? thank you!

请先登录,再进行评论。

回答(1 个)

Henrique Ramos
Henrique Ramos 2020-5-2
Dear Daniel
Use the stlwrite export (file exchange), find for download at,
set the .m file at the same path, and run this code, at the your .m (gyroid)
fv = isosurface(x,y,z,v);
stlwrite('Gyroid.stl',fv)
  4 个评论
Henrique Ramos
Henrique Ramos 2022-2-16
The code is simple like that, and the main thing is the file stlwrite from the link, as I mentioned, should be in the same folder.
Use the stlwrite export (file exchange), find for download at,
% Number of cells
x_period = 4;
y_period = 4;
z_period = 4;
% Mesh grid
[x,y,z] = meshgrid(0:0.1:x_period*pi, 0:0.1:y_period*pi, 0:0.1:z_period*pi);
% Gyroid Isosurface
f = ((cos(x).*sin(y))) + ((cos(y).*sin(z))) + ((cos(z).*sin(x)));
% PLot Figure
figure(1)
isosurface(x,y,z,f)
axis equal
xlabel('X')
ylabel('Y')
zlabel('Z')
% Name STL and write
stlwrite('Gyroid.stl',isosurface(x,y,z,f))
MITHILESH KURUP
MITHILESH KURUP 2022-2-16
Hello Henrique,
The file stlwrite from the link and the main code, both are in the same folder only.
But, unfortunately it is still giving the same error as before:
Unable to write to Gyroid.stl
The version that I'm using is MATLAB R 2021 b. Could it be due to the current version that I'm using?
Thanks

请先登录,再进行评论。

Community Treasure Hunt

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

Start Hunting!

Translated by