Borrar filtros
Borrar filtros

3D plot questions for 3d printing

8 visualizaciones (últimos 30 días)
Matthew
Matthew el 23 de Oct. de 2023
Respondida: Shubham el 2 de Nov. de 2023
i created this user input 3d plot to ultimately create a shape that fit in the corner of the dodecagon pyramid. i want to convert this new shape to an stl file to print on a 3d printer.
**** Update *****
The new shape has been made without meshgrid, now has clean edges. how would i go about saving this figure to scale in the same 3d plane as the dodecagon pyramid, but without the pyramid being displayed. also, how would i give this new plane mass or thickness???
sidelength = input('Enter Side length: ');
height = input('Enter Height: ');
V=nsidedpoly(12,'Side',sidelength).Vertices;
V(end+1,3)=-height;
trisurf( delaunay(V(:,1:2)), V(:,1), V(:,2), V(:,3),'FaceColor','c')
%% calculating angle for new shape based off sidelength and height input
x6 = (sidelength*3.078)/2; %side to side to determine base length for angle1
a = ((2+sqrt(3))*(sidelength))/2; %point to point to determine midpoint starting location for new shape
a8 = (3.236*sidelength);
a1 = (a)*0.9;
h1 = -height;
angle1 = atand(height/x6);
angle2 = 90-angle1;
L = sidelength/2;
L1 = -1*(sidelength/2);
L12 = ((L)*0.9);% Y axis scaled 1:10
L123 = ((L1)*0.9)
angle_12 = 150;
d = (-1*height)*0.1; % Z axis scaled 1:10
b1 = (((sqrt(6)+sqrt(2))/2)*(sidelength));
c1 = ((sqrt(3)+1)*sidelength)*0.5;
c11 = (c1)*0.9
c2 = -(1.902*sidelength)*0.5;
hold on
plot(c1,c1,"*")
plot(a,L,"*")
plot(a,L1,"*")
plot3([a a1], [L L12], [0 d],"m");
plot3([a a1], [L1 L123], [0 d]);
plot3([c1 c11], [c1 c11], [0 d]);
x = [c1, c11, a1, a1, a, a];
y = [c1, c11, L12, L123, L1, L];
z = [0, d, d, d, 0, 0];
c = [1, 0, 0, 1, 1, 0]
figure(2)
patch(x,y,z,c)

Respuestas (1)

Shubham
Shubham el 2 de Nov. de 2023
Hey @Matthew,
I understand that you want to add some thickness to the shape and save it in a STL file to print on a 3D printer.
For adding thickness to the surface, you can use “surf2solid” available on the file exchange:
For saving the shape as a STL file and reading it, you can use “stlwrite” and “stlread” respectively as available on the file exchange:
Here is the modified code snippet (download the above specified files for the following code to work):
sidelength = input('Enter Side length: ');
height = input('Enter Height: ');
V=nsidedpoly(12,'Side',sidelength).Vertices;
V(end+1,3)=-height;
trisurf( delaunay(V(:,1:2)), V(:,1), V(:,2), V(:,3),'FaceColor','c')
%% calculating angle for new shape based off sidelength and height input
x6 = (sidelength*3.078)/2; %side to side to determine base length for angle1
a = ((2+sqrt(3))*(sidelength))/2; %point to point to determine midpoint starting location for new shape
a8 = (3.236*sidelength);
a1 = (a)*0.9;
h1 = -height;
angle1 = atand(height/x6);
angle2 = 90-angle1;
L = sidelength/2;
L1 = -1*(sidelength/2);
L12 = ((L)*0.9);% Y axis scaled 1:10
L123 = ((L1)*0.9)
angle_12 = 150;
d = (-1*height)*0.1; % Z axis scaled 1:10
b1 = (((sqrt(6)+sqrt(2))/2)*(sidelength));
c1 = ((sqrt(3)+1)*sidelength)*0.5;
c11 = (c1)*0.9
c2 = -(1.902*sidelength)*0.5;
hold on
plot(c1,c1,"*")
plot(a,L,"*")
plot(a,L1,"*")
plot3([a a1], [L L12], [0 d],"m");
plot3([a a1], [L1 L123], [0 d]);
plot3([c1 c11], [c1 c11], [0 d]);
x = [c1, c11, a1, a1, a, a];
y = [c1, c11, L12, L123, L1, L];
z = [0, d, d, d, 0, 0];
c = [1, 0, 0, 1, 1, 0];
patch(x,y,z,c);
figure(2)
patch(x,y,z,c);
axis image; camlight;
view([-135 35]);
%%Adding thickness to the surface
figure(3);
surf2solid(x,y,z,"THICKNESS",-0.1);
d = surf2solid(x,y,z,"THICKNESS",-0.1);
axis image; camlight;
view([-135 35]);
% Saving as stl file
stlname='ans.stl';
stlwrite(stlname,d);
%% Read it back in and display it
disp('Reading stl file...');
figure(4)
fv = stlread(stlname);
patch(fv,'FaceColor', [0.8 0.8 1.0], ...
'EdgeColor', 'none', ...
'FaceLighting', 'gouraud', ...
'AmbientStrength', 0.15);
% Add a camera light, and tone down the specular highlighting
camlight('headlight');
material('dull');
% Fix the axes scaling, and set a nice view angle
axis('image');
view([-135 35]);
The above code has produced the following output figures:
I have adjusted the camera angle to same direction for all the plots for an easy comparison.
The shape seems to be in same scale with that of the pyramid. But you may also try copying the axes to a new figure for plotting the shape:
You can also refer to the following website which contains resources and examples for 3D printing and MATLAB:
Hope this helps!!

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by