QQ登录

只需一步,快速开始

快捷登录

登录 或者 注册 请先

UG爱好者

查看: 1572|回复: 32
打印 上一主题 下一主题

[分享] 刀具余量信息输出,基本可以算完整吧,哪里不对希望指正

[复制链接]

中尉

Rank: 5Rank: 5

17

主题

215

帖子

4433

积分
跳转到指定楼层
楼主
发表于 2024-8-24 11:42:54 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
之前发过贴,求助论坛的坛友有关余量代码信息, 通过论坛朋友不断的提醒帮助,(当然自己还是不会写),用百度AI算是给写出来了, 测试也没有发现什么问题,先把以前大多数人用的代码和问题说出来。   这个差不多是之前多数人用的代码和问题。   
global mom_stock_part mom_stock_floor mom_operation_type
if { ![info exists mom_stock_floor] } {
set mom_stock_floor 0
} else {
if { $mom_operation_type != "Point to Point" && $mom_operation_type != "Drilling" } {
MOM_output_literal "(XY=[string trimright [format "%.2f" $mom_stock_part] "0"]mm Z=[string trimright [format "%.2f" $mom_stock_floor] "0"]mm)"
}
} 这个是修改后的代码
global mom_stock_floor mom_stock_part mom_wall_stock mom_stock_part_use
global sidestock floorstock mom_operation_type




if {[info exists mom_stock_part]} {
    set sidestock $mom_stock_part
   
    if {[info exists mom_wall_stock] && $mom_wall_stock != 0} {
        set sidestock $mom_wall_stock
    }
} else {
   
    set sidestock 0
}




if {[info exists mom_stock_floor]} {
   
    if {[info exists mom_stock_part_use] && $mom_stock_part_use == 1 && [info exists mom_stock_part]} {
        set floorstock $mom_stock_part
    } else {
        
        set floorstock $mom_stock_floor
    }
} else {
   
    set floorstock 0
}




if {([info exists sidestock] && $sidestock != 0) || ([info exists floorstock] && $floorstock != 0)} {
    if {$mom_operation_type != "Point to Point" && $mom_operation_type != "Drilling"} {
      
        MOM_output_literal "(XY=[string trimright [format "%.2f" $sidestock] "0"]mm Z=[string trimright [format "%.2f" $floorstock] "0"]mm)"
    }
}



有奖推广贴子: 

回复

使用道具 举报

中尉

Rank: 5Rank: 5

17

主题

215

帖子

4433

积分
来自 6#
 楼主| 发表于 2024-8-24 14:33:17 | 只看该作者
global mom_stock_floor mom_stock_part mom_wall_stock mom_stock_part_use
global sidestock floorstock mom_operation_type


if {[info exists mom_stock_part]} {
    set sidestock $mom_stock_part
   
    if {[info exists mom_wall_stock] && $mom_wall_stock != 0} {
        set sidestock $mom_wall_stock
    }
} else {
   
    set sidestock 0
}


if {[info exists mom_stock_floor]} {
   
    if {[info exists mom_stock_part_use] && $mom_stock_part_use == 1 && [info exists mom_stock_part]} {
        set floorstock $mom_stock_part
    } else {
        
        set floorstock $mom_stock_floor
    }
} else {
   
    set floorstock 0
}


if {([info exists sidestock] && $sidestock != 0) || ([info exists floorstock] && $floorstock != 0)} {
    if {$mom_operation_type != "Point to Point" && $mom_operation_type != "Drilling"} {
      
        MOM_output_literal "(XY=[string trimright [format "%.2f" $sidestock] "0"]mm Z=[string trimright [format "%.2f" $floorstock] "0"]mm)"
    }
}
回复 支持 反对

使用道具 举报

中尉

Rank: 5Rank: 5

17

主题

215

帖子

4433

积分
来自 28#
 楼主| 发表于 2024-9-1 09:34:26 | 只看该作者
不知道为代码哪里有问题会出现以下情况,                                                   

global mom_operation_type
global mom_stock_part
global mom_stock_floor
global mom_stock_part_use
global xy xy1 z1



if {![info exists mom_stock_floor]} {
    set mom_stock_floor 0
}


