JPayne 发表于 2022-7-6 05:00:28

从桩号加减

这有点毛茸茸的-我有大约4000个标签,标签上有管道沿线的站点和焊缝编号,根据提供的新数据,站点都会增加或减少。
 
以下是一些随机标签:
0+57 MLC-25
748+94 ATI-16
 
只有定位需要更改-因此,如果它们都增加6,则将为0+63 MLC-25或749+00 ATI-16。
 
有没有Lisp程序的语言可以做到这一点?假设我需要删除+,修改数字并将+放回。
 
谢谢你的帮助!

Ohnoto 发表于 2022-7-6 05:39:15

我附上了一个LISP程序,我用过。我没有写它,而最初作者的功劳在于代码本身。这应该适用于单行文本。如果您有属性或多行文字,则可能需要进行一些修改。
 
另外,欢迎来到CadTutor。
反恐精英。LSP

JPayne 发表于 2022-7-6 05:40:44

成功了!非常感谢,Ohnoto!!

fixo 发表于 2022-7-6 06:00:58

我的2美分:


(setq inc (getint "\Enter increment with + / decrement with - : "))
(setq
strRep (vl-string-left-trim "0123456789" oldLabel))
(setq strFst
(vl-string-trim strRep oldLabel))
(setq strEnd (vl-string-left-trim
"+0123456789" strRep))
(setq sign
(if (minusp inc) "-" "+"))
(setq
decs
(if (= "-" sign)
(- (atoi strRep) (abs inc) )
(+ (atoi
strRep) (abs inc) ) ))


(setq newLabel
(if (= (fix (/ decs 100)) 1)
(strcat (itoa (+
(atoi strFst) (fix (/ decs 100)))) sign "00" strEnd)
(strcat strFst
sign (itoa decs) strEnd)))
页: [1]
查看完整版本: 从桩号加减