Тема: Координатная сетка.
Нашёл где-то эту программу. Но в ней две проблемы. Первая это нужно координаты начала сетки вводить в ручную вместо того, что бы взять их указанием точки то же самое размеры сетки нужно вводить в командную строку хотя нагляднее и удобнее указать точку на экране.
И вторая как мне кажется, большая проблема это то что координаты начала должны быть кратными интервалу сетки. Если у меня интервал сетки 25 а координаты начала 10,10 то сетка будет строиться и подписываться 10,10 35,35 и 70,70 а нужно 25,25 50,50 75,75.
Хотелось бы что бы что бы внутренняя рамка начиналась в любой указанной точке, а сетка чертилась и подписывалась в соответствии с заданным интервалом в данном случае 25 но могут быть и другие 50, 100, т.д. И соответственно это соответствовало координатной сетки Автокада.
Возможно, предложенную программу довести до такого состояния.
Максимальная потребность это что бы рамку можно было начертить при необходимости под уголом.
Сам не понимаю в программировании.
; ********************************************************************
; S E T BOUNDARY OF THE MAP *
; LENGTH - distance along axis X *
; HEIGTH - distance along axis Y *
; INTERVAL - distanse between points of coordinates *
; SCALE - scale of the map *
; ********************************************************************
( defun c:FRAME()
(setvar "cmdecho" 0)
(setq beg_x (getreal "SET origin of coordinates : X = ")
beg_y (getreal " Y = ")
dist_x (getreal "SET length : ")
dist_y (getreal "SET heigth : ")
inter (getreal "SET interval : ")
sc (getreal "SET scale : ")
)
(command "osnap" "nearest")
; -------------------------------------------------------------
(command "osnap" "none" )
(command "layer" "new" "1201" "")
(command "layer" "new" "1202" "")
(command "layer" "new" "1206" "")
(command "layer" "new" "1207" "")
(command "layer" "new" "1208" "")
; -------------------------------------------------------------
(setq cross_x (+ beg_x inter)
cross_y (+ beg_y inter)
rel (/ sc 1250.0)
nn (* 3.125 rel)
n1 (* 15 rel)
n2 (* 2 rel)
n3 (* 3 rel)
n5 (* 5 rel)
n10 (* 10 rel)
n17 (* 17 rel)
n19 (* 19 rel)
n25 (* 2.5 rel)
r1 (list (- cross_x nn) cross_y)
r2 (list (+ cross_x nn) cross_y)
r3 (list cross_x (- cross_y nn))
r4 (list cross_x (+ cross_y nn))
p_left (list (- cross_x 14)(- cross_y 14))
p_right (list (+ cross_x 14)(+ cross_y 14))
n_x (fix (- (/ dist_x inter) 1))
n_y (fix (- (/ dist_y inter) 1))
)
(command "layer" "set" "1206" "")
(command "pline" r1 r2 "")
(setq aa1 (entlast))
(command "pline" r3 r4 "")
(setq aa2 (entlast))
; (command "zoom" "w" p_left p_right)
(if (or (= n_y 1) (= n_x 1))
(progn
(command "array" aa1 "" "r" n_y n_x inter )
(command "array" aa2 "" "r" n_y n_x inter )
)
(progn
(command "array" aa1 "" "r" n_y n_x inter inter )
(command "array" aa2 "" "r" n_y n_x inter inter )
)
)
; -------------------------------------------------------------
(setq p1 (list beg_x beg_y)
dx (+ beg_x dist_x)
dy (+ beg_y dist_y)
p2 (list dx beg_y)
p3 (list dx dy)
p4 (list beg_x dy)
)
(command "layer" "set" "1201" "")
(command "pline" p1 p2 p3 p4 p1 "")
; ------------------------------------------------------------
(setq b15x (- beg_x n1)
b15y (- beg_y n1)
dx15 (+ dx n1)
dy15 (+ dy n1)
p1g (list b15x beg_y)
p1v (list beg_x b15y)
p2g (list dx15 beg_y)
p2v (list dx b15y)
p3g (list dx15 dy)
p3v (list dx dy15)
p4g (list b15x dy)
p4v (list beg_x dy15)
)
(command "layer" "set" "1207" "")
(command "pline" p1g p1 p1v "")
(command "pline" p2g p2 p2v "")
(command "pline" p3g p3 p3v "")
(command "pline" p4g p4 p4v "")
; ----------------------------------------------------------
(setq p11g (list (+ (car p1g) n2)(+ (cadr p1g) n2))
p_11g (list (+ (car p11g) n2)(cadr p11g))
p12g (list (+ (car p1g) n2)(- (cadr p1g) n5))
p_12g (list (+ (car p12g) n2)(cadr p12g))
p41g (list (+ (car p4g) n2)(+ (cadr p4g) n2))
p_41g (list (car p41g)(cadr p41g))
p42g (list (+ (car p4g) n2)(- (cadr p4g) n5))
p_42g (list (car p42g)(cadr p42g))
p11v (list (+ (car p1v) n2)(+ (cadr p1v) n10))
p_11v (list (car p11v)(+ (cadr p11v) rel))
p12v (list (- (car p1v) n5)(+ (cadr p1v) n10))
p_12v (list (car p12v)(+ (cadr p12v) rel))
p41v (list (+ (car p4v) n2)(- (cadr p4v) n2))
p_41v (list (car p41v)(- (cadr p41v) n2))
p42v (list (- (car p4v) n5)(- (cadr p4v) n2))
p_42v (list (car p42v)(- (cadr p42v) n2))
text_1 (rtos beg_y 2 0)
text_2 (rtos (+ beg_y dist_y) 2 0)
text_3 (rtos beg_x 2 0)
text_4 (rtos (+ beg_x dist_x) 2 0)
)
(setq l1 (strlen text_1)
l2 (strlen text_2)
l3 (strlen text_3)
l4 (strlen text_4)
)
(cond ((= l1 3)(setq text_1 (strcat "000" text_1)))
((= l1 4)(setq text_1 (strcat "00" text_1)))
((= l1 5)(setq text_1 (strcat "0" text_1)))
)
(cond ((= l2 3)(setq text_2 (strcat "000" text_2)))
((= l2 4)(setq text_2 (strcat "00" text_2)))
((= l2 5)(setq text_2 (strcat "0" text_2)))
)
(cond ((= l3 3)(setq text_3 (strcat "000" text_3)))
((= l3 4)(setq text_3 (strcat "00" text_3)))
((= l3 5)(setq text_3 (strcat "0" text_3)))
)
(cond ((= l4 3)(setq text_4 (strcat "000" text_4)))
((= l4 4)(setq text_4 (strcat "00" text_4)))
((= l4 5)(setq text_4 (strcat "0" text_4)))
)
(setq text11 (substr text_1 1 3)
text12 (substr text_1 4 3)
text21 (substr text_2 1 3)
text22 (substr text_2 4 3)
text31 (substr text_3 1 3)
text32 (substr text_3 4 3)
text41 (substr text_4 1 3)
text42 (substr text_4 4 3)
)
(repeat 2
(command "text" p11g n3 0.0 text11 )
(command "text" p12g n3 0.0 text12 )
(command "text" p41g n3 0.0 text21 )
(command "text" p42g n3 0.0 text22 )
(command "text" p11v n3 270.0 text31 )
(command "text" p12v n3 270.0 text32 )
(command "text" p41v n3 270.0 text31 )
(command "text" p42v n3 270.0 text32 )
(setq p11g (list (+ (car p11g) dist_x n19) (cadr p11g))
p12g (list (+ (car p12g) dist_x n19) (cadr p12g))
p41g (list (+ (car p41g) dist_x n19) (cadr p41g))
p42g (list (+ (car p42g) dist_x n19) (cadr p42g))
p11v (list (+(car p11v) dist_x) (cadr p11v))
p12v (list (+(car p12v) dist_x) (cadr p12v))
p41v (list (+(car p41v) dist_x) (cadr p41v))
p42v (list (+(car p42v) dist_x) (cadr p42v))
text31 text41
text32 text42
)
)
; -----------------------------------------------------------
(setq p1v (list b15x b15y)
p2v (list dx15 b15y)
p3v (list dx15 dy15)
p4v (list b15x dy15)
)
(command "layer" "set" "1202" "")
(command "pline" p1v "w" 0.32 "" p2v p3v p4v p1v "")
; ----------------------------------------------------------
(setq pt1 (list beg_x (+ beg_y inter))
pt2 (list (- beg_x n1) (+ beg_y inter))
pt3 (list (+ beg_x inter) beg_y)
pt4 (list (+ beg_x inter) (- beg_y n1))
)
(setq pt1a (list (+ (car pt1) dist_x n1)(cadr pt1))
pt2a (list (+ (car pt2) dist_x n1)(cadr pt2))
pt3a (list (car pt3)(+ (cadr pt3) dist_y n1))
pt4a (list (car pt4)(+ (cadr pt4) dist_y n1))
)
(command "layer" "set" "1208" "")
(command "pline" pt1 "w" 0.0 "" pt2 "")
(command "pline" pt1a pt2a "")
(command "pline" pt3 pt4 "")
(command "pline" pt3a pt4a "")
(setq coor1 beg_x)
(repeat n_x
(setq p_11v (list (+ (car p_11v) inter)(cadr p_11v))
p_12v (list (+ (car p_12v) inter)(cadr p_12v))
p_41v (list (+ (car p_41v) inter)(cadr p_41v))
p_42v (list (+ (car p_42v) inter)(cadr p_42v))
coor1 (rtos (+ coor1 inter) 2 0)
)
(setq l (strlen coor1))
(cond ((= l 3)(setq coor1 (strcat "000" coor1)))
((= l 4)(setq coor1 (strcat "00" coor1)))
((= l 5)(setq coor1 (strcat "0" coor1)))
)
(setq t_1 (substr coor1 1 3)
t_2 (substr coor1 4 3)
pt3 (list (+ (car pt3) inter)(cadr pt3))
pt4 (list (+ (car pt4) inter)(cadr pt4))
pt3a (list (+ (car pt3a) inter)(cadr pt3a))
pt4a (list (+ (car pt4a) inter)(cadr pt4a))
)
(command "text" p_11v n25 270.0 t_1 )
(command "text" p_12v n25 270.0 t_2 )
(command "text" p_41v n25 270.0 t_1 )
(command "text" p_42v n25 270.0 t_2 )
(setq coor1 (atof coor1))
(command "pline" pt3 pt4 "")
(command "pline" pt3a pt4a "")
)
(setq coor1 beg_y
p_41g (list (+ (car p_41g) dist_x n17)(- (cadr p_41g) dist_y))
p_42g (list (+ (car p_42g) dist_x n17)(- (cadr p_42g) dist_y))
)
(repeat n_y
(setq p_11g (list (car p_11g) (+ (cadr p_11g) inter))
p_12g (list (car p_12g) (+ (cadr p_12g) inter))
p_41g (list (car p_41g) (+ (cadr p_41g) inter))
p_42g (list (car p_42g) (+ (cadr p_42g) inter))
coor1 (rtos (+ coor1 inter) 2 0)
)
(setq l (strlen coor1))
(cond ((= l 3)(setq coor1 (strcat "000" coor1)))
((= l 4)(setq coor1 (strcat "00" coor1)))
((= l 5)(setq coor1 (strcat "0" coor1)))
)
(setq t_1 (substr coor1 1 3)
t_2 (substr coor1 4 3)
pt1 (list (car pt1)(+ (cadr pt1) inter))
pt2 (list (car pt2)(+ (cadr pt2) inter))
pt1a (list (car pt1a)(+ (cadr pt1a) inter))
pt2a (list (car pt2a)(+ (cadr pt2a) inter))
)
(command "text" p_11g n25 0.0 t_1 )
(command "text" p_12g n25 0.0 t_2 )
(command "text" p_41g n25 0.0 t_1 )
(command "text" p_42g n25 0.0 t_2 )
(setq coor1 (atof coor1))
(command "pline" pt1 pt2 "")
(command "pline" pt1a pt2a "")
)
; ----------------------------------------------------------
(setvar "cmdecho" 1)
(redraw)
(command "zoom" "e")
)
; ----------------------------------------------------------