if {![info exists mom_stock_part]} {
    set xy 0
} else {
    set xy1 $mom_stock_part
}


if {![info exists mom_stock_part_use] || $mom_stock_part_use != 1} {

    if {$mom_operation_type != "Point to Point" && $mom_operation_type != "Drilling"} {
        MOM_output_literal "(XY= [format "%.2f" $mom_stock_part]mm Z= [format "%.2f" $mom_stock_floor]mm)"
    }
} else {

    set xy1 $mom_stock_part
    set z1 $mom_stock_part
    MOM_output_literal "(XY= [format "%.2f" $xy1]mm Z= [format "%.2f" $z1]mm)"
}

回复 支持 反对

使用道具 举报

中尉

Rank: 5Rank: 5

17

主题

215

帖子

4433

积分
沙发
 楼主| 发表于 2024-8-24 11:46:39 | 只看该作者
上面的代码比较乱, 重新发一个global mom_stock_floor mom_stock_part mom_wall_stock mom_stock_part_use global sidestock floorstock mom_operation_type   if {[info exists mom_stock_part]} {     set sidestock $mom_stock_part         if {[info exists mom_wall_stock] && $mom_wall_stock != 0} {         set sidestock $mom_wall_stock     } } else {         set sidestock 0 }   if {[info exists mom_stock_floor]} {          if {[info exists mom_stock_part_use] && $mom_stock_part_use == 1 && [info exists mom_stock_part]} {         set floorstock $mom_stock_part     } else {                  set floorstock $mom_stock_floor     } } else {          set floorstock 0 }   if {([info exists sidestock] && $sidestock != 0) || ([info exists floorstock] && $floorstock != 0)} {     if {$mom_operation_type != "Point to Point" && $mom_operation_type != "Drilling"} {                 MOM_output_literal "(XY=[string trimright [format "%.2f" $sidestock] "0"]mm Z=[string trimright [format "%.2f" $floorstock] "0"]mm)"     } }     global mom_stock_part mom_stock_floor mom_operation_type  if { ![info exists mom_stock_floor] } { set mom_stock_floor 0 } else { if { $mom_operation_type != "Point to Point" && $mom_operation_type != "Drilling" } { MOM_output_literal "(XY=[format "%.2f" $mom_stock_part] Z=[format "%.2f" $mom_stock_floor])" } }
回复 支持 反对

使用道具 举报

中尉

Rank: 5Rank: 5

17

主题

215

帖子

4433

积分
板凳
 楼主| 发表于 2024-8-24 11:47:32 | 只看该作者
张思颖 发表于 2024-8-24 11:46
上面的代码比较乱, 重新发一个global mom_stock_floor mom_stock_part mom_wall_stock mom_stock_part_use ...

更乱了global mom_stock_floor mom_stock_part mom_wall_stock mom_stock_part_use
global sidestock floorstock mom_operation_type


if {[info exists mom_stock_part]} {
    set sidestock $mom_stock_part

    if {[info exists mom_wall_stock] && $mom_wall_stock != 0} {
        set sidestock $mom_wall_stock
    }
} else {

    set sidestock 0
}


if {[info exists mom_stock_floor]} {

    if {[info exists mom_stock_part_use] && $mom_stock_part_use == 1 && [info exists mom_stock_part]} {
        set floorstock $mom_stock_part
    } else {

        set floorstock $mom_stock_floor
    }
} else {

    set floorstock 0
}


if {([info exists sidestock] && $sidestock != 0) || ([info exists floorstock] && $floorstock != 0)} {
    if {$mom_operation_type != "Point to Point" && $mom_operation_type != "Drilling"} {

        MOM_output_literal "(XY=[string trimright [format "%.2f" $sidestock] "0"]mm Z=[string trimright [format "%.2f" $floorstock] "0"]mm)"
    }
}




global mom_stock_part mom_stock_floor mom_operation_type

if { ![info exists mom_stock_floor] } {
set mom_stock_floor 0
} else {
if { $mom_operation_type != "Point to Point" && $mom_operation_type != "Drilling" } {
MOM_output_literal "(XY=[format "%.2f" $mom_stock_part] Z=[format "%.2f" $mom_stock_floor])"
}
}

