26
1495
20
初露锋芒
使用道具 举报
29
781
430
中流砥柱
(alert (vl-princ-to-string (+ 1 2 3)))
114
1万
; Golf by Lee McDonnell ~ 28/12/2008 ; Credit to ASMI for Polyline Vertex Code(defun c:golf (/ *error* varLst oldVars pl plvert dislist totyrd anglist ptslist lastxt txtval) ; --- Error Trap --- (defun *error* (msg) (mapcar 'setvar varLst oldVars) (if (= msg "") (princ "\nFunction Complete.") (princ "\nError or Esc pressed... ") ) ;_ end if (princ) ) ; end of *error* (setq varLst (list "CMDECHO" "CLAYER") oldVars (mapcar 'getvar varLst) ) ; end setq ; --- Error Trap --- (or (getenv "GOLF:OFF") (setenv "GOLF:OFF" "125")) (or (getenv "GOLF:TEXT") (setenv "GOLF:TEXT" "30.0")) (or (getenv "GOLF:LTSCALE") (setenv "GOLF:LTSCALE" "300")) (alert (strcat "Type "GOLFSET" to Alter Base Variables \nCurrent Settings: \nText Offset: " (getenv "GOLF:OFF") "\nText Height: " (getenv "GOLF:TEXT") "\nLine-Type Scale: " (getenv "GOLF:LTSCALE") ) ;_ end strcat ) ;_ end alert (setvar "cmdecho" 0) (mapcar 'makelay '("DESIGN-PROP-CTR-LINES" "DESIGN-PROP-CTR-LINES-POINTS" "DESIGN-PROP-CTR-LINES-FLAGS" "DESIGN-PROP-CTR-LINES-YARDS" ) ) ;_ end mapcar (setvar "clayer" "DESIGN-PROP-CTR-LINES") (prompt "\nConsruct Polyline: ") (command "_pline") (while (> (getvar "cmdactive") 0) (command pause)) (setq pl (entlast)) (command "_pedit" pl "w" "1.0" "") (command "_chprop" pl "" "C" "BYLAYER" "LT" "AG-CENTER" "S" (getenv "GOLF:LTSCALE") "") (setq plvert (mapcar 'cdr (vl-remove-if '(lambda (x) (/= 10 (car x))) (entget pl)))) (Pointer plvert) (pdist plvert) (setq totyrd (/ (apply '+ dislist) 3)) (setq dislist (mapcar '(lambda (x) (/ x 3)) dislist)) (pangs plvert) (setq anglist (mapcar '(lambda (x) (+ x (/ pi 2))) anglist)) (setq ptslist (cdr plvert)) (if (= (length anglist) (length ptslist)) (progn (setq xth 0) (foreach x anglist (setq pt (polar (nth xth ptslist) x (atof (getenv "GOLF:OFF")))) (maketext pt (rtos (nth xth dislist) 2 0)) (command "_chprop" (entlast) "" "C" "BYLAYER" "") (setq xth (1+ xth)) ) ;_ end foreach ) ;_ end progn ) ;_ end if (setq lastxt (entget (entlast))) (setq txtval (cdr (assoc 1 lastxt))) (setq lastxt (subst (cons 1 (strcat txtval "/" (rtos totyrd 2 0))) (assoc 1 lastxt) lastxt)) (entmod lastxt) (*error* "") (princ)) ;_ end defun(defun Pointer (entlist / don) (setvar "clayer" "DESIGN-PROP-CTR-LINES-POINTS") (foreach coord entlist (command "_donut" "0" "20" coord "") (setq don (entlast)) (command "_chprop" don "" "C" "BYLAYER" "") ) ;_ end foreach) ;_ end defun(defun makelay (x) (if (not (tblsearch "Layer" x)) (command "-layer" "m" x "") (setvar "clayer" x) ) ;_ end if) ;_ end defun(defun pdist (entlist1 / index len dis) (setq index 0 len (length entlist1) ) ;_ end setq (while (< index (1- len)) (setq dis (distance (nth index entlist1) (nth (1+ index) entlist1) ) ;_ end distance dislist (cons dis dislist) index (1+ index) ) ;_ end setq ) ;_ end while (princ)) ;_ end defun(defun maketext (x y) (entmake (list '(0 . "TEXT") '(8 . "DESIGN-PROP-CTR-LINES-YARDS")