stl write triangulation error.

7 views (last 30 days)
Matthew
Matthew on 25 Oct 2023
Commented: Matthew on 25 Oct 2023
getting the error message
'input argument must be a triangulation object'
this is the code
sidelength = input('Enter Side length: ');
height = input('Enter Height: ');
ax = axes();
xlim(ax, [-20 20]);
ylim(ax, [-20 20]);
zlim(ax, [-20 20]);
view(ax, 3);
hold(ax, 'on');
x6 = (sidelength*3.078)/2;
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
x = [c1, c11, a1, a1, a, a];
y = [c1, c11, L12, L123, L1, L];
z = [0, d, d, d, 0, 0];
c = [1; 1; 1; 1; 1; 1];
surf2solid(x,y,z,'thickness',0.1); axis image; camlight;
S = surf2solid(x,y,z,'thickness',0.1);
stlwrite('test.stl',S)

Accepted Answer

Fabio Freschi
Fabio Freschi on 25 Oct 2023
Edited: Fabio Freschi on 25 Oct 2023
There are two errors
  1. The output of surf2solid is not a triangulation object
  2. inputs of stlwrite are in the wrong order
sidelength = input('Enter Side length: ');
height = input('Enter Height: ');
ax = axes();
xlim(ax, [-20 20]);
ylim(ax, [-20 20]);
zlim(ax, [-20 20]);
view(ax, 3);
hold(ax, 'on');
x6 = (sidelength*3.078)/2;
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
x = [c1, c11, a1, a1, a, a];
y = [c1, c11, L12, L123, L1, L];
z = [0, d, d, d, 0, 0];
c = [1; 1; 1; 1; 1; 1];
surf2solid(x,y,z,'thickness',0.1); axis image; camlight;
% below the changes
[T,P] = surf2solid(x,y,z,'thickness',0.1);
S = triangulation(T,P);
stlwrite(S,'test.stl')
  1 Comment
Matthew
Matthew on 25 Oct 2023
Thank you, I really appreciate your help.

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!