;;简单改了下
;;涉及到旋转角度,可能会受某些系统变量值的影响,比如ANGBASE或者ANGDIR,不严谨
;;可以考虑下用多行文字,多行文字本身有加框的选项
;;还有一些细节的地方你自己再看看
- (defun c:cgj (/ ANG BB CC DD EN EN_DATA FJM HH I JM K P1 P11 P2 P22 PC SS STR TXT)
- (setvar "CMDECHO" 0)
- (setq str (getstring "\n缺省配箍值<G1.0-0.5(#8@100200)>:"))
- (if (= str "")
- (setq str "G1.0-0.5")
- )
- (setq jm (atof (substr str 2 3))
- fjm (atof (substr str 6 3))
- )
- (setq ss (ssget '((0 . "text") (8 . "Pkpm_层15220"))))
- (setq i 0
- k 0
- )
- (vl-cmdf "LAYER" "m" "CGJ" "C" 1 "CGJ" "")
- (repeat (sslength ss)
- (setq en (ssname ss i))
- (setq en_data (entget en))
- (setq txt (cdr (assoc 1 en_data)))
- (setq bb (substr txt 2 3)
- cc (substr txt 6 3)
- DD (substr txt 1 1)
- )
- (if (AND (= DD "G") (or (> (atof bb) jm) (> (atof cc) fjm)))
- (progn
- (setq pc (textbox en_data)
- p1 (cdr (assoc 10 en_data))
- p2 (mapcar '+ p1 (cadr pc))
- hh (cdr (assoc 40 en_data))
- hh (* 0.1 hh)
- ang (cdr (assoc 50 en_data))
- )
- (setq p11 (mapcar '- p1 (list hh hh))
- p22 (mapcar '+ p2 (list hh hh))
- )
- (vl-cmdf "_.rectang" "_non" p11 p22)
- (if (equal ang (/ pi 2) 1e-5) (vl-cmdf "_.rotate" (entlast) "" "_non" p1 -90))
- (setq k (+ 1 k))
- )
- )
- (setq i (+ 1 i))
- )
- (princ (strcat "\n共找到超过缺省配箍值<" str "> " (itoa k) " 项。 "))
- )
|