Change scale in stl text mesh file

Reads an stl flie in text format, and applies an scale factor called factor.
74 Downloads
Updated 11 Oct 2018

View License

fid=fopen('originalfiletxt.stl');
fid2=fopen('modfile.stl','w');
factor=1000;
while ~feof(fid)
tline = fgetl(fid);
disp(tline);
if(strfind(tline,'vertex')==1)
A=sscanf(tline,'%s %f %f %f');
fprintf(fid2,'%s %.14f %.14f %.14f\n','vertex',A(7)*factor,A(8)*factor,A(9)*factor);
else
fprintf(fid2,'%s\n',tline);
end


end
fclose(fid);
fclose(fid2);

Cite As

JCBod Bodoque (2026). Change scale in stl text mesh file (https://www.mathworks.com/matlabcentral/fileexchange/69082-change-scale-in-stl-text-mesh-file), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2018b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags
Version Published Release Notes
1.0.0