点击查看详细介绍

生成一个累计的序列,想用于给程序组重命名

caosir 4年前 4445 3

购买与咨询 NX 二次开发视频教程,请联系微信号:13890821008  QQ号:85585969  


背景:

本人用ug编程,给程序组重命名的时候发现个问题,就是如果编程的时候每个prt文件的程序组都是比如A01,A02,A03......这样的,在传到机床上去的时候,由于cnc机床是用网线链接的,在电脑上用ftp软件传到机床上,如果要换新的零件做,而新的零件的程序也是A01,A02,A03......的话,ftp软件会提示覆盖机床上的文件,这样传上去的程序会有问题。所以想通过让每个prt文件的程序组名字都不一样,这样就不会用覆盖的方式传到机床上,避免出现问题。

批注 2022-09-05 101948.png





累计序列实现:

如果D盘不存在a.txt文件,则创建该文件,并写入数据;

数据由 字母 F +当前日期 组成;

并另起一行写上时间日期;

如果D盘已经存在a.txt文件,则续写

续写先读第一行,去掉第一个字母,再转化为数值,再加10,之后转成 字母 G+该数值;

并另起一行写上时间日期;



a.txt如下:

33.png


重命名程序组:

每次想重命名的时候,运行该grip,得到一个序列值,

手动复制该序列值再去重命名程序组



批量重命名程序组:

此部分不知道怎么实现

如有大神帮忙,感激





以下为完整的源代码:

$$ 检查变量
gripsw/declrv

string/xulie(132),shijian(2000),lujing(2000)
string/date1(132),date2(132),date3(132),date4(132)
string/time1(132),time2(132),time3(132),time4(132)
number/num(4)

date1=substr(date,1,2) $$月
date2=substr(date,5,2) $$日
date3=substr(date,9,2) $$年份后2位
num(1)=VALF(date2)$$ 字符串转实数
date4=date3+'-'+date1+'-'+date2+'        '+time 
$$ 年-月-日        时:分
$$ 22-09-05        10:00
shijian=date4

lujing='D:\a.txt'
$$ print/lujing

$$----------------创建新文件,写入
Xinjian1:
create/txt,1,lujing,iferr,Xuxie2:$$ 新建文件
print/'创建新文件,写入'
xulie='F'+date2
write/1,xulie     $$ 写入
write/1,'->    ',shijian  $$ 写入字符串
file/txt,1  $$ 保存文件
fterm/txt,1 $$ 关闭文件
print/xulie
jump/end:

$$-------续写
Xuxie2:
print/'续写'
fetch/txt,1,lujing,iferr,end:
reset/1
read/1,xulie
$$ print/xulie 读第一行
num(4)=LENF(xulie)
$$ print/num(4)  xulie  的长度
xulie=substr(xulie,2,num(4)-1)
$$ print/xulie  去掉 xulie 的第一个字符
num(2)=VALF(xulie)$$ 字符串 xulie 转实数
$$ print/num(2)
num(3)=num(2)+10
$$ print/num(3) 加10
xulie=ISTRL(num(3))$$ 整数转字符串
xulie='G'+xulie
print/xulie
reset/1
write/1,xulie     $$ 写入
write/1,'->    ',shijian  $$ 写入字符串
write/1,'    '  $$ 写入字符串
file/txt,1  $$ 保存文件
fterm/txt,1 $$ 关闭文件
jump/end:

rpaint
end:
halt

1.png


2.png



以下为代码
$$ 检查变量
gripsw/declrv

string/xulie(132),shijian(2000),lujing(2000)
string/date1(132),date2(132),date3(132),date4(132)
string/time1(132),time2(132),time3(132),time4(132)
number/num(4)

date1=substr(date,1,2) $$月
date2=substr(date,5,2) $$日
date3=substr(date,9,2) $$年份后2位
num(1)=VALF(date2)$$ 字符串转实数
date4=date3+'-'+date1+'-'+date2+' '+time
$$ 年-月-日 时:分
$$ 22-09-05 10:00
shijian=date4

lujing='D:\a.txt'
$$ print/lujing

$$----------------创建新文件,写入
Xinjian1:
create/txt,1,lujing,iferr,Xuxie2:$$ 新建文件
print/'创建新文件,写入'
xulie='F'+date2
write/1,xulie $$ 写入
write/1,'-> ',shijian $$ 写入字符串
file/txt,1 $$ 保存文件
fterm/txt,1 $$ 关闭文件
print/xulie
jump/end:


$$-------续写
Xuxie2:
print/'续写'
fetch/txt,1,lujing,iferr,end:
reset/1
read/1,xulie
$$ print/xulie 读第一行
num(4)=LENF(xulie)
$$ print/num(4) xulie 的长度
xulie=substr(xulie,2,num(4)-1)
$$ print/xulie 去掉 xulie 的第一个字符
num(2)=VALF(xulie)$$ 字符串 xulie 转实数
$$ print/num(2)
num(3)=num(2)+10
$$ print/num(3) 加10
xulie=ISTRL(num(3))$$ 整数转字符串
xulie='G'+xulie
print/xulie
reset/1
write/1,xulie $$ 写入
write/1,'-> ',shijian $$ 写入字符串
write/1,' ' $$ 写入字符串
file/txt,1 $$ 保存文件
fterm/txt,1 $$ 关闭文件
jump/end:

rpaint
end:
halt






0

最新回复 (3)
  • vum66346 3月前
    1

    Clinical psychological observations have found that the impact of the full body sex doll on the mental health of single men is complex. On the positive side, these products provide a safe emotional practice ground for those with social anxiety, helping them gradually build an understanding of intimate relationships.


  • TimFord 1月前
    2

    Finally, using an American sex doll correctly involves an attitude of self-respect. Sexual pleasure is a natural part of human life, and engaging with it responsibly should not be accompanied by shame. At the same time, maturity means recognizing when something begins to interfere with daily functioning or emotional balance. Self-reflection ensures that usage remains healthy, intentional, and aligned with personal values.

  • smmsmrtn 1月前
    3

    One major advantage of buying shemale sex dolls are its personalization. Buyers can typically choose from: face shape, body shape, skin tone, eye color, wig style, and AI modules. Customization allows you to design a realistic best sex dolls that matches your aesthetic preferences.

请登录后发表新帖