Lisp tính diện tích cho dân Cầu đường

Thứ Bảy, ngày 06 tháng 9 năm 2008

------------------------------
(DEFUN C:DTL() ;(Chuong trinh doi ty le ban ve);
(setq Ty_le_N (getreal "\nHorizontal Drawing scale : "))
(setq He_so (/ 1000 Ty_le_N))
(setq Ty_le_D (getreal "\nVertical Drawing scale : "))
(setq He_so1 (/ 1000 Ty_le_D))
(setq He_so2 (* He_so He_so1))
)
------------------------------

(defun c:DT1() ;(chương trình tính diện tích);
(if (= Ty_le_N nil) (progn
(setq Ty_le_N (getreal "\nHorizontal Drawing scale : "))
(setq He_so (/ 1000 Ty_le_N))
(setq Ty_le_D (getreal "\nVertical Drawing scale : "))
(setq He_so1 (/ 1000 Ty_le_D))
(setq He_so2 (* He_so He_so1))
)
)
(if (= vol nil) (progn
(setq vol (getreal "\nAll Quanttities(1) or Half(2): "))
)
)
(setq dtl 0)
(setq ss (ssadd))
(setq oslast (getvar "OSMODE"))
(command "osnap" "")
(print)
(print)
(setq pt1 (getpoint "\nPick internal point : "))
(while (/= pt1 nil)
(command "-boundary" pt1 "")
(setq et (entlast))
(ssadd et ss)
(command "area" "e" "last")
(setq vsize ( /(getvar "VIEWSIZE") 300 ))
(command "hatch" "ANSI31" vsize "0" "last" "")
(setq et (entlast))
(ssadd et ss)
(setq dtcon (getvar "AREA"))
(setq dtl (+ dtcon dtl))
(print)
(print)
(setq pt1 (getpoint "\nPick internal point : "))
)
(command "setvar" "OSMODE" oslast)
(command "erase" ss "")
(setq ss nil)
(command "redraw")
(setq dtl (/ (/ dtl He_so2) vol))
; (setq pt2 (getpoint "\nChon diem ghi ra : "))
; (command "text" "J" "M" pt2 2 0 (rtos dtl 2 2))
; (setq pt3 (rtos dtl 2 2))
; (while (null (setq pt5 (entsel "\nChon so ghi can sua:"))))
; (setq dt (entget (car pt5)))
; (setq loai (cdr (assoc 0 dt)))
; (if (= dtl "TEXT")

(progn
(setq pt3 (rtos dtl 2 2))
(setq pt5 (entsel "\nChon so ghi can sua :"))
(initget 0)
(if (null pt5)

(progn
(setq pt6 (getpoint "\nChon diem de the ghi : " ))
(command "text" "J" "M" pt6 0.2 "0" pt3)
)
(progn
(setq dt (entget (car pt5)))
(setq loai (cdr (assoc 0 dt)))
(command ".change" pt5 "" "" "" "" (cdr (assoc 40 dt)) "" pt3)
(command ".change" pt5 "" "P" "C" "7" "")
)
)
)
; (print)
; (prompt (strcat "\nTotal area : " (rtos dTy_le 2 4)))
; (print)
; (setq pt2 (getpoint "\nPoint to write: "))
; (command "text" pt2 "" "0" (rtos dtl 2 2))
);defun
------------------------------
(DEFUN C:TCD() ;(Chuong trinh tim cao do);
(if (= Ty_le_N nil) (progn
(setq Ty_le_N (getreal "\nHorizontal Drawing scale : "))
(setq He_so (/ 1000 Ty_le_N))
(setq Ty_le_D (getreal "\nVertical Drawing scale : "))
(setq He_so1 (/ 1000 Ty_le_D))
(setq He_so2 (* He_so He_so1))
)
)
(command "_layer" "new" "Text" "color" "white" "Text" "")
(setvar "REGENMODE" 0)
(setvar "CMDECHO" 0)
(setq cu (getvar "OSMODE"))
(Command "-osnap" "INT")
(Command "UCS" "W")
; (initget 129 "Y N")
; (setq dk (getkword "\nCo lay cao do o vi tri bat ky?:"))
; (if (= dk "Y")
(progn
(setq OO1 (getpoint "\nPick diem lay cao do: "))
(setq Xt (car OO1)
Yt (cadr OO1)
XOY (list Xt Yt)
))
; (progn
; (setq OO (getpoint "\nPick tim duong thiet ke : "))
; (setq
; XOY (List (car OO) (- (cadr OO) (* 0.25 He_so)))
; Xt (car XOY)
; Yt (cadr XOY)
; ))
; )
(setvar "OSMODE" 0)
(Command "UCS" "O" XOY)
(setq text (car (nentsel "\nChon cao do TKe :")))
(Command "-osnap" "INT,END")
(setq k (getpoint "\nChon diem tim cao do :"))
(while (/= text nil)
(progn
(setq st2 (entget text)) ;;hien thi record doi tuong
(setq st (cdr (assoc 1 st2))) ;;Lay noi dung text:ma DXF=1
(setq cdotim (atof st)
tim (getpoint "\ndiem dat :")
tim (list (car tim) (+ (cadr tim) 0.15))
Xt (/ (car k) he_so)
Yt (+ (/ (cadr k) he_so) cdotim)
gtr (rtos yt 2 2)
; h 0.18
h (* he_so 0.18)
)
(Command "_layer" "set" "text" "")
; (Command "text" tim h "0" gtr "")
; (command "_layer" "set" "0" "")
(Command "-osnap" "NONE")
(Command "text" "J" "ML" tim h "0" gtr "")
(princ "\n Khoang cach tu Tim: ")
(prin1 Xt)
(Command "-osnap" "INT,END")
(setq k (getpoint "\nChon diem tim cao do tiep theo :" ))
(princ)
))
(setvar "OSMODE" cu)
(princ)
)
------------------------************-------------------
(DEFUN C:KCa() ;(Chuong trinh viet K/C le);
(if (= Ty_le_N nil) (progn
(setq Ty_le_N (getreal "\nHorizontal Drawing scale : "))
(setq He_so (/ 1000 Ty_le_N))
(setq Ty_le_D (getreal "\nVertical Drawing scale : "))
(setq He_so1 (/ 1000 Ty_le_D))
(setq He_so2 (* He_so He_so1))
)
)
(setvar "REGENMODE" 0)
(setvar "CMDECHO" 0)
(setq cu (getvar "OSMODE"))
(Command "-osnap" "MID")
(setq Chan (getpoint "\nChon diem dat TEXT :"))
(setq Ych (- (cadr Chan) 0.0) )
(Command "-osnap" "END")
(setq A1 (getpoint "\nChon diem thu nhat :")
A2 (getpoint "\nChon diem thu 2 :")
ht 0.4
; ht (/ he_so 2.5)
)
(While (/= A2 nil)
(progn
(setq Xa1 (car A1)
Xa2 (car A2)
Tb (/ (+ Xa1 Xa2) 2)
Dat (list Tb Ych)
DISS (/ (abs (- Xa1 Xa2)) He_so)
DIS (rtos DISS 2 2)
)
----------
(if (< DISS 1)
(setq Ang 90)
(setq Ang 0)
)
-----------
(Command "-osnap" "")
(Command "text" "J" "M" Dat ht Ang DIS)
)
(Command "-osnap" "END")
(setq A1 (getpoint "\nChon diem thu nhat :")
A2 (getpoint "\nChon diem thu 2 :"))
)
(setvar "OSMODE" cu)
(princ)
)
---------------------********-----------------------
(defun C:SCC () ;Chuong trinh sua lai do doc mat duong
(if (= Ty_le_N nil) (progn
(setq Ty_le_N (getreal "\nHorizontal Drawing scale : "))
(setq He_so (/ 1000 Ty_le_N))
(setq Ty_le_D (getreal "\nVertical Drawing scale : "))
(setq He_so1 (/ 1000 Ty_le_D))
(setq He_so2 (* He_so He_so1))
)
)
(setq st1 (car (entsel "\nPick cao do thu nhat : "))) ;;Lay ma doi tuong
(setq st1 (entget st1)) ;;hien thi record doi tuong
(setq st (cdr (assoc 1 st1))) ;;Lay noi dung text:ma DXF=1
(setq a1 (atof st))
(prin1 a1)
(setq st2 (car (entsel "\nPick cao do thu hai: "))) ;;Lay ma doi tuong
(setq st2 (entget st2)) ;;hien thi record doi tuong
(setq st (cdr (assoc 1 st2))) ;;Lay noi dung text:ma DXF=1
(setq a2 (atof st))
(prin1 a2)
(setq kc (atof (cdr (assoc 1 (entget (car (entsel "\nPick K/C :")))))))
(print kc)
(setq sc (* 100 (/ (- a1 a2) kc))
sc (rtos sc 2 2)
sc (strcat sc "%")
)
(setq en (car (entsel "\nThay cho do doc ngang : ")))
(setq elst (entget en))
(setq elst (subst (cons 1 (strcat " " sc)) (assoc 1 elst) elst))
(setq elst (append elst '((62 . 3))));7 trang
(prin1 elst)
(entmod elst)
)
-----------------------***********----------------------
(Defun C:ddan() ;CT VIET DUONG DAN CUA BAN VE
(setvar "REGENMODE" 0)
(setvar "CMDECHO" 0)
(setq last (getvar "OSMODE"))
(Command "-osnap" "END")
(if (= TEN nil) (setq TEN (getstring "\nMay cua ai: ")))
(setq NAME (getvar "dwgname")
PATH (getvar "dwgprefix")
POINT (getpoint "\nPick Bottum_Letf :")
POINT (list (- (car POINT) 3) (cadr POINT))
ND (strcat "TCI-PTKD-" TEN " FILE: " PATH NAME)
)
(Command "_layer" "set" "0" "")
(Command "-osnap" "NONE")
(Command "Text" POINT "2.0" "90" ND)
(setvar "OSMODE" last)
(princ)
)
------------------------------------------------

(DEFUN XD ()
(SETQ CMD (GETVAR "CMDECHO"))
(SETVAR "CMDECHO" 0)
(COMMAND "UCS" "W")
(SETVAR "CMDECHO" 1)
(PROMPT"\nSelect vertical dimension(s) extensions to be aligned")
(SETQ SET (SSGET))
(PROMPT"\nSelect new extension position")
(SETQ P1 (GETPOINT))
(SETQ X3 (CAR P1))
(SETQ QUANT (SSLENGTH SET))
(SETQ INDEX 0)
(WHILE (< INDEX QUANT)
(IF (AND(= "DIMENSION" (CDR (ASSOC 0 (SETQ A (ENTGET (SSNAME SET INDEX))))))
)
(PROGN
(SETQ L13 (ASSOC 13 A))
(SETQ M13 (CDR L13))
(SETQ L14 (ASSOC 14 A))
(SETQ M14 (CDR L14))
(SETQ P13 (LIST 13 X3 (CADR M13) (CADDR M13)))
(SETQ P14 (LIST 14 X3 (CADR M14) (CADDR M14)))
(SETQ A (SUBST P13 L13 A))
(SETQ A (SUBST P14 L14 A))
(ENTMOD A)
)
)
(SETQ INDEX (+ INDEX 1))
)
(SETVAR "CMDECHO" 0)
(COMMAND "UCS" "P")
(SETVAR "CMDECHO" CMD)
(PRINC)
)
(DEFUN C:XD () (XD) )
(DEFUN C:XX () (XD) )
(DEFUN C:SDD () (XD) )
--------------------------------------
(DEFUN YD ()
(SETQ CMD (GETVAR "CMDECHO"))
(SETVAR "CMDECHO" 0)
(COMMAND "UCS" "W")
(SETVAR "CMDECHO" 1)
(PROMPT"\nSelect dimension(s) to be aligned")
(SETQ SET (SSGET))
(PROMPT"\nSelect new dimension position")
(SETQ P1 (GETPOINT))
(SETQ Y3 (CADR P1))
(SETQ QUANT (SSLENGTH SET))
(SETQ INDEX 0)
(WHILE (< INDEX QUANT)
(IF (AND(= "DIMENSION" (CDR (ASSOC 0 (SETQ A (ENTGET (SSNAME SET INDEX))))))
)
(PROGN
(SETQ L13 (ASSOC 13 A))
(SETQ M13 (CDR L13))
(SETQ L14 (ASSOC 14 A))
(SETQ M14 (CDR L14))
(SETQ P13 (LIST 13 (CAR M13) Y3 (CADDR M13)))
(SETQ T13 (CDR P13))
(SETQ P14 (LIST 14 (CAR M14) Y3 (CADDR M14)))
(SETQ A (SUBST P13 L13 A))
(SETQ A (SUBST P14 L14 A))
(ENTMOD A)
)
)
(SETQ INDEX (+ INDEX 1))
)
(SETVAR "CMDECHO" 0)
(COMMAND "UCS" "P")
(SETVAR "CMDECHO" CMD)
)
(DEFUN C:YD () (YD) )
(DEFUN C:YY () (YD) )
(DEFUN C:SDN () (YD) )
-------------------------------------
(DEFUN YD ()
(SETQ CMD (GETVAR "CMDECHO"))
(SETVAR "CMDECHO" 0)
(COMMAND "UCS" "W")
(SETVAR "CMDECHO" 1)
(PROMPT"\nChon dim can cat")
(SETQ SET (SSGET))
(PROMPT"\nChon vi tri cat")
(SETQ P1 (GETPOINT))
(SETQ Y3 (CADR P1))
(SETQ QUANT (SSLENGTH SET))
(SETQ INDEX 0)
(WHILE (< INDEX QUANT)
(IF (AND(= "DIMENSION" (CDR (ASSOC 0 (SETQ A (ENTGET (SSNAME SET INDEX))))))
)
(PROGN
(SETQ L13 (ASSOC 13 A))
(SETQ M13 (CDR L13))
(SETQ L14 (ASSOC 14 A))
(SETQ M14 (CDR L14))
(SETQ P13 (LIST 13 (CAR M13) Y3 (CADDR M13)))
(SETQ T13 (CDR P13))
(SETQ P14 (LIST 14 (CAR M14) Y3 (CADDR M14)))
(SETQ A (SUBST P13 L13 A))
(SETQ A (SUBST P14 L14 A))
(ENTMOD A)
)
)
(SETQ INDEX (+ INDEX 1))
)
(SETVAR "CMDECHO" 0)
(COMMAND "UCS" "P")
(SETVAR "CMDECHO" CMD)
)
(DEFUN C:YD () (YD) )
(DEFUN C:ww () (YD) )
(DEFUN C:SDN () (YD) )
------------------------
(load "C:/acad.lsp")
(load "C:/catdoc.lsp")
(load "C:/loadhet.lsp")

0 nhận xét: