尾数.00字串去除(已解决多谢飞雪神光大大帮忙及各位大大的解答)
本帖最后由 wuwubaibai 于 2024-1-15 21:20 编辑请问大大们~如果要达到以下的功能~该如何修改以下代码呢?感谢大大们
尾数.00字串去除~不是.00则不去除
(defun c:de3 ()
(setvar "cmdecho" 0)
(CClay "bend" 211 "2_正折")
(setq a (ssget "X" '((8 . "2_正折"))))
(if (and (/= nil a) (/= 0 (sslength a)))
(command "chprop" a "" "c" "bylayer" "La" "bend" "lt" "bylayer" "s" "1" "")
)
(command "ERASE"(ssget '((0 . "TEXT,MTEXT")(-4 . "<NOT")(1 . "*上*UP*,*上*up*,*下*down*,*下*DOWN*")(-4 . "NOT>")))"" )
(setvar "CmdEcho" 1)
(princ)
)
(defun CClay (layname cc sObjTyp) ;;;layname
(if (= nil (tblsearch "layer" layname))
(command "-layer" "n" layname "c" cc layname "")
)
(setq SS(ssget "x" (list (cons 0 sObjTyp) (cons 410 "Model"))))
(if (and (/= nil ss) (/= 0 (sslength SS)))
(command "chprop" SS "" "la" layname "")
)
(princ)
)
(defun c:de3 (/ a lm-entmake-layer ss ss-enlst str wz wz0 wz1 wz2 wz3)
(defun lm-entmake-layer(datalst)
(mapcar'set '(tc co) datalst)
(or co (setq co 256))
(or tc (setq tc (getvar "clayer")))
(entmake (list '(0 . "LAYER")'(100 . "AcDbSymbolTableRecord")'(100 . "AcDbLayerTableRecord")(cons 2 tc)(cons 62 co)'(70 . 0)'(6 . "CONTINUOUS")))
)
(defun ss-enlst (ss / enlst)
(cond
((= (type ss) 'PICKSET)
(vl-remove-if-not '(lambda (x) (= (type x) 'ENAME)) (mapcar 'cadr (ssnamex SS)))
)
((= (type ss) 'LIST)
(setq enlst (ssadd))
(last (mapcar '(lambda (x) (ssadd x enlst)) ss))
)
)
)
(if (null (tblsearch "layer" "2_正折"))
(lm-entmake-layer (list "2_正折" 211))
)
(setq a (ssget "X" '((8 . "2_正折"))))
(foreach ty (ss-enlst a)
(vla-put-Layer (vlax-ename->vla-object ty) "bend")
)
(setq ss (ssget '((0 . "*TEXT") (1 . "上DOWN*,下DOWN*"))))
(foreach ty (vl-remove-if-not '(lambda (x) (= (type x) 'ENAME)) (mapcar 'cadr (ssnamex ss)))
(setq str (vla-get-TextString (vlax-ename->vla-object ty)))
(setq wz (vl-string-search "." str))
(if wz
(progn
(setq wz0 (substr str (+ wz 1) 3))
(if (= wz0 ".00")
(progn
(setq wz1 (substr str 1 wz))
(setq wz2 (substr str (+ wz 4)))
(setq wz3 (strcat wz1 wz2))
(vla-put-TextString (vlax-ename->vla-object ty) wz3)
)
)
)
)
)
(princ)
) 本帖最后由 llsheng_73 于 2023-12-31 09:13 编辑
wuwubaibai 发表于 2023-12-30 02:33
请问这个过滤出来后还是得去0呀!前面的数字我还要
(defun delstr(str chars)
(while(vl-string-search chars str)
(setq str(VL-STRING-SUBST""chars str)))
str)
(defun c:tt(/ e s)
(if(setq s(ssget'((0 . "text")(1 . "*.00*"))))
(while(setq e(ssname s 0))
(ssdel e s)
(entmod(list(cons -1 e)(cons 1(delstr(cdr(assoc 1(entget e)))".00"))(cons 8 "bend"))))
)) 飞雪神光 发表于 2023-12-29 10:23
"(ssget"X" '((0 . "TEXT,MTEXT")(-4 . "")))
加了以后完全选不到东西了~还在研究中:dizzy:
defun c:de3 (/ ss str wz wz0 wz1 wz2 wz3)
(setvar "cmdecho" 0)
(CClay "bend" 211 "2_正折")
(setq a (ssget "X" '((8 . "2_正折"))))
(if (and (/= nil a) (/= 0 (sslength a)))
(command "chprop" a "" "c" "bylayer" "La" "bend" "lt" "bylayer" "s" "1" "")
)
(setq ss (ssget '((0 . "*TEXT") (1 . "上DOWN*,下DOWN*"))))
(foreach ty (vl-remove-if-not '(lambda (x) (= (type x) 'ENAME)) (mapcar 'cadr (ssnamex ss)))
(setq str (vla-get-TextString (vlax-ename->vla-object ty)))
(vl-string-right-trim ".00" str)
(vl-string-right-trim "." (vl-string-right-trim "0" str))
(setq wz (vl-string-search "." str))
(if wz
(progn
(setq wz0 (substr str (+ wz 1) 3))
(if (= wz0 ".00")
(progn
(setq wz1 (substr str 1 wz))
(setq wz2 (substr str (+ wz 4)))
(setq wz3 (strcat wz1 wz2))
(vla-put-TextString (vlax-ename->vla-object ty) wz3)
)
)
)
)
)
command "ERASE"(ssget"X" '((0 . "TEXT,MTEXT")(-4 . "<NOT")(1 . "*上*UP*,*上*up*,*下*down*,*下*DOWN*")(-4 . "NOT>")))
(setvar "CmdEcho" 1)
(princ)
)
(defun CClay (layname cc sObjTyp) ;;;layname
(if (= nil (tblsearch "layer" layname))
(command "-layer" "n" layname "c" cc layname "")
)
(setq SS(ssget "x" (list (cons 0 sObjTyp) (cons 410 "Model"))))
(if (and (/= nil ss) (/= 0 (sslength SS)))
(command "chprop" SS "" "la" layname "")
)
(princ)
) 一看就是AI写的这用find命令替换不就行了 飞雪神光 发表于 2023-12-28 22:27
一看就是AI写的这用find命令替换不就行了
不是AI写的
是不才的我找资料东拼西凑出来的
因为不懂LISP只能找寻大量资料
但也只能拼凑到这样了 本帖最后由 飞雪神光 于 2023-12-31 16:06 编辑
好吧 能凑成这样也是不容易(defun c:de3 (/ ss str wz wz0 wz1 wz2 wz3)
(setq ss (ssget '((0 . "*TEXT") (1 . "上DOWN*,下DOWN*"))))
(foreach ty (vl-remove-if-not '(lambda (x) (= (type x) 'ENAME)) (mapcar 'cadr (ssnamex ss)))
(setq str (vla-get-TextString (vlax-ename->vla-object ty)))
(setq wz (vl-string-search "." str))
(if wz
(progn
(setq wz0 (substr str (+ wz 1) 3))
(if (= wz0 ".00")
(progn
(setq wz1 (substr str 1 wz))
(setq wz2 (substr str (+ wz 4)))
(setq wz3 (strcat wz1 wz2))
(vla-put-TextString (vlax-ename->vla-object ty) wz3)
)
)
)
)
)
(princ)
) 取出末尾数字(自己搜)---然后atof---判断(= (fix a) a)--再转字符串连接 飞雪神光 发表于 2023-12-28 22:48
好吧 能凑成这样也是不容易
非常感谢大大~可以实现~~剩下我应该凑一凑就能把图层搞定了~~感谢您 wzg356 发表于 2023-12-28 22:48
取出末尾数字(自己搜)---然后atof---判断(= (fix a) a)--再转字符串连接
谢谢大大的提示~但其实已经搜很久了~对一个门外汉来说已经到极限了~只能求助了 飞雪神光 发表于 2023-12-28 22:48
好吧 能凑成这样也是不容易
大大抱歉再请问一下~.00解决了~图层我也改好了~
不过在
(princ)
)
前加上这句
(command "ERASE"(ssget '((0 . "TEXT,MTEXT")(-4 . "<NOT")(1 . "*上*UP*,*上*up*,*下*down*,*下*DOWN*")(-4 . "NOT>")))"" )
~那我得再重选一次才能把其他的注释去除~能否只选一次就完成了呢?感谢您
wuwubaibai 发表于 2023-12-29 02:03
大大抱歉再请问一下~.00解决了~图层我也改好了~
不过在
(princ)
论坛上有选择集相减这个函数,选择后过滤一次就可以了吧 wuwubaibai 发表于 2023-12-29 02:03
大大抱歉再请问一下~.00解决了~图层我也改好了~
不过在
(princ)
"(ssget"X" '((0 . "TEXT,MTEXT")(-4 . "<NOT")(1 . "*上*UP*,*上*up*,*下*down*,*下*DOWN*")(-4 . "NOT>")))