回复 支持 反对

使用道具 举报

六级士官

Rank: 4

2

主题

113

帖子

1565

积分
地板
发表于 2024-8-24 14:29:55 | 只看该作者
这代码是不是多的有东西怎么输出两行余量呢?

1724480935822.png (6.11 KB, 下载次数: 4)

1724480935822.png
回复 支持 反对

使用道具 举报

中尉

Rank: 5Rank: 5

17

主题

215

帖子

4433

积分
5#
 楼主| 发表于 2024-8-24 14:32:45 | 只看该作者
13526775595 发表于 2024-8-24 14:29
这代码是不是多的有东西怎么输出两行余量呢?

global mom_stock_floor mom_stock_part mom_wall_stock mom_stock_part_use
global sidestock floorstock mom_operation_type


if {[info exists mom_stock_part]} {
    set sidestock $mom_stock_part
   
    if {[info exists mom_wall_stock] && $mom_wall_stock != 0} {
        set sidestock $mom_wall_stock
    }
} else {
   
    set sidestock 0
}


if {[info exists mom_stock_floor]} {
   
    if {[info exists mom_stock_part_use] && $mom_stock_part_use == 1 && [info exists mom_stock_part]} {
        set floorstock $mom_stock_part
    } else {
        
        set floorstock $mom_stock_floor
    }
} else {
   
    set floorstock 0
}


if {([info exists sidestock] && $sidestock != 0) || ([info exists floorstock] && $floorstock != 0)} {
    if {$mom_operation_type != "Point to Point" && $mom_operation_type != "Drilling"} {
      
        MOM_output_literal "(XY=[string trimright [format "%.2f" $sidestock] "0"]mm Z=[string trimright [format "%.2f" $floorstock] "0"]mm)"
    }
}
回复 支持 反对

使用道具 举报

中尉

Rank: 5Rank: 5

13

主题

213

帖子

3486

积分
7#
发表于 2024-8-24 14:42:27 | 只看该作者
精光的时候,侧底余量都是零。就不显示了吗?
回复 支持 反对

使用道具 举报

中尉

Rank: 5Rank: 5

17

主题

215

帖子

4433

积分
8#
 楼主| 发表于 2024-8-24 14:47:50 | 只看该作者
snowa* 发表于 2024-8-24 14:42
精光的时候,侧底余量都是零。就不显示了吗?

是的, ,具体是怎么回事, 我也搞不清楚,我本来就不会写代码的
回复 支持 反对

使用道具 举报

六级士官

Rank: 4

0

主题

139

帖子

1800

积分
9#
发表于 2024-8-24 15:07:20 | 只看该作者
张思颖 发表于 2024-8-24 14:33
global mom_stock_floor mom_stock_part mom_wall_stock mom_stock_part_use
global sidestock floorstock ...

不错不错,终于搞出来了,代码还是那个代码对吧,只要反过来就好了
回复 支持 反对

使用道具 举报

六级士官

Rank: 4

2

主题

113

帖子

1565

积分
10#
发表于 2024-8-24 15:10:10 | 只看该作者
本帖最后由 13526775595 于 2024-8-24 15:11 编辑
snowa* 发表于 2024-8-24 14:42
精光的时候,侧底余量都是零。就不显示了吗?

我试了一下把上面的那个代码屏蔽一下,下面这个代码在余量为零的时候是可以正常输出的。

1724483206126.jpg (14.55 KB, 下载次数: 4)

1724483206126.jpg

1724483470971.jpg (3.25 KB, 下载次数: 6)

1724483470971.jpg
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

 
 
QQ:1359218528
工作时间:
9:00-17:00
 
微信公众号
手机APP
机械社区
微信小程序

手机版|UG爱好者论坛 ( 京ICP备10217105号-2 )    论坛管理员QQ:1359218528

本站信息均由会员发表,不代表本网站立场,如侵犯了您的权利请联系管理员,邮箱:1359218528@qq.com  

Powered by UG爱好者 X3.2  © 2001-2014 Comsenz Inc. GMT+8, 2024-9-17 03:33

返回顶部