gcode2pointClound

振镜系统优化

安装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(
  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值