Тема: Профиль для исполнительных
Вот, написал код для построения продольного профиля теплосети (впрочем подойдет для любого профиля). Исходными данными являются результаты тахеометрической съемки, т. е. точки с определеннными координатами и высотой.
; (defun dtr (a) (* pi (/ a 180.0)) ) (defun C:pro (/ dz ucs osn txt p pt1 pt2 ppt1 ppt2 tdis uk) (setq dz (getvar "DIMZIN")) (setvar "DIMZIN" 0) (setvar "CMDECHO" 0) (setq ucs (getpoint "\n Укажите точку где строить профиль: ")) (command "_UCS" ucs "") (setq osn (getvar "OSMODE")) (setvar "OSMODE" 0) ;Рисуем табличку (command "_rectang" '(0 0) '(85 10)) (setq txt (substr " Покрытие" 1)) (command "_TEXT" "_ML" '(0 5) 3.5 "0" txt) (command "_rectang" '(0 20) '(85 10)) (setq txt (substr " Тип прокладки" 1)) (command "_TEXT" "_ML" '(0 15) 3.5 "0" txt) (command "_rectang" '(0 20) '(85 40)) (setq txt (substr " План трассы" 1)) (command "_TEXT" "_ML" '(0 30) 3.5 "0" txt) (command "_rectang" '(0 50) '(85 40)) (command "_PLINE" '(0 50) '(85 40) "") (setq txt (substr " Длина участка" 1)) (command "_TEXT" "_ML" '(0 43) 3.5 "0" txt) (setq txt (substr "Уклон " 1)) (command "_TEXT" "_MR" '(85 47) 3.5 "0" txt) (command "_rectang" '(0 50) '(85 60)) (setq txt (substr " Расстояние" 1)) (command "_TEXT" "_ML" '(0 55) 3.5 "0" txt) (command "_rectang" '(0 70) '(85 60)) (setq txt (substr " Глубина до верха канала" 1)) (command "_TEXT" "_ML" '(0 65) 3.5 "0" txt) (command "_rectang" '(0 70) '(85 80)) (setq txt (substr " Глубина заложения низа канала" 1)) (command "_TEXT" "_ML" '(0 75) 3.5 "0" txt) (command "_rectang" '(0 80) '(8 140)) (setq txt (substr "Отметки" 1)) (command "_TEXT" "_MC" '(4 110) 3.5 "90" txt) (command "_rectang" '(8 80) '(85 95)) (setq txt (substr " Осей труб" 1)) (command "_TEXT" "_ML" '(8 87.5) 3.5 "0" txt) (command "_rectang" '(8 110) '(85 95)) (setq txt (substr " Низа канала или дна траншеи" 1)) (command "_TEXT" "_ML" '(8 102.5) 3.5 "0" txt) (command "_rectang" '(8 110) '(85 125)) (setq txt (substr " Верха канала или верха труб" 1)) (command "_TEXT" "_ML" '(8 117.5) 3.5 "0" txt) (command "_rectang" '(8 140) '(85 125)) (setq txt (substr " Планировки" 1)) (command "_TEXT" "_ML" '(8 132.5) 3.5 "0" txt) (command "_rectang" '(0 140) '(85 150)) (setq txt (substr " Номера точек" 1)) (command "_TEXT" "_ML" '(0 145) 3.5 "0" txt) (command "_PLINE" (setq p '(80 150)) (setq p (polar p (dtr 90) 5)) (setq p (polar p (dtr 180) 15)) "" ) (command "_PLINE" (setq p '(80 150)) (setq p (polar p (dtr 45) 4)) "" ) (setq p (entlast)) (command "_MIRROR" p "" '(80 150) '(80 151) "") (setq p (getstring "\n Условный горизонт:")) (command "_TEXT" '(66 156) 3.5 "0" p) (setq p (atof p)) (setq txt (substr "М гор. 1:500" 1)) (command "_TEXT" '(30 160) 3.5 "0" txt) (setq txt (substr "М вер. 1:100" 1)) (command "_TEXT" '(30 154.5) 3.5 "0" txt) (command "_UCS" '(110 0) "") (setvar "OSMODE" 8) (setvar "PDMODE" 35) (setvar "PDSIZE" 1) (setq pt1 (getpoint "\n Укажите точку : ")) (setq pt1 (trans pt1 1 0)) (command "_PLINE" (list 0 150) (list 0 (+ 150 (* (- (last pt1) p) 10))) "" ) (command "_TEXT" "_BC" (list 0 87.5) 3.5 "90" (rtos (last pt1) 2 2) ) (while (setq pt2 (getpoint "\n Укажите точку (ENTER = хватит): ")) (setq pt2 (trans pt2 1 0)) (setq ppt1 (list (car pt1) (cadr pt1) 0)) (setq ppt2 (list (car pt2) (cadr pt2) 0)) (setq tdis (distance ppt1 ppt2)) (setq uk (/ (- (last pt1) (last pt2)) tdis)) (setvar "OSMODE" 0) ; строим прямоугольники (command "_rectang" (list 0 140) "_D" (* tdis 2) 10 (list 1 140) ) (command "_rectang" (list 0 125) "_D" (* tdis 2) 15 (list 1 125) ) (command "_rectang" (list 0 110) "_D" (* tdis 2) 15 (list 1 110) ) (command "_rectang" (list 0 95) "_D" (* tdis 2) 15 (list 1 95) ) (command "_rectang" (list 0 80) "_D" (* tdis 2) 15 (list 1 80) ) ; пишем отметку оси (command "_TEXT" "_BC" (list (* tdis 2) 87.5) 3.5 "90" (rtos (last pt2) 2 2) ) ; написали (command "_rectang" (list 0 70) "_D" (* tdis 2) 10 (list 1 70) ) (command "_rectang" (list 0 60) "_D" (* tdis 2) 10 (list 1 60) ) ; пишем длину (command "_TEXT" "_BC" (list tdis 52) 3.5 "0" (rtos tdis 2 2) ) ; написали (command "_rectang" (list 0 50) "_D" (* tdis 2) 10 (list 1 50) ) ; рисуем направление уклона (if (> uk 0) (command "_PLINE" (list 0 50) (list (* tdis 2) 40) "") (command "_PLINE" (list 0 40) (list (* tdis 2) 50) "") ) ;if (if (= uk 0) (command "_erase" (entlast) "") ) ; нарисовали ; пишем уклон и длину (if (= uk 0) (progn (command "_TEXT" "_BC" (list tdis 44.13) 3.5 "0" (substr "0.000" 1) ) (command "_TEXT" "_BC" (list tdis 40.13) 3.5 "0" (rtos tdis 2 2) ) ) ;progn (progn (if (> uk 0) (progn (command "_TEXT" "_MR" (list (- (* tdis 2) 1) 46) 3.5 "0" (rtos (abs uk) 2 4) ) (command "_TEXT" "_ML" (list 1 44) 3.5 "0" (rtos tdis 2 2)) ) ;progn (progn (command "_TEXT" "_Ml" (list 1 46) 3.5 "0" (rtos (abs uk) 2 4) ) (command "_TEXT" "_MR" (list (- (* tdis 2) 1) 44) 3.5 "0" (rtos tdis 2 2) ) ) ;progn ) ;if ) ;progn ) ;if ; написали (command "_rectang" (list 0 40) "_D" (* tdis 2) 10 (list 1 40) ) (command "_rectang" (list 0 20) "_D" (* tdis 2) 20 (list 1 20) ) (command "_rectang" (list 0 10) "_D" (* tdis 2) 10 (list 1 10) ) (command "_rectang" (list 0 0) "_D" (* tdis 2) 10 (list 1 0) ) ;построили ;рисуем линии профиля (command "_PLINE" (list 0 (+ 150 (* (- (last pt1) p) 10))) "_W" 0.6 0.6 (list (* tdis 2) (+ 150 (* (- (last pt2) p) 10))) "" ) (command "_PLINE" (list (* tdis 2) 150) "_W" 0 0 (list (* tdis 2) (+ 150 (* (- (last pt2) p) 10))) "" ) ;нарисовали (command "_UCS" (list (* tdis 2) 0) "") (print tdis) (print uk) (setq pt1 pt2) (setvar "OSMODE" 8) ) ; while (command "_UCS" "_W") (setvar "OSMODE" osn) (setvar "DIMZIN" dz) (princ) ) ; defun