振镜系统优化
安装Ultimaker
偏好设置 -> 基本 ->语言 -> 简体中文
偏好设置 -> 设置 -> Check all
偏好设置 -> 打印机 == 参数如图,下面也是==
参数设置
导入stl文件,调整好位置,点准备,就可保存模型,即gcode代码
实心matlab代码,gcode2pointClound
%%新Gcode解析,适用于实心加工件
clear;
syms u v t m n;
d = 150;%扫描间距
xtemp = 0;
ytemp = 0;
gcode = fopen('10-3-1.gcode');%导入Gcode文件
pc = fopen(('10-3-1v4.txt'), 'a');%写入点云文件
fprintf(pc, ['%s\r\n'], 'start');
g0Flag = 'G0';
g1Flag = 'G1';
xFlag = ' X';
yFlag = ' Y';
zFlag = ' Z';
nFlag = '\n';
eFlag = ' E';
while ~feof(gcode)
str1 = fgetl(gcode);
g0p = strfind(str1,g0Flag);
g1p = strfind(str1,g1Flag);
xp = strfind(str1,xFlag);
yp = strfind(str1,yFlag);
zp = strfind(str1,zFlag);
np = length(str1);
ep = strfind(str1,eFlag);
if zp
z = round(str2double(str1((zp+length(zFlag)):length(str1))) * 1000);
end
if g0p
if xp
if yp
if ep
strx = str1((xp+length(xFlag)):yp);
if length(strx) > 2
if strx(1:2) == '-.'
strx = strx(3:length(strx));
strx = ['-0.',strx];
end
end
stry = str1((yp+length(yFlag)):ep);
if length(stry) > 2
if stry(1:2) == '-.'
stry = stry(3:length(stry));
stry = ['-0.',stry];
end
end
x = round(str2double(strx) * 1000);
y = round(str2double(stry) * 1000);
xtemp = x;
ytemp = y;
fprintf(pc,'%d,%d,%d\r\n',[x,y,z]);
end
if zp
strx = str1((xp+length(xFlag)):yp);
if length(strx) > 2
if strx(1:2) == '-.'
strx = strx(3:length(strx));
strx = ['-0.',strx];
end
end
stry = str1((yp+length(yFlag)):zp);
if length(stry) > 2
if stry(1:2) == '-.'
stry = stry(3:length(stry));
stry = ['-0.',stry];
end
end
x = round(str2double(strx) * 1000);
y = round(str2double(stry) * 1000);
xtemp = x;
ytemp = y;
fprintf(pc,'%d,%d,%d\r\n',[x,y,z]);
end
if isempty(zp)
if isempty(ep)
strx = str1((xp+length(xFlag)):yp);
if length(strx) > 2
if strx(1:2) == '-.'
strx = strx(3:length(strx));
strx = ['-0.',strx];
end
end
stry = str1((yp+length(yFlag)):length(str1));
if length(stry) > 2
if stry(1:2) == '-.'
stry = stry(3:length(stry));
stry = ['-0.',stry];
end
end
x = round(str2double(strx) * 1000);
y = round(str2double(stry) * 1000);
xtemp = x;
ytemp = y;
fprintf(pc,'%d,%d,%d\r\n',[x,y,z]);
end
end
end
end
end
if g1p
if xp
if yp
if ep
strx = str1((xp+length(xFlag)):yp);
if length(strx) > 2
if strx(1:2) == '-.'
strx = strx(3:length(strx));
strx = ['-0.',strx];
end
end
stry = str1((yp+length(yFlag)):ep);
if length(stry) > 2
if stry(1:2) == '-.'
stry = stry(3:length(stry));
stry = ['-0.',stry];
end
end
x = round(str2double(strx) * 1000);
y = round(str2double(stry) * 1000);
md = max(abs(x - xtemp),abs(y - ytemp));
k = ceil(md / d) ;
for i =1:1:k
xx(i) = round(x - (k - i) * (x - xtemp) / k);
yy(i) = round(y - (k - i) * (y - ytemp) / k);
fprintf(pc,'%d,%d,%d\r\n',[xx(i),yy(i),z]);
end
xtemp = xx(i);
ytemp = yy(i);
end
if zp
strx = str1((xp+length(xFlag)):yp);
if length(