Borrar filtros
Borrar filtros

Need help regarding "surf2stl" - want to convert surface in to stl file.

6 visualizaciones (últimos 30 días)
EDIT: surf2stl is from the File Exchange. Attached here so code can be run
I am trying to convert the surface in to stl format... i am using surf2stl command but i cannot figure how to convert !! any help is appreciated :)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clc
clear all
close all
t1 = (0:pi/100:pi); % Top curve 0 to 180 deg
t2 = (-pi:pi/100:0); % Bottom curve 180 to -180 deg
%%% Body Station # 1 %%%
semimajright1 = 91.5*0.001; %%% semi major axis %%% width, x-axis
semimajleft1 = 91.5*0.001;
semiminup1 = 304.66*0.001; %%% semi minor axis %%% height, y-axis
semimindown1 = 0*0.001;
n1st1up = -1.43;
m1st1up = 1.25;
n1st1down = -1.0;
m1st1down = 1.6;
x1up = zeros(length(t1),length(n1st1up));
y1up = x1up;
z1up = x1up*0*0.001;
leg1up = cell(length(n1st1up),1);
x1down = zeros(length(t2),length(n1st1down));
y1down = x1down;
z1down = x1down*0*0.001;
leg1down = cell(length(n1st1down),1);
for i=1:length(n1st1up)
x1up(:,i) = sign(cos(t1)).*semimajright1.*abs(cos(t1)).^(2+n1st1up(i));
y1up(:,i) = sign(sin(t1)).*semiminup1.*abs(sin(t1)).^(2+m1st1up(i));
leg(i) = {['n1st1up = ',num2str(n1st1up(i))]};
end
for i=1:length(n1st1down)
x1down(:,i) = sign(cos(t2)).*semimajleft1.*abs(cos(t2)).^(2+n1st1down(i));
y1down(:,i) = sign(sin(t2)).*semimindown1.*abs(sin(t2)).^(2+m1st1down(i));
leg(i) = {['n1st1down = ',num2str(n1st1down(i))]};
end
%%% Body Station # 2 %%%
semimajright2 = 87.13*0.001; %%% semi major axis %%% width, x-axis
semimajleft2 = 87.13*0.001;
semiminup2 = 87.13*0.001; %%% semi minor axis %%% height, y-axis
semimindown2 = 87.13*0.001;
n1st2up = -1.43;
m1st2up = 1.25;
n1st2down = -1.43;
m1st2down = 1.25;
x2up = zeros(length(t1),length(n1st2up));
y2up = x2up;
z2up = x2up*0+800*0.001;
leg2up = cell(length(n1st2up),1);
x2down = zeros(length(t2),length(n1st2down));
y2down = x2down;
z2down = x2down*0+800*0.001;
leg2down = cell(length(n1st2down),1);
for i=1:length(n1st2up)
x2up(:,i) = sign(cos(t1)).*semimajright2.*abs(cos(t1)).^(2+n1st2up(i));
y2up(:,i) = sign(sin(t1)).*semiminup2.*abs(sin(t1)).^(2+m1st2up(i));
leg(i) = {['n1st2up = ',num2str(n1st2up(i))]};
end
for i=1:length(n1st2down)
x2down(:,i) = sign(cos(t2)).*semimajleft2.*abs(cos(t2)).^(2+n1st2down(i));
y2down(:,i) = sign(sin(t2)).*semimindown2.*abs(sin(t2)).^(2+m1st2down(i));
leg(i) = {['n1st2down = ',num2str(n1st2down(i))]};
end
%%% Body Station # 3 %%%
semimajright3 = 99.63*0.001; %%% semi major axis %%% width, x-axis
semimajleft3 = 99.63*0.001;
semiminup3 = 99.63*0.001; %%% semi minor axis %%% height, y-axis
semimindown3 = 99.63*0.001;
n1st3up = -1.43;
m1st3up = 1.25;
n1st3down = -1.43;
m1st3down = 1.25;
x3up = zeros(length(t1),length(n1st3up));
y3up = x3up;
z3up = x3up*0+950*0.001;
leg3up = cell(length(n1st3up),1);
x3down = zeros(length(t2),length(n1st3down));
y3down = x3down;
z3down = x3down*0+950*0.001;
leg3down = cell(length(n1st3down),1);
for i=1:length(n1st3up)
x3up(:,i) = sign(cos(t1)).*semimajright3.*abs(cos(t1)).^(2+n1st3up(i));
y3up(:,i) = sign(sin(t1)).*semiminup3.*abs(sin(t1)).^(2+m1st3up(i));
leg(i) = {['n1st3up = ',num2str(n1st3up(i))]};
end
for i=1:length(n1st3down)
x3down(:,i) = sign(cos(t2)).*semimajleft3.*abs(cos(t2)).^(2+n1st3down(i));
y3down(:,i) = sign(sin(t2)).*semimindown3.*abs(sin(t2)).^(2+m1st3down(i));
leg(i) = {['n1st3down = ',num2str(n1st3down(i))]};
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
xm1 = [(-y1down+(0.3)).'; z2down.'; z3down.'];
ym1 = [x1down.'; x2down.'; x3down.';];
zm1 = [z1down.'; (y2down+(0.152)).'; (y3down+(0.196)).'];
xm2 = [(-y1up+(0.3)).'; z2up.'; z3up.'];
ym2 = [x1up.'; x2up.'; x3up.'];
zm2 = [z1up.'; (y2up+(0.152)).'; (y3up+(0.196)).'];
figure(1)
grid on
hold on
axis equal
set(gcf,'color','white')
xlabel('X-axis','fontweight','bold','fontsize',10)
ylabel('Y-axis','fontweight','bold','fontsize',10)
zlabel('Z-axis','fontweight','bold','fontsize',10)
hold on
plot3(-y1up+(0.3),x1up,z1up,'r',-y1down+(0.3),x1down,z1down,'r',...
z2up,x2up,y2up+(0.152),'r',z2down,x2down,y2down+(0.152),'r',...
z3up,x3up,y3up+(0.196),'r',z3down,x3down,y3down+(0.196),'r','linewidth',2)
hold on
surf(xm1, ym1, zm1)
hold on
surf(xm2, ym2, zm2)
grid on
shading('interp')
hold on
surf2stl('Surface1.stl',xm1,ym1,zm1,xm2,ym2,zm2);
Error using surf2stl
Too many input arguments.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Respuesta aceptada

Cris LaPierre
Cris LaPierre el 22 de Jul. de 2023
Your calling syntax is incorrect. The function only has 4 inputs, but you are calling it with 7. Please see the syntax guidelines for the function here.
Valid syntaxes are:
  • SURF2STL('filename',X,Y,Z) writes a stereolithography (STL) file for a surface with geometry defined by three matrix arguments, X, Y and Z. X, Y and Z must be two-dimensional arrays with the same size.
  • SURF2STL('filename',x,y,Z), uses two vector arguments replacing the first two matrix arguments, which must have length(x) = n and length(y) = m where [m,n] = size(Z). Note that x corresponds to the columns of Z and y corresponds to the rows.
  • SURF2STL('filename',dx,dy,Z) uses scalar values of dx and dy to specify the x and y spacing between grid points.
  2 comentarios
Dr Sohaib Khan
Dr Sohaib Khan el 22 de Jul. de 2023
yes cris but even when i call 4 functions i am get the same error warning... trying to fix it. thankyou for replying....
Cris LaPierre
Cris LaPierre el 23 de Jul. de 2023
What is that error/warning? When I run your code just changing the function call, I get no errors or warnings.
surf2stl('Surface1.stl',xm1,ym1,zm1);
>> Wrote 400 facets

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Lighting, Transparency, and Shading en Help Center y File Exchange.

Productos


Versión

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by