(defun c:THY ()
(princ "\n根據圓直徑替換成塊: ")
(if (setq ss (ssget '((0 . "circle"))))
还不错,改下容差
(defun c:THY ()
(princ "\n根據圓直徑替換成塊: ")
(if (setq ss (ssget '((0 . "circle"))))
(progn
(setq i -1
ss1 (ssadd)
)
(while (setq s1 (ssname ss (setq i (1+ i))))
(setq ent (entget s1)
pt(cdr (assoc 10 ent))
rr(cdr (assoc 40 ent))
)
(cond ((= (rtos rr 2 2) "3")
(command "insert" "LSPD6" pt 1 1 0)
(ssadd s1 ss1)
)
((= (rtos rr 2 2) "4")
(command "insert" "LSPD8" pt 1 1 0)
(ssadd s1 ss1)
)
((= (rtos rr 2 0) "5")
(command "insert" "LSPD10" pt 1 1 0)
(ssadd s1 ss1)
)
((= (rtos rr 2 2) "6")
(command "insert" "LSPD12" pt 1 1 0)
(ssadd s1 ss1)
)
((= (rtos rr 2 2) "8")
(command "insert" "LSPD16" pt 1 1 0)
(ssadd s1 ss1)
)
((= (rtos rr 2 2) "10")
(command "insert" "LSPD20" pt 1 1 0)
(ssadd s1 ss1)
)
)
)
(command "erase" ss1 "")
)
)
(princ)
) 越来越强大
非常好!! bssurvey 发表于 2018-1-19 13:19
(defun c:THY ()
(princ "\n根據圓直徑替換成塊: ")
(if (setq ss (ssget '((0 . "circle"))))
怎么加上一段线形过滤,rr=3且线形为虚线任意一种才替换(or(= "HIDDEN" LTY1)
(= "HIDDEN2" LTY1)
(= "HIDDENX2" LTY1)
(= "DASHED" LTY1)
(= "DASHED2" LTY1)
(= "DASHEDX2" LTY1)))
:handshake谢谢 本帖最后由 bssurvey 于 2018-1-25 13:39 编辑
shopping200 发表于 2018-1-25 09:56
怎么加上一段线形过滤,rr=3且线形为虚线任意一种才替换(or(= "HIDDEN" LTY1)
...
(defun c:THY ()
(setvar "CMDECHO" 0) ;如果程序測試沒問題,可以加上這個,這樣命令列就不會出現執行的過程,但最後要還原回來(setvar "CMDECHO" 1)。
(princ "\n根據圓直徑替換成塊: ") ;如果在ssget後面加"x" 這一列就不用了
(if (setq ss (ssget '((0 . "circle")))) ; 也可以批量做,不用點選,(setq ss (ssget "x" '((0 . "circle"))))只要在ssget後面加"x"就可以了
(progn
(setq i -1
ss1 (ssadd)
)
(while (setq s1 (ssname ss (setq i (1+ i))))
(setq ent (entget s1)
pt(cdr (assoc 10 ent))
rr(cdr (assoc 40 ent))
lty1(cdr (assoc 6 ent)) ;加這一列
)
(cond ((and (>= rr 3)(< rr 4) ;如果要容差應該這麼寫 因為RTOS 轉換後,比對要完全符合才可以
(or(= "HIDDEN" LTY1)
(= "HIDDEN2" LTY1)
(= "HIDDENX2" LTY1)
(= "DASHED" LTY1)
(= "DASHED2" LTY1)
(= "DASHEDX2" LTY1)
)
)
(command "insert" "LSPD6" pt 1 1 0)
(ssadd s1 ss1)
)
((and (>= rr 4)(< rr 5))
(command "insert" "LSPD8" pt 1 1 0)
(ssadd s1 ss1)
)
((and (>= rr 5)(< rr 6))
(command "insert" "LSPD10" pt 1 1 0)
(ssadd s1 ss1)
)
((and (>= rr 6)(< rr 7))
(command "insert" "LSPD12" pt 1 1 0)
(ssadd s1 ss1)
)
((and (>= rr 7)(< rr 8))
(command "insert" "LSPD16" pt 1 1 0)
(ssadd s1 ss1)
)
((and (>= rr 8)(< rr 9))
(command "insert" "LSPD20" pt 1 1 0)
(ssadd s1 ss1)
)
)
)
(command "erase" ss1 "")
)
)
(setvar "CMDECHO" 1)
(princ)
)
学习一下下
bssurvey 发表于 2018-1-25 10:50
(defun c:THY ()
太感谢了。 bssurvey 发表于 2018-1-25 10:50
(defun c:THY ()
;为什么对BYBLOCKCONTINUOUS不管用呢?
(cond ((and (>= rr 2.999)(< rr 3.001)
(or(= "HIDDEN" LTY1)
(= "HIDDEN2" LTY1)
(= "HIDDENX2" LTY1)
(= "DASHED" LTY1)
(= "DASHED2" LTY1)
(= "DASHEDX2" LTY1)
)
)
(command "insert" "XLV6" pt 1 1 0)
(ssadd s1 ss1)
)
((and (>= rr 2.999)(< rr 3.001)
(or(= "BYBLOCK" LTY1)
(= "CONTINUOUS" LTY1)
)
)
(command "insert" "XLW6" pt 1 1 0)
(ssadd s1 ss1)
) shopping200 发表于 2018-1-25 17:17
;为什么对BYBLOCKCONTINUOUS不管用呢?
(cond ((and (>= rr 2.999)(< rr 3.001)
...
字串比對時大小寫有區分 "Continuous" "ByBlock"
虽然看不太懂,慢慢学习了
页:
1
[2]