- 积分
- 671
- 明经币
- 个
- 注册时间
- 2015-11-15
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2016-7-24 17:02:56
|
显示全部楼层
我之前用的,但没有显示- ;; eGrid.lsp
- ;; Rewritten by CAB @ TheSwamp.org
- ;;
- ;; User picks a rectangle to size the 24x24 grid lines the
- ;; User drags the grid to it's final position
- (defun c:egrid (/ DRAG GHOSTPT H_CNT H_CNT H_DIST H_OFS PLIST
- PT_1 PT_2 TIME TMP V_CNT V_CNT V_DIST V_OFS
- get_osmode calc_ get_points DrawGrid ghost
- )
-
- ;; CAB 10/5/2006
- ;;
- ;; Function to return the current osmode setting in the form of a string
- ;; If (getvar "osmode") = 175
- ;; (get_osmode) returns "_end,_mid,_cen,_nod,_int,_per"
- (defun get_osmode (/ cur_mode mode$)
- (setq mode$ "")
- (if (< 0 (setq cur_mode (getvar "osmode")) 16383)
- (mapcar
- '(lambda (x)
- (if (not (zerop (logand cur_mode (car x))))
- (setq mode$ (strcat mode$ (cadr x)))
- )
- )
- '(
- (0 "_non,")
- (1 "_end,")
- (2 "_mid,")
- (4 "_cen,")
- (8 "_nod,")
- (16 "_qua,")
- (32 "_int,")
- (64 "_ins,")
- (128 "_per,")
- (256 "_tan,")
- (512 "_nea,")
- (1024 "_qui,")
- (2048 "_app,")
- (4096 "_ext,")
- (8192 "_par")
- )
- )
- )
- mode$
- )
- ;; Subrutine - calc offset & count
- (defun calc_ (dist / rm ofs count)
- (setq count (/ dist 24.0))
- (setq rm (- count (fix count)))
- (setq ofs (* rm 12))
- (cond
- ((zerop rm) ; 24 even
- (setq count (1- count)
- ofs 24
- )
- )
- ((< ofs 12)
- (setq ofs (+ ofs 12)
- count (1- count)
- )
- )
- )
- (list ofs (fix count))
- )
- (defun get_points (ll h_ofs h_cnt v_ofs v_cnt h_dist v_dist / up ptl pts pte)
- (setq up (/ pi 2))
- ;; hor lines
- (setq pts (polar ll up v_ofs)
- pte (polar pts 0 h_dist)
- )
- (setq ptl (list (list pts pte)))
- (repeat v_cnt
- (setq pts (polar pts up 24)
- pte (polar pts 0 h_dist)
- )
- (setq ptl (cons (list pts pte) ptl))
- )
- ;; vert lines
- (setq pts (polar ll 0 h_ofs)
- pte (polar pts up v_dist)
- )
- (setq ptl (cons (list pts pte) ptl))
- (repeat h_cnt
- (setq pts (polar pts 0 24)
- pte (polar pts up v_dist)
- )
- (setq ptl (cons (list pts pte) ptl))
- )
- ptl
- )
- ;; Draw the Grid
- (defun DrawGrid (plist / mk_line)
- (defun mk_line (st en)
- (entmake (list
- (cons 0 "LINE") ;***
- (cons 6 "BYLAYER")
- (cons 8 "0")
- (cons 10 st) ;***
- (cons 11 en) ;***
- (cons 39 0.0)
- (cons 62 256)
- (cons 210 (list 0.0 0.0 1.0))
- )
- )
- )
- (mapcar '(lambda (x) (mk_line (car x) (cadr x))) plist)
- )
- ;; Ghost the Grid
- (defun ghost (plist / pv)
- (mapcar '(lambda (x)
- (if pv
- (setq pv (cons (car x) (cons (cadr x) (cons 4 pv))))
- (setq pv (list (car x) (cadr x) 4))
- )
- )
- plist
- )
- (grvecs (reverse pv))
- )
- ;;****************************
- ;; Main Routine starts here
- ;;****************************
- (setq pt_1 (getpoint "\n* Size the Grid, Pick Lower-Left corner *"))
- (setq pt_2 (getcorner pt_1 "\n* Pick Upper-Right corner *"))
- (setq h_dist (- (car pt_2) (car pt_1))) ; horizontal length of the rectangle
- (setq v_dist (- (cadr pt_2) (cadr pt_1))) ; vertical length of the rectangle
- (setq tmp (Calc_ h_dist)
- h_ofs (car tmp)
- h_cnt (cadr tmp)
- )
- (setq tmp (Calc_ v_dist)
- v_ofs (car tmp)
- v_cnt (cadr tmp)
- )
- (setq time T)
- (while time
- (setq drag (grread t 1 1))
- (cond
- ((= (car drag) 5)
- (if (null (setq ghostpt (osnap (cadr drag) (get_osmode))))
- (setq ghostpt (cadr drag))
- )
- (redraw)
- (setq plist (get_points ghostpt h_ofs h_cnt v_ofs v_cnt h_dist v_dist))
- (ghost plist)
- )
- ((= (car drag) 3)
- ;;(setq ghostpt (cadr drag))
- (if (null (setq ghostpt (osnap (cadr drag) (get_osmode))))
- (setq ghostpt (cadr drag))
- )
- (redraw)
- (setq plist (get_points ghostpt h_ofs h_cnt v_ofs v_cnt h_dist v_dist))
- (DrawGrid plist)
- (setq time nil)
- )
- )
- )
- (princ)
- )
|
|