 - (defun GRID (idx ids / ss idx dis xx yx xs ys train row entl osn fu)
- (setvar "cmdecho" 0)
- (command "_.undo" "be")
- (setq ss (ssget "x" '((8 . "a91") (0 . "*polyline"))))
- (if (/= nil ss)
- (command "layer" "t" "a91" "u" "a91" "" "erase" ss "")
- )
- (setvar "cecolor" "bylayer")
- (command "-layer" "m" "a91" "c" "1" "a91" "lt" "Continuous" "a91" "")
- (setq xx (* (* 0.5 100) (fix (/ (car idx) (* 0.5 100))))
- yx (* (* 0.5 100) (fix (/ (cadr idx) (* 0.5 100))))
- xs (+ (* 0.5 100)
- (* (* 0.5 100) (fix (/ (car ids) (* 0.5 100))))
- )
- ys (+ (* 0.5 100)
- (* (* 0.5 100) (fix (/ (cadr ids) (* 0.5 100))))
- )
- train xx
- row yx
- fu 400
- osn (getvar "osmode")
- )
- (setvar "osmode" 0)
- (while (<= train xs)
- (command "pline" (list train yx) (list train ys) "")
- (if (= (rem train (* 0.5 500)) 0)
- (progn
- (setq entl (entlast))
- (command "_change" entl "" "p" "c" "3" "")
- )
- )
- (setq train (+ train (* 0.5 100)))
- )
- (while (<= row ys)
- (command "pline" (list xx row) (list xs row) "")
- (if (= (rem row (* 0.5 400)) 0)
- (progn
- (setq entl (entlast))
- (command "_change" entl "" "p" "c" "3" "")
- )
- )
- (setq row (+ row (* 0.5 100)))
- )
- (command "-layer" "lock" "a91" "s" "0" "")
- (setvar "osmode" osn)
- (command "_.undo" "e")
- (princ)
- )
idx ids 是网格的左下和右上角,(* 0.5 100)是网格的宽度,可设个变量,Fu 是按500图标准分幅的边线,坐标进行了,推算,取的500地形图的标准分幅点位 |