大家好 我这有一个非常好的LISP程序 可以自动改变直线,圆等的线形比例 但不能改变矩形及多段线的的 哪位大大修改一下 (defun c:df () ;自動變換成適當比例的虛線 (ltchange "dashed" 3 "bylayer") (princ) ) (defun ltchange (type1 scale color / oce lin n nam tab pt1 pt2 x1 x2 y1 y2 len leg sca otyp ocol osca col typ lts rad ) ;自動變換成適當比例的中心線 (setq oce (getvar "cmdecho") lts (getvar "ltscale") ) ;_ end of setq (setvar "cmdecho" 0) (setq n 0) (print (strcat "Select object change to " type1 ":") ) ;_ end of print (setq lin (ssget '((-4 . "<OR") (0 . "LINE") (0 . "CIRCLE") (0 . "ELLIPSE") (0 . "ARC") (0 . "polyline") (-4 . "OR>") ) ) ;_ end of ssget ) ;end setq (if (not lin) (progn (alert "\nNo selection!") (exit) ) ;_ end of progn ) ;end if (repeat (sslength lin) (setq nam (ssname lin n)) (setq tab (entget nam)) ;;;;;;;;;;circle (if (= (cdr (assoc 0 tab)) "CIRCLE") (progn (setq rad (cdr (assoc 40 tab))) (setq len (* 2 (* 3.14 rad))) ) ;如是圓實體取周長為"len" ;;;;;;;;;;ARC (if (= (cdr (assoc 0 tab)) "ARC") (progn (setq rad (cdr (assoc 40 tab))) (setq len (* 3.14 rad)) ) ;end progn;如是圓弧取其圓周長半 ;;;;;;;;;;ellipse (if (= (cdr (assoc 0 tab)) "ellipse") (progn (setq rad (cdr (assoc 40 tab))) (setq len (* 2 (* 3.14 rad))) ) ;;;;;;;;;LINE (progn (setq pt1 (cdr (assoc 10 tab)) pt2 (cdr (assoc 11 tab)) len (distance pt1 pt2) ) ;end setq ) ;end progn ) ;end if ) );end if (cond ((and (> len 0) (<= len 2)) (setq leg 2) ) ((and (> len 2) (<= len 5)) (setq leg 6) ) ((and (> len 5) (<= len 30)) (setq leg 20) ) ((and (> len 30) (<= len 50)) (setq leg 40) ) ((and (> len 50) (<= len 100)) (setq leg 75) ) ((> len 100) (setq leg 100) ) ) ;end cond (setq sca (/ leg scale lts 2)) (command "-linetype" "l" type1 "acad.lin" "" "") (command "change" nam "" "p" "c" color "lt" type1 "s" SCA "") ;_ end of command ;_ end of command ;_ end of command (setq n (+ n 1)) ) ;end repeat (setvar "cmdecho" oce) (princ) ) ;_ end of defun
|