Chuyển đến nội dung
Diễn đàn CADViet
  • Thông báo

    • Nguyen Hoanh

      CADViet đã hoàn tất nâng cấp   14/09/2017

      Chào các bạn, CADViet đã hoàn tất việc nâng cấp lên phiên bản mới. Tất cả các chức năng đã hoạt động theo kỳ vọng của ban quản trị. Nếu có vấn đề gì cần phản hồi, các bản post ở đây nhé: Trân trọng, Nguyễn Hoành.
chuongduong

xin lisp san nền

Các bài được khuyến nghị

amosis    4

Mình có xin được lisp của anh Sáu rất hay đang sử dụng cho công việc nhưng hiện tại lưới khi nhập vào là lưới ô vuông tức là chỉ nhập vào 1 số 10m chẳng hạn,

giờ mình muốn nhập lưới hình chữ nhật 10mx20m hoặc lưới tam giác, nhờ các bác giúp đỡ

 

 

 

;tao layer cho ban ve
(defun c:khsn ()
 (command ".layer" "n" "sn-luoi o vuong" "c" "8" "sn-luoi o vuong" ""
      ".layer" "n" "sn-STT o luoi" "c" "120" "sn-STT o luoi" ""
      ".style" "text" "VNI-Helve" "" "" "" "" "" ""
      ".layer" "n" "sn-vong tron o luoi" "c" "1" "sn-vong tron o luoi" ""
      	".layer" "n" "sn-DTdap" "c" "210" "sn-DTdap" ""
      ".Layer" "n" "sn-CDTK" "c" "1" "sn-CDTK" ""
      ".layer" "n" "sn-CD Trung binh" "c" "30" "sn-CD trung binh" ""
      ".Layer" "n" "sn-CDTCdao" "c" "4" "sn-CDTCdao" ""
      ".Layer" "n" "sn-CDTCdap" "c" "2" "sn-CDTCdap" ""
      ".layer" "n" "sn-KLuongdap" "c" "42" "sn-KLuongdap" ""
      ".Layer" "n" "sn-CDTN" "c" "3" "sn-CDTN" ""
      )
 (command ".layer" "n" "sn-KLuongdao" "c" "91" "sn-KLuongdao" ""
        ".layer" "n" "sn-CD Trung binh" "c" "30" "sn-CD trung binh" ""
        ".layer" "n" "sn-KLuongdap" "c" "241" "sn-KLuongdap" ""
        ".layer" "n" "sn-DTdao" "c" "151" "sn-DTdao" ""
        )  
 (command ".layer" "n" "THop-KLuongdao" "c" "91" "THop-KLuongdao" ""
      ".layer" "n" "THop-KLuongdap" "c" "241" "THop-KLuongdap" ""
      ".layer" "n" "THop-DTdap" "c" "210" "THop-DTdap" ""
      ".layer" "n" "THop-DTdao" "c" "151" "THop-DTdao" ""
          ;".layer" "n" "THop-KLuongdao" "c" "7" "THop-KLuongdao" ""
      ;".layer" "n" "THop-KLuongdap" "c" "7" "THop-KLuongdap" ""
      ;".layer" "n" "THop-DTdap" "c" "7" "THop-DTdap" ""
      ;".layer" "n" "THop-DTdao" "c" "7" "THop-DTdao" ""
      ".layer" "n" "THop-DThang" "c" "2" "THop-DThang" ""
      ".layer" "n" "THop-TEXT" "c" "7" "THop-TEXT" ""
      ".layer" "n" "sn-ranhgioidaodap" "c" "91" "sn-ranhgioidaodap"""
      )
 (princ)
 )
;danh so thu tu o luoi
(defun TTOL ()
 (setvar "cmdecho" 0)  
 (setq SS (ssget '((0 . "text") (8 . "sn-STT o luoi")))
LS (sslength SS)
)
 (setq N 0)
 (setq M LS)
 (setq CDD (getstring "\nChu so dung dau (tien to):"))
 (repeat LS
   ;lay ra ma doi tuong
   (setq MDT (entget (ssname SS N)))
   ;lay ra gia tri text
   (setq TEXT1 (assoc 1 MDT))
   (setq STT1 (strcat CDD (rtos M 2 0)))
   ;danh so thu tu
   (setq STT (subst (cons 1 STT1) TEXT1 MDT))
   (setq N (1+ N))
   (setq M (1- M))
   ;cap nhat lai ma doi tuong
   (entmod STT)
   )  
 (princ)
 )
***************************************
;them dau tru "-" vao o trong ranh gio dao va them bat ky vao dau text
(defun themtext ()	;
 (setvar "cmdecho" 0)  
 (setq SS (ssget '((0 . "text")))
LS (sslength SS)
)
 (setq N 0)
 (setq CDD (getstring "\nThem gi:"))
 (repeat LS
   ;lay ra ma doi tuong
   (setq MDT (entget (ssname SS N)))
   ;lay ra gia tri text
   (setq TEXT1 (assoc 1 MDT))
   (setq TEXT2 (cdr TEXT1))
   (setq STT1 (strcat CDD TEXT2))
   (setq STT (subst (cons 1 STT1) TEXT1 MDT))
   (setq N (1+ N))
	;cap nhat lai ma doi tuong
   (entmod STT)
   )
 (princ)
 )
******************************************
;ve o luoi san nen
(defun vol () ;vol:Ve o luoi
 (setvar "cmdecho" 0)
 (setvar "orthomode" 0)
 (setvar "gridmode" 0)
 (setvar "snapmode" 0)
 (setvar "osmode" 0)  
 ;vao hai diem
 (setq pt1 (getpoint "\nChon diem thu nhat: ")
pt2 (getcorner pt1 "\nChon diem thu hai: ")
)
 (setq ktol (getint "\nKich thuoc o luoi: ")) ;ktol:kich thuoc o luoi
 ;lay ra toa do hai diem
 (setq pt1_x (car pt1)
pt1_y (cadr pt1)
pt2_x (car pt2)
pt2_y (cadr pt2)
)
 ;tao cac diem moi de ve o luoi
 (setq pt3 (polar pt1 0 (- pt2_x pt1_x))
)
 ;xac dinh bao nhieu line trong o luoi
 (setq ln (distance pt3 pt1)	;chieu dai toan bo luoi theo phuong ngang
ld (distance pt2 pt3)	;chieu dai toan bo luoi theo phuong dung
sln (fix (/ ln ktol))	;so duong thang theo phuong ngang
sld (fix (/ ld ktol))	;so duong thang theo phuong dung
)
 (setq pt4 (polar pt1 0 (* ktol sln))
pt5 (polar pt4 (/ pi 2) (* ktol sld))
)
 (command ".layer" "s" "sn-luoi o vuong" "")
 (command ".line" pt1 pt4 ""       
      ".array" "l" "" "r" (+ 1 sld) 1 ktol
      ".line" pt4 pt5 ""
      ".array" "l" "" "r" 1 (+ 1 sln) (- ktol)
      )
 ;tinh cac diem trong o luoi
 (setq pt6 (polar pt1 (/ pi 2) (* ktol sld))
pt7 (polar pt6 (/ pi 2) (- (/ ktol 2)))
pt8 (polar pt7 0 (/ ktol 2))
;pt9 pt8
)   
 (repeat sld
   ;ve vong tron khoi luong
   (setq bkol (/ ktol 3.00))	;bkol:ban kinh o luoi
   (command ".layer" "s" "sn-vong tron o luoi" "")
   (command ".circle" pt8 bkol
        ".array" "l" "" "r" 1  sln ktol
      )    
   ;ghi so thu tu o luoi vao o luoi
   (setq htext (/ ktol 14.00))	;chieu cao chu
   (setq pt11 (polar pt8 (/ pi 2) (/ ktol 5.33)))
   (command ".layer" "s" "sn-STT o luoi" "")
   (command ".text" "j" "mc" pt11 htext 0  "STT"
        ".array" "l" "" "r" 1  sln ktol
      )
   ;ve cac doan thang vao o luoi
   (setq ol_ld (/ ktol (* 2 5.00))	;duong thang dung
 	pt12 (polar pt8 (/ pi 2) ol_ld)
 	pt13 (polar pt8 (/ pi 2) (- ol_ld))
 	ol_ln (/ ktol (* 2 1.572427175))
 	pt14 (polar pt12 0 ol_ln)
 	pt15 (polar pt12 0 (- ol_ln))
 	pt16 (polar pt13 0 ol_ln)
 	pt17 (polar pt13 0 (- ol_ln))
 	)
   (command ".layer" "s" "sn-vong tron o luoi" "")
   (command ".line" pt12 pt13 ""
        ".array" "l" "" "r" 1  sln ktol
        ".line" pt14 pt15 ""
        ".array" "l" "" "r" 1  sln ktol
        ".line" pt16 pt17 ""
        ".array" "l" "" "r" 1  sln ktol
        )
   ;dien dien tich o luoi
   (setq pt18 (polar pt8 0 (- (/ ktol 6.289703755))))
   (command ".layer" "s" "sn-DTdap" "")
   (command ".text" "j" "mc" pt18 htext 0 (rtos (* ktol ktol) 2 0)
        ".array" "l" "" "r" 1  sln ktol
        )       
	;doi cuoi thanh dau
   (setq pt10 (polar pt8 (/ pi 2) (- ktol)))
   (setq pt8 pt10)    
   )
 ;(alert "Hay su dung nhung layer duoc tao ra va dung xoa di")
 (princ)
 )

*********************************************
;tinh cao do trung binh
(defun CDTB ()
 (setvar "cmdecho" 0)
 (setvar "orthomode" 0)
 (setvar "gridmode" 0)
 (setvar "snapmode" 0)
 (setvar "osmode" 0)    
 (alert (strcat "Khong chon nhung o luoi thuoc ranh gioi dao dap va cac o le"
    	  	"\nChon nhung o luoi nam hoan toan trong vung dao hoac dap")
    )
 ;kiem tra kich thuoc o luoi
 ;(if ( = ktol nil)
  ; (progn
	; (setq KTOL (getreal "\nKich thuoc o luoi: "))
	; )
   ;)
 (setq SSC (ssget '((0 . "circle") (8 . "sn-vong tron o luoi")))
LSC (sslength SSC)
    )  
 (setq N 0)
 (repeat LSC
	;lay ra ma doi tuong
   (setq MDTC (entget (ssname SSC N))
 	pt_tam (cdr (assoc 10 MDTC)) ;lay ra toa do tam duong tron
 	nol (/ KTOL 2)	;do lon nua o luoi
 	;xac dinh hai diem ben phai     
 	pt19 (polar pt_tam 0 nol)
 	pt20 (polar pt19 (/ pi 2) (- nol))
 	;xac dinh diem ben phai
 	pt21 (polar pt_tam 0 (- (+ nol (* nol 0.8))))
 	pt22 (polar pt21 (/ pi 2) (+ nol (* nol 0.8)))
 	)
   ;tinh cao do trung binh
   (setq CDTB (ssget "w" pt22 pt20 '((0 . "text") (8 . "sn-CDTC*")))
 	SL_CDTB (sslength CDTB)
 	)
   ;cao do thi cong cac diem nut
   (setq CDTC_1 (entget (ssname CDTB 0))
 	CDTC_11 (atof (cdr (assoc 1 CDTC_1)))
 	)
   (setq CDTC_2 (entget (ssname CDTB 1))
 	CDTC_22 (atof (cdr (assoc 1 CDTC_2)))
 	)
   (setq CDTC_3 (entget (ssname CDTB 2))
 	CDTC_33 (atof (cdr (assoc 1 CDTC_3)))
    )
   (setq CDTC_4 (entget (ssname CDTB 3))
 	CDTC_44 (atof (cdr (assoc 1 CDTC_4)))
    )
   ;tinh ra cao do trung binh
   (setq CDTBKq (/ (+ CDTC_11 CDTC_22 CDTC_33 CDTC_44) 4)
 	CDTBKq (atof (rtos CDTBKq 2 2))
 	KLOL (* KTOL KTOL CDTBKq)
 	)
   ;in gia tri
   (setq pt23 (polar pt_tam 0 (/ nol 3.144851877))
 	pt24 (polar pt_tam (/ pi 2) (- (/ nol 2.45)))
 	)    
   (command ".layer" "s" "sn-CD Trung binh" ""
              ".text" "j" "mc" pt23 htext 0 (rtos CDTBKq 2 2)
        )
   (if (< CDTBKq 0)
     (progn
(setq SSdao (ssget "w" pt22 pt20 '((0 . "text") (8 . "sn-DTdap")))
     	dautru "-"	;them dau "-" vao nhung dien tich dao
     	)
(setq MDT (entget (ssname SSdao 0)))
;lay ra gia tri text them dau tru
       (setq TEXT1 (assoc 1 MDT))
       (setq TEXT2 (cdr TEXT1))
       (setq STT1 (strcat dautru TEXT2))
       (setq STT (subst (cons 1 STT1) TEXT1 MDT))
;cap nhat lai ma doi tuong
(entmod STT)    
(command ".layer" "s" "sn-KLuongdao" "")
     )
     (progn    
     (command ".layer" "s" "sn-KLuongdap" "")
     )
     );ket thuc if
   ;chuyen sang layer moi neu CDTBKq <0
   (if (< CDTBKq 0)
     (progn
(setq SSdao1 (ssget "w" pt22 pt20 '((0 . "text") (8 . "sn-DTdap"))))
(setq layer (entget (ssname SSdao1 0)))
(setq CLayer (subst '(8 . "sn-DTdao") (assoc 8 layer) layer))
    ;cap nhat lai ma doi tuong       
(entmod CLayer)
     )
     )

   (command ".text" "j" "mc" pt24 htext 0 (rtos KLOL 2 2)
        )    
   (setq N (1+ N))    
   )
   (princ )   
 )
********************************************
;Lap bang tong hop khoi luong
(defun THKL ()	;THKL:Tong hop khoi luong
 (setvar "cmdecho" 0)
 (setvar "orthomode" 0)
 (setvar "gridmode" 0)
 (setvar "snapmode" 0)
 (setvar "osmode" 0)

 ;khoang cah giua cac dong
 (setq KCDC (* 0.3 ktol))	;KCDC: khoang cach dong chu
 ;lua chon phuong lap bang tong hop
 (initget 1 "Y X")
 (setq plb (getkword "\nBang tong hop dat theo phuong Y hay X ? <Y/X>: "))
 ;tao diem ao cua pt1
 (setq pt1_1 pt1   
)
 (if (= plb "X")
   (progn
     (setq pt23 (polar pt1_1 (/ pi 2) (- (* 0.75 ktol)))
   	pt23_1 (polar pt23 0 (* ktol sln))
   	pt23_2 (polar pt23_1 0 (* 1.5 ktol))
   	pt24 (polar pt23 0 (- (* 2 ktol)))       
   	)
     ;ve duong thang
     (command ".layer" "s" "THop-DThang" ""
          ".line" pt23 pt24 ""
          ".array" "l" "" "r" 5  1 (- KCDC)
          ".line" pt24 (polar pt24 (/ pi 2) (- (* 4 KCDC))) ""
          ".line" pt23 (polar pt23 (/ pi 2) (- (* 4 KCDC))) ""
          ".array" "l" "" "r" 1  (+ 1 sln) ktol
          ".line" pt23 (polar pt23 0 (* ktol sln)) ""
          ".array" "l" "" "r" 5  1 (- KCDC)
          ".line" pt23_1 pt23_2 ""
          ".array" "l" "" "r" 5  1 (- KCDC)
          ".line" pt23_2 (polar pt23_2 (/ pi 2) (- (* 4 KCDC))) ""
          )
     ;tinh diem de dat text dau bang tong hop
     (setq pt25 (polar pt24 (/ pi 2) (- (/ KCDC 2)))
   	pt25_1 (polar pt23_1 (/ pi 2) (- (/ KCDC 2)))
   	pt25_2 (polar pt25_1 0 (* ktol 0.4))
   	pt26 (polar pt25 0 (* ktol 0.245))
   	)
     (command ".layer" "s" "THop-TEXT" ""
          ".text" "j" "ml" pt26 htext 0 "DIEÄN TÍCH ÑAÉP (M2)"
          ".text" "j" "ml" (polar pt26 (/ pi 2) (- KCDC)) htext 0 "DIEÄN TÍCH ÑAØO (M2)"
                ".text" "j" "ml" (polar pt26 (/ pi 2) (- (* 2 KCDC))) htext 0 "KHOÁI LÖÔÏNG ÑAÁT ÑAÉP (M3)"
          ".text" "j" "ml" (polar pt26 (/ pi 2) (- (* 3 KCDC))) htext 0 "KHOÁI LÖÔÏNG ÑAÁT ÑAØO (M3)"
          ".text" "j" "m" pt25_2 htext 90 "M"
          ".array" "l" "" "r" 4  1 (- KCDC)
	)
     ;thu hien vong lap
     (repeat sln
;tinh diem de chon doi tuong
(setq pt27 (polar pt1_1 0 ktol)
   	pt28 (polar pt27 (/ pi 2) (* ktol sld))
   	)
;tinh diem in gia tri
(setq pt29 (polar pt1_1 (/ pi 2) (- (* 0.75 ktol)))
     	pt30 (polar pt29 (/ pi 2) (- (/ KCDC 2)))
     	pt31 (polar pt30 0 (/ ktol 2))
     	)
;tinh dien tich dap
(setq DTdap (ssget "w" pt1_1 pt28 '((0 . "text") (8 . "sn-DTdap"))))
(if (= DTdap nil)     
 	(progn
   	(command ".layer" "s" "THop-DTdap" ""
         ".text" "j" "mc" pt31 htext 0 "00.00"
         )
   	)
 	(progn
   	(setq N 0
  	Tong 0
       SLDTdap (sslength DTdap)
  	)
   	(repeat SLDTdap
     	(setq MDT_DTdap (entget (ssname DTdap N))
    	DTdap_1 (atof (cdr (assoc 1 MDT_DTdap)))
    	)
     	;tinh tong
     	(setq Tong (+ DTdap_1 Tong))
     	(setq N (1+ N))
     	)
   	(command ".layer" "s" "THop-DTdap" ""
         ".text" "j" "mc" pt31 htext 0 (rtos Tong 2 2)
         )
   	)
 	)
;tinh dien tich dao
(setq DTdao (ssget "w" pt1_1 pt28 '((0 . "text") (8 . "sn-DTdao"))))
(if (= DTdao nil)     
 	(progn
   	(command ".layer" "s" "THop-DTdao" ""
         ".text" "j" "mc" (polar pt31 (/ pi 2) (- KCDC)) htext 0 "00.00"
         )
   	)
 	(progn
   	(setq N 0
  	Tong 0
       SLDTdao (sslength DTdao)
  	)
   	(repeat SLDTdao
     	(setq MDT_DTdao (entget (ssname DTdao N))
    	DTdao_1 (atof (cdr (assoc 1 MDT_DTdao)))
    	)
     	;tinh tong
     	(setq Tong (+ DTdao_1 Tong))
     	(setq N (1+ N))
     	)
   	(command ".layer" "s" "THop-DTdao" ""
         ".text" "j" "mc" (polar pt31 (/ pi 2) (- KCDC)) htext 0 (rtos Tong 2 2)
         )
   	)
 	)
;tinh khoi luong dap
(setq KLdap (ssget "w" pt1_1 pt28 '((0 . "text") (8 . "sn-KLuongdap"))))
(if (= KLdap nil)     
 	(progn
   	(command ".layer" "s" "THop-KLuongdap" ""
         ".text" "j" "mc" (polar pt31 (/ pi 2) (- (* 2 KCDC))) htext 0 "00.00"
         )
   	)
 	(progn
   	(setq N 0
  	Tong 0
       SLKLdap (sslength KLdap)
  	)
   	(repeat SLKLdap
     	(setq MDT_KLdap (entget (ssname KLdap N))
    	KLdap_1 (atof (cdr (assoc 1 MDT_KLdap)))
    	)
     	;tinh tong
     	(setq Tong (+ KLdap_1 Tong))
     	(setq N (1+ N))
     	)
   	(command ".layer" "s" "THop-KLuongdap" ""
         ".text" "j" "mc" (polar pt31 (/ pi 2) (- (* 2 KCDC))) htext 0 (rtos Tong 2 2)
         )
   	)
 	)
;tinh khoi luong dao
(setq KLdao (ssget "w" pt1_1 pt28 '((0 . "text") (8 . "sn-KLuongdao"))))
(if (= KLdao nil)     
 	(progn
   	(command ".layer" "s" "THop-KLuongdao" ""
         ".text" "j" "mc" (polar pt31 (/ pi 2) (- (* 3 KCDC))) htext 0 "00.00"
         )
   	)
 	(progn
   	(setq N 0
  	Tong 0
       SLKLdao (sslength KLdao)
  	)
   	(repeat SLKLdao
     	(setq MDT_KLdao (entget (ssname KLdao N))
    	KLdao_1 (atof (cdr (assoc 1 MDT_KLdao)))
    	)
     	;tinh tong
     	(setq Tong (+ KLdao_1 Tong))
     	(setq N (1+ N))
     	)
   	(command ".layer" "s" "THop-KLuongdao" ""
         ".text" "j" "mc" (polar pt31 (/ pi 2) (- (* 3 KCDC))) htext 0 (rtos Tong 2 2)
         )
   	)
 	)
;doi dau thanh cuoi
(setq pt1_1 pt27)
)
;tinh tong cac gia tri dien vao cot cuoi cung
     ;tao diem ao pt23
     (setq pt32 pt23)
     (repeat 2
(setq  pt33 (polar pt32 0 (* ktol sln))
          pt34 (polar pt33 (/ pi 2) (- KCDC))
          pt35 (polar pt33 (/ pi 2) (- (/ KCDC 2)))
          pt36 (polar pt35 0 (/ ktol 2))
          )
(setq sum_all (ssget "w" pt32 pt34 '((0 . "text")))
     	sum_SL (sslength sum_all)
     	)
(setq N 0
     	sum 0
     	)
(repeat sum_SL
 	(setq MDT_sum_all (entget (ssname sum_all N))
    	sum_all_1 (atof (cdr (assoc 1 MDT_sum_all)))
    	)
 	;tinh tong
 	(setq sum (+ sum_all_1 sum))
 	(setq N (1+ N))
 	)
(command ".layer" "s" "THop-TEXT" ""
     ".text" "j" "ml"  pt36 htext 0 (strcat "= "(rtos sum 2 2) " (M2)")
         )
;doi dau thanh cuoi
(setq pt32 (polar pt32 (/ pi 2) (- KCDC)))
)
     (repeat 2
(setq  pt33 (polar pt32 0 (* ktol sln))
          pt34 (polar pt33 (/ pi 2) (- KCDC))
          pt35 (polar pt33 (/ pi 2) (- (/ KCDC 2)))
          pt36 (polar pt35 0 (/ ktol 2))
          )
(setq sum_all (ssget "w" pt32 pt34 '((0 . "text")))
     	sum_SL (sslength sum_all)
     	)
(setq N 0
     	sum 0
     	)
(repeat sum_SL
 	(setq MDT_sum_all (entget (ssname sum_all N))
    	sum_all_1 (atof (cdr (assoc 1 MDT_sum_all)))
    	)
 	;tinh tong
 	(setq sum (+ sum_all_1 sum))
 	(setq N (1+ N))
 	)
(command ".layer" "s" "THop-TEXT" ""
     ".text" "j" "ml"  pt36 htext 0 (strcat "= "(rtos sum 2 2) " (M3)")
         )
;doi dau thanh cuoi
(setq pt32 (polar pt32 (/ pi 2) (- KCDC)))
)    
     )   ;dong progn
   ;da tinh xong khi lap bang theo phuong X
   ;neu lap bang theo phuong Y
   (progn
     (setq pt23 (polar pt1_1 0 (- (* 0.75 ktol)))
   	pt23_1 (polar pt23 (/ pi 2) (* ktol sld))
   	pt23_2 (polar pt23_1 (/ pi 2) (* 1.5 ktol))
   	pt24 (polar pt23 (/ pi 2) (- (* 2 ktol)))       
   	)
     ;ve duong thang
     (command ".layer" "s" "THop-DThang" ""
          ".line" pt23 pt24 ""
          ".array" "l" "" "r" 1  5 (- KCDC)
          ".line" pt24 (polar pt24 0 (- (* 4 KCDC))) ""
          ".line" pt23 (polar pt23 0 (- (* 4 KCDC))) ""
          ".array" "l" "" "r" (+ 1 sld) 1 ktol
          ".line" pt23 (polar pt23 (/ pi 2) (* ktol sld)) ""
          ".array" "l" "" "r" 1  5 (- KCDC)
          ".line" pt23_1 pt23_2 ""
          ".array" "l" "" "r" 1  5 (- KCDC)
          ".line" pt23_2 (polar pt23_2 0 (- (* 4 KCDC))) ""
          )
     ;tinh diem de dat text dau bang tong hop
     (setq pt25 (polar pt24 0 (- (/ KCDC 2)))
   	pt25_1 (polar pt23_1 0 (- (/ KCDC 2)))
   	pt25_2 (polar pt25_1 (/ pi 2) (* ktol 0.4))
   	pt26 (polar pt25 (/ pi 2) (* ktol 0.245))
   	)
     (command ".layer" "s" "THop-TEXT" ""
          ".text" "j" "ml" pt26 htext 90 "DIEÄN TÍCH ÑAÉP (M2)"
          ".text" "j" "ml" (polar pt26 0 (- KCDC)) htext 90 "DIEÄN TÍCH ÑAØO (M2)"
                ".text" "j" "ml" (polar pt26 0 (- (* 2 KCDC))) htext 90 "KHOÁI LÖÔÏNG ÑAÁT ÑAÉP (M3)"
          ".text" "j" "ml" (polar pt26 0 (- (* 3 KCDC))) htext 90 "KHOÁI LÖÔÏNG ÑAÁT ÑAØO (M3)"
          ".text" "j" "m" pt25_2 htext 180 "M"
          ".array" "l" "" "r" 1  4 (- KCDC)
	)
     ;thu hien vong lap
     (repeat sld
;tinh diem de chon doi tuong
(setq pt27 (polar pt1_1 (/ pi 2) ktol)
   	pt28 (polar pt27 0 (* ktol sln))
   	)
;tinh diem in gia tri
(setq pt29 (polar pt1_1 0 (- (* 0.75 ktol)))
     	pt30 (polar pt29 0 (- (/ KCDC 2)))
     	pt31 (polar pt30 (/ pi 2) (/ ktol 2))
     	)
;tinh dien tich dap
(setq DTdap (ssget "w" pt1_1 pt28 '((0 . "text") (8 . "sn-DTdap"))))
(if (= DTdap nil)     
 	(progn
   	(command ".layer" "s" "THop-DTdap" ""
         ".text" "j" "mc" pt31 htext 90 "00.00"
         )
   	)
 	(progn
   	(setq N 0
  	Tong 0
       SLDTdap (sslength DTdap)
  	)
   	(repeat SLDTdap
     	(setq MDT_DTdap (entget (ssname DTdap N))
    	DTdap_1 (atof (cdr (assoc 1 MDT_DTdap)))
    	)
     	;tinh tong
     	(setq Tong (+ DTdap_1 Tong))
     	(setq N (1+ N))
     	)
   	(command ".layer" "s" "THop-DTdap" ""
         ".text" "j" "mc" pt31 htext 90 (rtos Tong 2 2)
         )
   	)
 	)
;tinh dien tich dao
(setq DTdao (ssget "w" pt1_1 pt28 '((0 . "text") (8 . "sn-DTdao"))))
(if (= DTdao nil)     
 	(progn
   	(command ".layer" "s" "THop-DTdao" ""
         ".text" "j" "mc" (polar pt31 0 (- KCDC)) htext 90 "00.00"
         )
   	)
 	(progn
   	(setq N 0
  	Tong 0
       SLDTdao (sslength DTdao)
  	)
   	(repeat SLDTdao
     	(setq MDT_DTdao (entget (ssname DTdao N))
    	DTdao_1 (atof (cdr (assoc 1 MDT_DTdao)))
    	)
     	;tinh tong
     	(setq Tong (+ DTdao_1 Tong))
     	(setq N (1+ N))
     	)
   	(command ".layer" "s" "THop-DTdao" ""
         ".text" "j" "mc" (polar pt31 0 (- KCDC)) htext 90 (rtos Tong 2 2)
         )
   	)
 	)
;tinh khoi luong dap
(setq KLdap (ssget "w" pt1_1 pt28 '((0 . "text") (8 . "sn-KLuongdap"))))
(if (= KLdap nil)     
 	(progn
   	(command ".layer" "s" "THop-KLuongdap" ""
         ".text" "j" "mc" (polar pt31 0 (- (* 2 KCDC))) htext 90 "00.00"
         )
   	)
 	(progn
   	(setq N 0
  	Tong 0
       SLKLdap (sslength KLdap)
  	)
   	(repeat SLKLdap
     	(setq MDT_KLdap (entget (ssname KLdap N))
    	KLdap_1 (atof (cdr (assoc 1 MDT_KLdap)))
    	)
     	;tinh tong
     	(setq Tong (+ KLdap_1 Tong))
     	(setq N (1+ N))
     	)
   	(command ".layer" "s" "THop-KLuongdap" ""
         ".text" "j" "mc" (polar pt31 0 (- (* 2 KCDC))) htext 90 (rtos Tong 2 2)
         )
   	)
 	)
;tinh khoi luong dao
(setq KLdao (ssget "w" pt1_1 pt28 '((0 . "text") (8 . "sn-KLuongdao"))))
(if (= KLdao nil)     
 	(progn
   	(command ".layer" "s" "THop-KLuongdao" ""
         ".text" "j" "mc" (polar pt31 0 (- (* 3 KCDC))) htext 90 "00.00"
         )
   	)
 	(progn
   	(setq N 0
  	Tong 0
       SLKLdao (sslength KLdao)
  	)
   	(repeat SLKLdao
     	(setq MDT_KLdao (entget (ssname KLdao N))
    	KLdao_1 (atof (cdr (assoc 1 MDT_KLdao)))
    	)
     	;tinh tong
     	(setq Tong (+ KLdao_1 Tong))
     	(setq N (1+ N))
     	)
   	(command ".layer" "s" "THop-KLuongdao" ""
         ".text" "j" "mc" (polar pt31 0 (- (* 3 KCDC))) htext 90 (rtos Tong 2 2)
         )
   	)
 	)
;doi dau thanh cuoi
(setq pt1_1 pt27)
)
;tinh tong cac gia tri dien vao cot cuoi cung
     ;tao diem ao pt23
     (setq pt32 pt23)
     (repeat 2
(setq  pt33 (polar pt32 (/ pi 2) (* ktol sld))
          pt34 (polar pt33 0 (- KCDC))
          pt35 (polar pt33 0 (- (/ KCDC 2)))
          pt36 (polar pt35 (/ pi 2) (/ ktol 2))
          )
(setq sum_all (ssget "w" pt32 pt34 '((0 . "text")))
     	sum_SL (sslength sum_all)
     	)
(setq N 0
     	sum 0
     	)
(repeat sum_SL
 	(setq MDT_sum_all (entget (ssname sum_all N))
    	sum_all_1 (atof (cdr (assoc 1 MDT_sum_all)))
    	)
 	;tinh tong
 	(setq sum (+ sum_all_1 sum))
 	(setq N (1+ N))
 	)
(command ".layer" "s" "THop-TEXT" ""
     ".text" "j" "ml"  pt36 htext 90 (strcat "= "(rtos sum 2 2) " (M2)")
         )
;doi dau thanh cuoi
(setq pt32 (polar pt32 0 (- KCDC)))
)
     (repeat 2
(setq  pt33 (polar pt32 (/ pi 2) (* ktol sld))
          pt34 (polar pt33 0 (- KCDC))
          pt35 (polar pt33 0 (- (/ KCDC 2)))
          pt36 (polar pt35 (/ pi 2) (/ ktol 2))
          )
(setq sum_all (ssget "w" pt32 pt34 '((0 . "text")))
     	sum_SL (sslength sum_all)
     	)
(setq N 0
     	sum 0
     	)
(repeat sum_SL
 	(setq MDT_sum_all (entget (ssname sum_all N))
    	sum_all_1 (atof (cdr (assoc 1 MDT_sum_all)))
    	)
 	;tinh tong
 	(setq sum (+ sum_all_1 sum))
 	(setq N (1+ N))
 	)
(command ".layer" "s" "THop-TEXT" ""
     ".text" "j" "ml"  pt36 htext 90 (strcat "= "(rtos sum 2 2) " (M3)")
         )
;doi dau thanh cuoi
(setq pt32 (polar pt32 0 (- KCDC)))
)    
     )    ;dong progn
     )	;dong if
 (princ)
 )    
*********************************************
;tinh cao do thi cong
(defun CDTC ()
 (setvar "cmdecho" 0)
 (setvar "orthomode" 0)
 (setvar "gridmode" 0)
 (setvar "snapmode" 0)
 (setvar "osmode" 0)    
 ;kiem tra bao nhieu doi tuong co do tu nhien
 (setq sum_CDTK (ssget '((0 . "text") (8 . "sn-CDTK")))
SL_CDTK (sslength sum_CDTK)
)
 (setq N 0)
 (repeat SL_CDTK
   (setq MDT_CDTK (entget (ssname sum_CDTK N))
      pt37 (cdr (assoc 10 MDT_CDTK))
 	)
   (setq pt38 ( polar pt37 0 (- (* ktol 0.3)))
 	pt39 (polar pt38 (/ pi 2) (* ktol 0.3))
 	pt40 (polar pt37 0 (* ktol 0.3))
 	pt41 (polar pt40 (/ pi 2) (- (* ktol 0.3)))
 	)
   (setq cdtk_1 (ssget "w" pt39 pt41 '((0 . "text") (8 . "sn-CDTK")))
 	MDT_cdtk_1 (entget (ssname cdtk_1 0))
 	cdtk_2 (atof (cdr (assoc 1 MDT_CDTK)))
 	)
	(setq cdtn_1 (ssget "w" pt39 pt41 '((0 . "text") (8 . "sn-CDTN")))
 	MDT_cdtn_1 (entget (ssname cdtn_1 0))
 	cdtn_2 (atof (cdr (assoc 1 MDT_cdtn_1)))
 	)
   (setq cdtc_1 (- cdtk_2 cdtn_2))
   (setq pt42 (polar pt37 0 (- (* ktol 0.056))))
   (if (< cdtc_1 0)
     (progn
;dat layer hien hanh
 	(command ".layer" "s" "sn-CDTCdao" "")   
   	(command ".text" "j" "r" pt42 htext 0 (rtos cdtc_1 2 2))
)
     (progn
(command ".layer" "s" "sn-CDTCdap" "")   
   	(command ".text" "j" "r" pt42 htext 0 (rtos cdtc_1 2 2))
)
     )
   ;tang so luong N
   (setq N (1+ N))
   )
 (princ)
 )  
********************************************
;ve ranh gio dao dap
(defun rgdd  ();ranh gio dao dap
 (setq SSC_rgdd (ssget '((0 . "circle") (8 . "sn-vong tron o luoi")))
LSC_rgdd (sslength SSC_rgdd)
    )  
 (setq N 0)
 (repeat LSC_rgdd
   (command ".layer" "s" "sn-ranhgioidaodap" ""
        )
   ;lay ra ma doi tuong
   (setq MDT_rgdd (entget (ssname SSC_rgdd N))
 	pt_tam_rgdd (cdr (assoc 10 MDT_rgdd)) ;lay ra toa do tam duong tron
 	nol (/ KTOL 2)	;do lon nua o luoi
 	;xac dinh hai diem ben phai     
 	pt19_rgdd (polar pt_tam_rgdd 0 nol)
 	pt20_rgdd (polar pt19_rgdd (/ pi 2) (- nol))
 	;xac dinh diem ben phai
 	pt21_rgdd (polar pt_tam_rgdd 0 (- (+ nol (* nol 0.8))))
 	pt22_rgdd (polar pt21_rgdd (/ pi 2) (+ nol (* nol 0.8)))
 	)
   ;tinh cao do trung binh
   (setq CDTC_dao (ssget "w" pt22_rgdd pt20_rgdd '((0 . "text") (8 . "sn-CDTCdao")))
 	SL_CDTC_dao (sslength CDTC_dao)
 	)
	(if (= CDTC_dao nil)
     (progn
(prompt "\nKhong co ranh gioi dao dap")
)
     (progn    
(prompt "\nCo ranh gioi dao dap")
)
     )
   ;(setq CDTC_dap (ssget "w" pt22_rgdd pt20_rgdd '((0 . "text") (8 . "sn-CDTCdap")))
 	;SL_CDTC_dap (sslength CDTC_dap)
 	;)

   ;cao do thi cong cac diem nut
   ;(setq CDTC_1 (entget (ssname CDTB 0))
 	;CDTC_11 (atof (cdr (assoc 1 CDTC_1)))
    ; )
   ;(setq CDTC_2 (entget (ssname CDTB 1))
    ; CDTC_22 (atof (cdr (assoc 1 CDTC_2)))
    ; )
   ;(setq CDTC_3 (entget (ssname CDTB 2))
    ; CDTC_33 (atof (cdr (assoc 1 CDTC_3)))
    ;)
  ; (setq CDTC_4 (entget (ssname CDTB 3))
    ; CDTC_44 (atof (cdr (assoc 1 CDTC_4)))
; )
   (setq N (1+ N))
   );dong vong lap repeat
 (princ)
 );ket thuc ham


********************************************
;chuong trinh chinh goi cac ham tren
;ve o luoi
(defun c:vol ()
 (vol)
 )
;ghi thu tu o luoi
(defun c:TTOL ()
 (TTOL)
 )
;them text vao text cu
(defun c:themtext ()
 (themtext)
 )
;tinh cao do thi cong
(defun c:CDTC ()
 (CDTC)
   )
;ve ranh gioi dao dap
(defun c:RGDD ()
 (RGDD)
 )
;tinh cao do trung binh o luoi
(defun c:CDTB ()
 (CDTB)
 (setq Timfile (findfile "ve o luoi va tinh gia tri o luoi.LSP"))
 (load Timfile)
 (prompt Timfile)
 (princ)
 )
;lap bang tong hop khoi luong
(defun c:THKL ()
 (THKL)
 )

  • Vote giảm 1

Chia sẻ bài đăng này


Liên kết tới bài đăng
Chia sẻ trên các trang web khác

Mình đóng góp tính vảo lisp anh Sau nhe:

 

- Thứ nhất: Phần vẽ ô lưới thay vì chọn điểm đầu và điểm cuối thì ta cho chọn đường bao khu đất san lấp, đường này là 1 đường khép kín. Vì như vậy nó sẽ tính đươc tổng quát hơn. Ở ranh giới khu đất hiện tại mình phải tính tay rồi điền vào thì nó mới chạy đúng được như vậy sẽ mất thời gian cho những khu đất lớn hay dài.

 

- Thứ 2: Ta có thể chỉnh bảng THKL của mình tổng họp theo từ ô lưới. THKL thành 1 bảng với các cột là:

STT số lô Diện tích Htntb Htk Hsl KLsl

 

Trong đó:

Htntb: là chiều cao trung bình của mặt đất tự nhiên chính là CDTB của anh.

Htk: chiều cao thiết kế

Hsl: Chiều dày san lấp Hsl = Htk-Htntb

KLsl: Khối lượng san lấp.

 

- Thứ 3: Sao lệnh CDTB có khi chạy khi không.Mong mất anh em cao thủ Lisp của CadViet mình chỉnh lại để có 1 lisp san nền tuyệt vời để dùng.

  • Vote tăng 1

Chia sẻ bài đăng này


Liên kết tới bài đăng
Chia sẻ trên các trang web khác
dinhthe265    1

Mình cũng là gà mới vào làm san nền! Mình đang tìm 1 cách tính tính toán thẳng trên cad thay cho phần mềm HS chạy không ổn định. Thấy ý kiến của các bạn rất hay. Mong các cao thủ lisp cad giúp đỡ hoàn thành lisp trên trong thời gian sớm nhất

  • Vote tăng 1

Chia sẻ bài đăng này


Liên kết tới bài đăng
Chia sẻ trên các trang web khác

 

Mình có xin được lisp của anh Sáu rất hay đang sử dụng cho công việc nhưng hiện tại lưới khi nhập vào là lưới ô vuông tức là chỉ nhập vào 1 số 10m chẳng hạn,

giờ mình muốn nhập lưới hình chữ nhật 10mx20m hoặc lưới tam giác, nhờ các bác giúp đỡ

 

 

 

;tao layer cho ban ve
(defun c:khsn ()
  (command ".layer" "n" "sn-luoi o vuong" "c" "8" "sn-luoi o vuong" ""
       ".layer" "n" "sn-STT o luoi" "c" "120" "sn-STT o luoi" ""
       ".style" "text" "VNI-Helve" "" "" "" "" "" ""
       ".layer" "n" "sn-vong tron o luoi" "c" "1" "sn-vong tron o luoi" ""
       	".layer" "n" "sn-DTdap" "c" "210" "sn-DTdap" ""
       ".Layer" "n" "sn-CDTK" "c" "1" "sn-CDTK" ""
       ".layer" "n" "sn-CD Trung binh" "c" "30" "sn-CD trung binh" ""
       ".Layer" "n" "sn-CDTCdao" "c" "4" "sn-CDTCdao" ""
       ".Layer" "n" "sn-CDTCdap" "c" "2" "sn-CDTCdap" ""
       ".layer" "n" "sn-KLuongdap" "c" "42" "sn-KLuongdap" ""
       ".Layer" "n" "sn-CDTN" "c" "3" "sn-CDTN" ""
       )
  (command ".layer" "n" "sn-KLuongdao" "c" "91" "sn-KLuongdao" ""
         ".layer" "n" "sn-CD Trung binh" "c" "30" "sn-CD trung binh" ""
         ".layer" "n" "sn-KLuongdap" "c" "241" "sn-KLuongdap" ""
         ".layer" "n" "sn-DTdao" "c" "151" "sn-DTdao" ""
         )  
  (command ".layer" "n" "THop-KLuongdao" "c" "91" "THop-KLuongdao" ""
       ".layer" "n" "THop-KLuongdap" "c" "241" "THop-KLuongdap" ""
       ".layer" "n" "THop-DTdap" "c" "210" "THop-DTdap" ""
       ".layer" "n" "THop-DTdao" "c" "151" "THop-DTdao" ""
           ;".layer" "n" "THop-KLuongdao" "c" "7" "THop-KLuongdao" ""
       ;".layer" "n" "THop-KLuongdap" "c" "7" "THop-KLuongdap" ""
       ;".layer" "n" "THop-DTdap" "c" "7" "THop-DTdap" ""
       ;".layer" "n" "THop-DTdao" "c" "7" "THop-DTdao" ""
       ".layer" "n" "THop-DThang" "c" "2" "THop-DThang" ""
       ".layer" "n" "THop-TEXT" "c" "7" "THop-TEXT" ""
       ".layer" "n" "sn-ranhgioidaodap" "c" "91" "sn-ranhgioidaodap"""
       )
  (princ)
  )
;danh so thu tu o luoi
(defun TTOL ()
  (setvar "cmdecho" 0)  
  (setq SS (ssget '((0 . "text") (8 . "sn-STT o luoi")))
	LS (sslength SS)
	)
  (setq N 0)
  (setq M LS)
  (setq CDD (getstring "\nChu so dung dau (tien to):"))
  (repeat LS
    ;lay ra ma doi tuong
    (setq MDT (entget (ssname SS N)))
    ;lay ra gia tri text
    (setq TEXT1 (assoc 1 MDT))
    (setq STT1 (strcat CDD (rtos M 2 0)))
    ;danh so thu tu
    (setq STT (subst (cons 1 STT1) TEXT1 MDT))
    (setq N (1+ N))
    (setq M (1- M))
    ;cap nhat lai ma doi tuong
    (entmod STT)
    )  
  (princ)
  )
***************************************
;them dau tru "-" vao o trong ranh gio dao va them bat ky vao dau text
(defun themtext ()	;
  (setvar "cmdecho" 0)  
  (setq SS (ssget '((0 . "text")))
	LS (sslength SS)
	)
  (setq N 0)
  (setq CDD (getstring "\nThem gi:"))
  (repeat LS
    ;lay ra ma doi tuong
    (setq MDT (entget (ssname SS N)))
    ;lay ra gia tri text
    (setq TEXT1 (assoc 1 MDT))
    (setq TEXT2 (cdr TEXT1))
    (setq STT1 (strcat CDD TEXT2))
    (setq STT (subst (cons 1 STT1) TEXT1 MDT))
    (setq N (1+ N))
 	;cap nhat lai ma doi tuong
    (entmod STT)
    )
  (princ)
  )
******************************************
;ve o luoi san nen
(defun vol () ;vol:Ve o luoi
  (setvar "cmdecho" 0)
  (setvar "orthomode" 0)
  (setvar "gridmode" 0)
  (setvar "snapmode" 0)
  (setvar "osmode" 0)  
  ;vao hai diem
  (setq pt1 (getpoint "\nChon diem thu nhat: ")
	pt2 (getcorner pt1 "\nChon diem thu hai: ")
	)
  (setq ktol (getint "\nKich thuoc o luoi: ")) ;ktol:kich thuoc o luoi
  ;lay ra toa do hai diem
  (setq pt1_x (car pt1)
	pt1_y (cadr pt1)
	pt2_x (car pt2)
	pt2_y (cadr pt2)
	)
  ;tao cac diem moi de ve o luoi
  (setq pt3 (polar pt1 0 (- pt2_x pt1_x))
	)
  ;xac dinh bao nhieu line trong o luoi
  (setq ln (distance pt3 pt1)	;chieu dai toan bo luoi theo phuong ngang
	ld (distance pt2 pt3)	;chieu dai toan bo luoi theo phuong dung
	sln (fix (/ ln ktol))	;so duong thang theo phuong ngang
	sld (fix (/ ld ktol))	;so duong thang theo phuong dung
	)
  (setq pt4 (polar pt1 0 (* ktol sln))
	pt5 (polar pt4 (/ pi 2) (* ktol sld))
	)
  (command ".layer" "s" "sn-luoi o vuong" "")
  (command ".line" pt1 pt4 ""       
       ".array" "l" "" "r" (+ 1 sld) 1 ktol
       ".line" pt4 pt5 ""
       ".array" "l" "" "r" 1 (+ 1 sln) (- ktol)
       )
  ;tinh cac diem trong o luoi
  (setq pt6 (polar pt1 (/ pi 2) (* ktol sld))
	pt7 (polar pt6 (/ pi 2) (- (/ ktol 2)))
	pt8 (polar pt7 0 (/ ktol 2))
	;pt9 pt8
	)   
  (repeat sld
    ;ve vong tron khoi luong
    (setq bkol (/ ktol 3.00))	;bkol:ban kinh o luoi
    (command ".layer" "s" "sn-vong tron o luoi" "")
    (command ".circle" pt8 bkol
         ".array" "l" "" "r" 1  sln ktol
       )    
    ;ghi so thu tu o luoi vao o luoi
    (setq htext (/ ktol 14.00))	;chieu cao chu
    (setq pt11 (polar pt8 (/ pi 2) (/ ktol 5.33)))
    (command ".layer" "s" "sn-STT o luoi" "")
    (command ".text" "j" "mc" pt11 htext 0  "STT"
         ".array" "l" "" "r" 1  sln ktol
       )
    ;ve cac doan thang vao o luoi
    (setq ol_ld (/ ktol (* 2 5.00))	;duong thang dung
  	pt12 (polar pt8 (/ pi 2) ol_ld)
  	pt13 (polar pt8 (/ pi 2) (- ol_ld))
  	ol_ln (/ ktol (* 2 1.572427175))
  	pt14 (polar pt12 0 ol_ln)
  	pt15 (polar pt12 0 (- ol_ln))
  	pt16 (polar pt13 0 ol_ln)
  	pt17 (polar pt13 0 (- ol_ln))
  	)
    (command ".layer" "s" "sn-vong tron o luoi" "")
    (command ".line" pt12 pt13 ""
         ".array" "l" "" "r" 1  sln ktol
         ".line" pt14 pt15 ""
         ".array" "l" "" "r" 1  sln ktol
         ".line" pt16 pt17 ""
         ".array" "l" "" "r" 1  sln ktol
         )
    ;dien dien tich o luoi
    (setq pt18 (polar pt8 0 (- (/ ktol 6.289703755))))
    (command ".layer" "s" "sn-DTdap" "")
    (command ".text" "j" "mc" pt18 htext 0 (rtos (* ktol ktol) 2 0)
         ".array" "l" "" "r" 1  sln ktol
         )       
 	;doi cuoi thanh dau
    (setq pt10 (polar pt8 (/ pi 2) (- ktol)))
    (setq pt8 pt10)    
    )
  ;(alert "Hay su dung nhung layer duoc tao ra va dung xoa di")
  (princ)
  )
 
*********************************************
;tinh cao do trung binh
(defun CDTB ()
  (setvar "cmdecho" 0)
  (setvar "orthomode" 0)
  (setvar "gridmode" 0)
  (setvar "snapmode" 0)
  (setvar "osmode" 0)    
  (alert (strcat "Khong chon nhung o luoi thuoc ranh gioi dao dap va cac o le"
     	  	"\nChon nhung o luoi nam hoan toan trong vung dao hoac dap")
     )
  ;kiem tra kich thuoc o luoi
  ;(if ( = ktol nil)
   ; (progn
 	; (setq KTOL (getreal "\nKich thuoc o luoi: "))
 	; )
    <img src='http://www.cadviet.com/forum/public/style_emoticons/<#EMO_DIR#>/wink.png' class='bbc_emoticon' alt=';)' />
  (setq SSC (ssget '((0 . "circle") (8 . "sn-vong tron o luoi")))
	LSC (sslength SSC)
     )  
  (setq N 0)
  (repeat LSC
 	;lay ra ma doi tuong
    (setq MDTC (entget (ssname SSC N))
  	pt_tam (cdr (assoc 10 MDTC)) ;lay ra toa do tam duong tron
  	nol (/ KTOL 2)	;do lon nua o luoi
  	;xac dinh hai diem ben phai     
  	pt19 (polar pt_tam 0 nol)
  	pt20 (polar pt19 (/ pi 2) (- nol))
  	;xac dinh diem ben phai
  	pt21 (polar pt_tam 0 (- (+ nol (* nol 0.8))))
  	pt22 (polar pt21 (/ pi 2) (+ nol (* nol 0.8)))
  	)
    ;tinh cao do trung binh
    (setq CDTB (ssget "w" pt22 pt20 '((0 . "text") (8 . "sn-CDTC*")))
  	SL_CDTB (sslength CDTB)
  	)
    ;cao do thi cong cac diem nut
    (setq CDTC_1 (entget (ssname CDTB 0))
  	CDTC_11 (atof (cdr (assoc 1 CDTC_1)))
  	)
    (setq CDTC_2 (entget (ssname CDTB 1))
  	CDTC_22 (atof (cdr (assoc 1 CDTC_2)))
  	)
    (setq CDTC_3 (entget (ssname CDTB 2))
  	CDTC_33 (atof (cdr (assoc 1 CDTC_3)))
     )
    (setq CDTC_4 (entget (ssname CDTB 3))
  	CDTC_44 (atof (cdr (assoc 1 CDTC_4)))
     )
    ;tinh ra cao do trung binh
    (setq CDTBKq (/ (+ CDTC_11 CDTC_22 CDTC_33 CDTC_44) 4)
  	CDTBKq (atof (rtos CDTBKq 2 2))
  	KLOL (* KTOL KTOL CDTBKq)
  	)
    ;in gia tri
    (setq pt23 (polar pt_tam 0 (/ nol 3.144851877))
  	pt24 (polar pt_tam (/ pi 2) (- (/ nol 2.45)))
  	)    
    (command ".layer" "s" "sn-CD Trung binh" ""
               ".text" "j" "mc" pt23 htext 0 (rtos CDTBKq 2 2)
         )
    (if (< CDTBKq 0)
      (progn
	(setq SSdao (ssget "w" pt22 pt20 '((0 . "text") (8 . "sn-DTdap")))
      	dautru "-"	;them dau "-" vao nhung dien tich dao
      	)
	(setq MDT (entget (ssname SSdao 0)))
	;lay ra gia tri text them dau tru
        (setq TEXT1 (assoc 1 MDT))
        (setq TEXT2 (cdr TEXT1))
        (setq STT1 (strcat dautru TEXT2))
        (setq STT (subst (cons 1 STT1) TEXT1 MDT))
	;cap nhat lai ma doi tuong
	(entmod STT)    
	(command ".layer" "s" "sn-KLuongdao" "")
      )
      (progn    
      (command ".layer" "s" "sn-KLuongdap" "")
      )
      );ket thuc if
    ;chuyen sang layer moi neu CDTBKq <0
    (if (< CDTBKq 0)
      (progn
	(setq SSdao1 (ssget "w" pt22 pt20 '((0 . "text") (8 . "sn-DTdap"))))
	(setq layer (entget (ssname SSdao1 0)))
	(setq CLayer (subst '(8 . "sn-DTdao") (assoc 8 layer) layer))
     ;cap nhat lai ma doi tuong       
	(entmod CLayer)
      )
      )
         
    (command ".text" "j" "mc" pt24 htext 0 (rtos KLOL 2 2)
         )    
    (setq N (1+ N))    
    )
    (princ )   
  )
********************************************
;Lap bang tong hop khoi luong
(defun THKL ()	;THKL:Tong hop khoi luong
  (setvar "cmdecho" 0)
  (setvar "orthomode" 0)
  (setvar "gridmode" 0)
  (setvar "snapmode" 0)
  (setvar "osmode" 0)
  
  ;khoang cah giua cac dong
  (setq KCDC (* 0.3 ktol))	;KCDC: khoang cach dong chu
  ;lua chon phuong lap bang tong hop
  (initget 1 "Y X")
  (setq plb (getkword "\nBang tong hop dat theo phuong Y hay X ? <Y/X>: "))
  ;tao diem ao cua pt1
  (setq pt1_1 pt1   
	)
  (if (= plb "X")
    (progn
      (setq pt23 (polar pt1_1 (/ pi 2) (- (* 0.75 ktol)))
    	pt23_1 (polar pt23 0 (* ktol sln))
    	pt23_2 (polar pt23_1 0 (* 1.5 ktol))
    	pt24 (polar pt23 0 (- (* 2 ktol)))       
    	)
      ;ve duong thang
      (command ".layer" "s" "THop-DThang" ""
           ".line" pt23 pt24 ""
           ".array" "l" "" "r" 5  1 (- KCDC)
           ".line" pt24 (polar pt24 (/ pi 2) (- (* 4 KCDC))) ""
           ".line" pt23 (polar pt23 (/ pi 2) (- (* 4 KCDC))) ""
           ".array" "l" "" "r" 1  (+ 1 sln) ktol
           ".line" pt23 (polar pt23 0 (* ktol sln)) ""
           ".array" "l" "" "r" 5  1 (- KCDC)
           ".line" pt23_1 pt23_2 ""
           ".array" "l" "" "r" 5  1 (- KCDC)
           ".line" pt23_2 (polar pt23_2 (/ pi 2) (- (* 4 KCDC))) ""
           )
      ;tinh diem de dat text dau bang tong hop
      (setq pt25 (polar pt24 (/ pi 2) (- (/ KCDC 2)))
    	pt25_1 (polar pt23_1 (/ pi 2) (- (/ KCDC 2)))
    	pt25_2 (polar pt25_1 0 (* ktol 0.4))
    	pt26 (polar pt25 0 (* ktol 0.245))
    	)
      (command ".layer" "s" "THop-TEXT" ""
           ".text" "j" "ml" pt26 htext 0 "DIEÄN TÍCH ÑAÉP (M2)"
           ".text" "j" "ml" (polar pt26 (/ pi 2) (- KCDC)) htext 0 "DIEÄN TÍCH ÑAØO (M2)"
                 ".text" "j" "ml" (polar pt26 (/ pi 2) (- (* 2 KCDC))) htext 0 "KHOÁI LÖÔÏNG ÑAÁT ÑAÉP (M3)"
           ".text" "j" "ml" (polar pt26 (/ pi 2) (- (* 3 KCDC))) htext 0 "KHOÁI LÖÔÏNG ÑAÁT ÑAØO (M3)"
           ".text" "j" "m" pt25_2 htext 90 "M"
           ".array" "l" "" "r" 4  1 (- KCDC)
		)
      ;thu hien vong lap
      (repeat sln
	;tinh diem de chon doi tuong
	(setq pt27 (polar pt1_1 0 ktol)
    	pt28 (polar pt27 (/ pi 2) (* ktol sld))
    	)
	;tinh diem in gia tri
	(setq pt29 (polar pt1_1 (/ pi 2) (- (* 0.75 ktol)))
      	pt30 (polar pt29 (/ pi 2) (- (/ KCDC 2)))
      	pt31 (polar pt30 0 (/ ktol 2))
      	)
	;tinh dien tich dap
	(setq DTdap (ssget "w" pt1_1 pt28 '((0 . "text") (8 . "sn-DTdap"))))
	(if (= DTdap nil)     
  	(progn
    	(command ".layer" "s" "THop-DTdap" ""
	         ".text" "j" "mc" pt31 htext 0 "00.00"
	         )
    	)
  	(progn
    	(setq N 0
	  	Tong 0
	       SLDTdap (sslength DTdap)
	  	)
    	(repeat SLDTdap
      	(setq MDT_DTdap (entget (ssname DTdap N))
	    	DTdap_1 (atof (cdr (assoc 1 MDT_DTdap)))
	    	)
      	;tinh tong
      	(setq Tong (+ DTdap_1 Tong))
      	(setq N (1+ N))
      	)
    	(command ".layer" "s" "THop-DTdap" ""
	         ".text" "j" "mc" pt31 htext 0 (rtos Tong 2 2)
	         )
    	)
  	)
	;tinh dien tich dao
	(setq DTdao (ssget "w" pt1_1 pt28 '((0 . "text") (8 . "sn-DTdao"))))
	(if (= DTdao nil)     
  	(progn
    	(command ".layer" "s" "THop-DTdao" ""
	         ".text" "j" "mc" (polar pt31 (/ pi 2) (- KCDC)) htext 0 "00.00"
	         )
    	)
  	(progn
    	(setq N 0
	  	Tong 0
	       SLDTdao (sslength DTdao)
	  	)
    	(repeat SLDTdao
      	(setq MDT_DTdao (entget (ssname DTdao N))
	    	DTdao_1 (atof (cdr (assoc 1 MDT_DTdao)))
	    	)
      	;tinh tong
      	(setq Tong (+ DTdao_1 Tong))
      	(setq N (1+ N))
      	)
    	(command ".layer" "s" "THop-DTdao" ""
	         ".text" "j" "mc" (polar pt31 (/ pi 2) (- KCDC)) htext 0 (rtos Tong 2 2)
	         )
    	)
  	)
	;tinh khoi luong dap
	(setq KLdap (ssget "w" pt1_1 pt28 '((0 . "text") (8 . "sn-KLuongdap"))))
	(if (= KLdap nil)     
  	(progn
    	(command ".layer" "s" "THop-KLuongdap" ""
	         ".text" "j" "mc" (polar pt31 (/ pi 2) (- (* 2 KCDC))) htext 0 "00.00"
	         )
    	)
  	(progn
    	(setq N 0
	  	Tong 0
	       SLKLdap (sslength KLdap)
	  	)
    	(repeat SLKLdap
      	(setq MDT_KLdap (entget (ssname KLdap N))
	    	KLdap_1 (atof (cdr (assoc 1 MDT_KLdap)))
	    	)
      	;tinh tong
      	(setq Tong (+ KLdap_1 Tong))
      	(setq N (1+ N))
      	)
    	(command ".layer" "s" "THop-KLuongdap" ""
	         ".text" "j" "mc" (polar pt31 (/ pi 2) (- (* 2 KCDC))) htext 0 (rtos Tong 2 2)
	         )
    	)
  	)
	;tinh khoi luong dao
	(setq KLdao (ssget "w" pt1_1 pt28 '((0 . "text") (8 . "sn-KLuongdao"))))
	(if (= KLdao nil)     
  	(progn
    	(command ".layer" "s" "THop-KLuongdao" ""
	         ".text" "j" "mc" (polar pt31 (/ pi 2) (- (* 3 KCDC))) htext 0 "00.00"
	         )
    	)
  	(progn
    	(setq N 0
	  	Tong 0
	       SLKLdao (sslength KLdao)
	  	)
    	(repeat SLKLdao
      	(setq MDT_KLdao (entget (ssname KLdao N))
	    	KLdao_1 (atof (cdr (assoc 1 MDT_KLdao)))
	    	)
      	;tinh tong
      	(setq Tong (+ KLdao_1 Tong))
      	(setq N (1+ N))
      	)
    	(command ".layer" "s" "THop-KLuongdao" ""
	         ".text" "j" "mc" (polar pt31 (/ pi 2) (- (* 3 KCDC))) htext 0 (rtos Tong 2 2)
	         )
    	)
  	)
	;doi dau thanh cuoi
	(setq pt1_1 pt27)
	)
	;tinh tong cac gia tri dien vao cot cuoi cung
      ;tao diem ao pt23
      (setq pt32 pt23)
      (repeat 2
	(setq  pt33 (polar pt32 0 (* ktol sln))
           pt34 (polar pt33 (/ pi 2) (- KCDC))
           pt35 (polar pt33 (/ pi 2) (- (/ KCDC 2)))
           pt36 (polar pt35 0 (/ ktol 2))
           )
	(setq sum_all (ssget "w" pt32 pt34 '((0 . "text")))
      	sum_SL (sslength sum_all)
      	)
	(setq N 0
      	sum 0
      	)
	(repeat sum_SL
  	(setq MDT_sum_all (entget (ssname sum_all N))
	    	sum_all_1 (atof (cdr (assoc 1 MDT_sum_all)))
	    	)
  	;tinh tong
  	(setq sum (+ sum_all_1 sum))
  	(setq N (1+ N))
  	)
	(command ".layer" "s" "THop-TEXT" ""
	     ".text" "j" "ml"  pt36 htext 0 (strcat "= "(rtos sum 2 2) " (M2)")
	         )
	;doi dau thanh cuoi
	(setq pt32 (polar pt32 (/ pi 2) (- KCDC)))
	)
      (repeat 2
	(setq  pt33 (polar pt32 0 (* ktol sln))
           pt34 (polar pt33 (/ pi 2) (- KCDC))
           pt35 (polar pt33 (/ pi 2) (- (/ KCDC 2)))
           pt36 (polar pt35 0 (/ ktol 2))
           )
	(setq sum_all (ssget "w" pt32 pt34 '((0 . "text")))
      	sum_SL (sslength sum_all)
      	)
	(setq N 0
      	sum 0
      	)
	(repeat sum_SL
  	(setq MDT_sum_all (entget (ssname sum_all N))
	    	sum_all_1 (atof (cdr (assoc 1 MDT_sum_all)))
	    	)
  	;tinh tong
  	(setq sum (+ sum_all_1 sum))
  	(setq N (1+ N))
  	)
	(command ".layer" "s" "THop-TEXT" ""
	     ".text" "j" "ml"  pt36 htext 0 (strcat "= "(rtos sum 2 2) " (M3)")
	         )
	;doi dau thanh cuoi
	(setq pt32 (polar pt32 (/ pi 2) (- KCDC)))
	)    
      )   ;dong progn
    ;da tinh xong khi lap bang theo phuong X
    ;neu lap bang theo phuong Y
    (progn
      (setq pt23 (polar pt1_1 0 (- (* 0.75 ktol)))
    	pt23_1 (polar pt23 (/ pi 2) (* ktol sld))
    	pt23_2 (polar pt23_1 (/ pi 2) (* 1.5 ktol))
    	pt24 (polar pt23 (/ pi 2) (- (* 2 ktol)))       
    	)
      ;ve duong thang
      (command ".layer" "s" "THop-DThang" ""
           ".line" pt23 pt24 ""
           ".array" "l" "" "r" 1  5 (- KCDC)
           ".line" pt24 (polar pt24 0 (- (* 4 KCDC))) ""
           ".line" pt23 (polar pt23 0 (- (* 4 KCDC))) ""
           ".array" "l" "" "r" (+ 1 sld) 1 ktol
           ".line" pt23 (polar pt23 (/ pi 2) (* ktol sld)) ""
           ".array" "l" "" "r" 1  5 (- KCDC)
           ".line" pt23_1 pt23_2 ""
           ".array" "l" "" "r" 1  5 (- KCDC)
           ".line" pt23_2 (polar pt23_2 0 (- (* 4 KCDC))) ""
           )
      ;tinh diem de dat text dau bang tong hop
      (setq pt25 (polar pt24 0 (- (/ KCDC 2)))
    	pt25_1 (polar pt23_1 0 (- (/ KCDC 2)))
    	pt25_2 (polar pt25_1 (/ pi 2) (* ktol 0.4))
    	pt26 (polar pt25 (/ pi 2) (* ktol 0.245))
    	)
      (command ".layer" "s" "THop-TEXT" ""
           ".text" "j" "ml" pt26 htext 90 "DIEÄN TÍCH ÑAÉP (M2)"
           ".text" "j" "ml" (polar pt26 0 (- KCDC)) htext 90 "DIEÄN TÍCH ÑAØO (M2)"
                 ".text" "j" "ml" (polar pt26 0 (- (* 2 KCDC))) htext 90 "KHOÁI LÖÔÏNG ÑAÁT ÑAÉP (M3)"
           ".text" "j" "ml" (polar pt26 0 (- (* 3 KCDC))) htext 90 "KHOÁI LÖÔÏNG ÑAÁT ÑAØO (M3)"
           ".text" "j" "m" pt25_2 htext 180 "M"
           ".array" "l" "" "r" 1  4 (- KCDC)
		)
      ;thu hien vong lap
      (repeat sld
	;tinh diem de chon doi tuong
	(setq pt27 (polar pt1_1 (/ pi 2) ktol)
    	pt28 (polar pt27 0 (* ktol sln))
    	)
	;tinh diem in gia tri
	(setq pt29 (polar pt1_1 0 (- (* 0.75 ktol)))
      	pt30 (polar pt29 0 (- (/ KCDC 2)))
      	pt31 (polar pt30 (/ pi 2) (/ ktol 2))
      	)
	;tinh dien tich dap
	(setq DTdap (ssget "w" pt1_1 pt28 '((0 . "text") (8 . "sn-DTdap"))))
	(if (= DTdap nil)     
  	(progn
    	(command ".layer" "s" "THop-DTdap" ""
	         ".text" "j" "mc" pt31 htext 90 "00.00"
	         )
    	)
  	(progn
    	(setq N 0
	  	Tong 0
	       SLDTdap (sslength DTdap)
	  	)
    	(repeat SLDTdap
      	(setq MDT_DTdap (entget (ssname DTdap N))
	    	DTdap_1 (atof (cdr (assoc 1 MDT_DTdap)))
	    	)
      	;tinh tong
      	(setq Tong (+ DTdap_1 Tong))
      	(setq N (1+ N))
      	)
    	(command ".layer" "s" "THop-DTdap" ""
	         ".text" "j" "mc" pt31 htext 90 (rtos Tong 2 2)
	         )
    	)
  	)
	;tinh dien tich dao
	(setq DTdao (ssget "w" pt1_1 pt28 '((0 . "text") (8 . "sn-DTdao"))))
	(if (= DTdao nil)     
  	(progn
    	(command ".layer" "s" "THop-DTdao" ""
	         ".text" "j" "mc" (polar pt31 0 (- KCDC)) htext 90 "00.00"
	         )
    	)
  	(progn
    	(setq N 0
	  	Tong 0
	       SLDTdao (sslength DTdao)
	  	)
    	(repeat SLDTdao
      	(setq MDT_DTdao (entget (ssname DTdao N))
	    	DTdao_1 (atof (cdr (assoc 1 MDT_DTdao)))
	    	)
      	;tinh tong
      	(setq Tong (+ DTdao_1 Tong))
      	(setq N (1+ N))
      	)
    	(command ".layer" "s" "THop-DTdao" ""
	         ".text" "j" "mc" (polar pt31 0 (- KCDC)) htext 90 (rtos Tong 2 2)
	         )
    	)
  	)
	;tinh khoi luong dap
	(setq KLdap (ssget "w" pt1_1 pt28 '((0 . "text") (8 . "sn-KLuongdap"))))
	(if (= KLdap nil)     
  	(progn
    	(command ".layer" "s" "THop-KLuongdap" ""
	         ".text" "j" "mc" (polar pt31 0 (- (* 2 KCDC))) htext 90 "00.00"
	         )
    	)
  	(progn
    	(setq N 0
	  	Tong 0
	       SLKLdap (sslength KLdap)
	  	)
    	(repeat SLKLdap
      	(setq MDT_KLdap (entget (ssname KLdap N))
	    	KLdap_1 (atof (cdr (assoc 1 MDT_KLdap)))
	    	)
      	;tinh tong
      	(setq Tong (+ KLdap_1 Tong))
      	(setq N (1+ N))
      	)
    	(command ".layer" "s" "THop-KLuongdap" ""
	         ".text" "j" "mc" (polar pt31 0 (- (* 2 KCDC))) htext 90 (rtos Tong 2 2)
	         )
    	)
  	)
	;tinh khoi luong dao
	(setq KLdao (ssget "w" pt1_1 pt28 '((0 . "text") (8 . "sn-KLuongdao"))))
	(if (= KLdao nil)     
  	(progn
    	(command ".layer" "s" "THop-KLuongdao" ""
	         ".text" "j" "mc" (polar pt31 0 (- (* 3 KCDC))) htext 90 "00.00"
	         )
    	)
  	(progn
    	(setq N 0
	  	Tong 0
	       SLKLdao (sslength KLdao)
	  	)
    	(repeat SLKLdao
      	(setq MDT_KLdao (entget (ssname KLdao N))
	    	KLdao_1 (atof (cdr (assoc 1 MDT_KLdao)))
	    	)
      	;tinh tong
      	(setq Tong (+ KLdao_1 Tong))
      	(setq N (1+ N))
      	)
    	(command ".layer" "s" "THop-KLuongdao" ""
	         ".text" "j" "mc" (polar pt31 0 (- (* 3 KCDC))) htext 90 (rtos Tong 2 2)
	         )
    	)
  	)
	;doi dau thanh cuoi
	(setq pt1_1 pt27)
	)
	;tinh tong cac gia tri dien vao cot cuoi cung
      ;tao diem ao pt23
      (setq pt32 pt23)
      (repeat 2
	(setq  pt33 (polar pt32 (/ pi 2) (* ktol sld))
           pt34 (polar pt33 0 (- KCDC))
           pt35 (polar pt33 0 (- (/ KCDC 2)))
           pt36 (polar pt35 (/ pi 2) (/ ktol 2))
           )
	(setq sum_all (ssget "w" pt32 pt34 '((0 . "text")))
      	sum_SL (sslength sum_all)
      	)
	(setq N 0
      	sum 0
      	)
	(repeat sum_SL
  	(setq MDT_sum_all (entget (ssname sum_all N))
	    	sum_all_1 (atof (cdr (assoc 1 MDT_sum_all)))
	    	)
  	;tinh tong
  	(setq sum (+ sum_all_1 sum))
  	(setq N (1+ N))
  	)
	(command ".layer" "s" "THop-TEXT" ""
	     ".text" "j" "ml"  pt36 htext 90 (strcat "= "(rtos sum 2 2) " (M2)")
	         )
	;doi dau thanh cuoi
	(setq pt32 (polar pt32 0 (- KCDC)))
	)
      (repeat 2
	(setq  pt33 (polar pt32 (/ pi 2) (* ktol sld))
           pt34 (polar pt33 0 (- KCDC))
           pt35 (polar pt33 0 (- (/ KCDC 2)))
           pt36 (polar pt35 (/ pi 2) (/ ktol 2))
           )
	(setq sum_all (ssget "w" pt32 pt34 '((0 . "text")))
      	sum_SL (sslength sum_all)
      	)
	(setq N 0
      	sum 0
      	)
	(repeat sum_SL
  	(setq MDT_sum_all (entget (ssname sum_all N))
	    	sum_all_1 (atof (cdr (assoc 1 MDT_sum_all)))
	    	)
  	;tinh tong
  	(setq sum (+ sum_all_1 sum))
  	(setq N (1+ N))
  	)
	(command ".layer" "s" "THop-TEXT" ""
	     ".text" "j" "ml"  pt36 htext 90 (strcat "= "(rtos sum 2 2) " (M3)")
	         )
	;doi dau thanh cuoi
	(setq pt32 (polar pt32 0 (- KCDC)))
	)    
      )    ;dong progn
      )	;dong if
  (princ)
  )    
*********************************************
;tinh cao do thi cong
(defun CDTC ()
  (setvar "cmdecho" 0)
  (setvar "orthomode" 0)
  (setvar "gridmode" 0)
  (setvar "snapmode" 0)
  (setvar "osmode" 0)    
  ;kiem tra bao nhieu doi tuong co do tu nhien
  (setq sum_CDTK (ssget '((0 . "text") (8 . "sn-CDTK")))
	SL_CDTK (sslength sum_CDTK)
	)
  (setq N 0)
  (repeat SL_CDTK
    (setq MDT_CDTK (entget (ssname sum_CDTK N))
       pt37 (cdr (assoc 10 MDT_CDTK))
  	)
    (setq pt38 ( polar pt37 0 (- (* ktol 0.3)))
  	pt39 (polar pt38 (/ pi 2) (* ktol 0.3))
  	pt40 (polar pt37 0 (* ktol 0.3))
  	pt41 (polar pt40 (/ pi 2) (- (* ktol 0.3)))
  	)
    (setq cdtk_1 (ssget "w" pt39 pt41 '((0 . "text") (8 . "sn-CDTK")))
  	MDT_cdtk_1 (entget (ssname cdtk_1 0))
  	cdtk_2 (atof (cdr (assoc 1 MDT_CDTK)))
  	)
 	(setq cdtn_1 (ssget "w" pt39 pt41 '((0 . "text") (8 . "sn-CDTN")))
  	MDT_cdtn_1 (entget (ssname cdtn_1 0))
  	cdtn_2 (atof (cdr (assoc 1 MDT_cdtn_1)))
  	)
    (setq cdtc_1 (- cdtk_2 cdtn_2))
    (setq pt42 (polar pt37 0 (- (* ktol 0.056))))
    (if (< cdtc_1 0)
      (progn
	;dat layer hien hanh
  	(command ".layer" "s" "sn-CDTCdao" "")   
    	(command ".text" "j" "r" pt42 htext 0 (rtos cdtc_1 2 2))
	)
      (progn
	(command ".layer" "s" "sn-CDTCdap" "")   
    	(command ".text" "j" "r" pt42 htext 0 (rtos cdtc_1 2 2))
	)
      )
    ;tang so luong N
    (setq N (1+ N))
    )
  (princ)
  )  
********************************************
;ve ranh gio dao dap
(defun rgdd  ();ranh gio dao dap
  (setq SSC_rgdd (ssget '((0 . "circle") (8 . "sn-vong tron o luoi")))
	LSC_rgdd (sslength SSC_rgdd)
     )  
  (setq N 0)
  (repeat LSC_rgdd
    (command ".layer" "s" "sn-ranhgioidaodap" ""
         )
    ;lay ra ma doi tuong
    (setq MDT_rgdd (entget (ssname SSC_rgdd N))
  	pt_tam_rgdd (cdr (assoc 10 MDT_rgdd)) ;lay ra toa do tam duong tron
  	nol (/ KTOL 2)	;do lon nua o luoi
  	;xac dinh hai diem ben phai     
  	pt19_rgdd (polar pt_tam_rgdd 0 nol)
  	pt20_rgdd (polar pt19_rgdd (/ pi 2) (- nol))
  	;xac dinh diem ben phai
  	pt21_rgdd (polar pt_tam_rgdd 0 (- (+ nol (* nol 0.8))))
  	pt22_rgdd (polar pt21_rgdd (/ pi 2) (+ nol (* nol 0.8)))
  	)
    ;tinh cao do trung binh
    (setq CDTC_dao (ssget "w" pt22_rgdd pt20_rgdd '((0 . "text") (8 . "sn-CDTCdao")))
  	SL_CDTC_dao (sslength CDTC_dao)
  	)
 	(if (= CDTC_dao nil)
      (progn
	(prompt "\nKhong co ranh gioi dao dap")
	)
      (progn    
	(prompt "\nCo ranh gioi dao dap")
	)
      )
    ;(setq CDTC_dap (ssget "w" pt22_rgdd pt20_rgdd '((0 . "text") (8 . "sn-CDTCdap")))
  	;SL_CDTC_dap (sslength CDTC_dap)
  	<img src='http://www.cadviet.com/forum/public/style_emoticons/<#EMO_DIR#>/wink.png' class='bbc_emoticon' alt=';)' />
  
    ;cao do thi cong cac diem nut
    ;(setq CDTC_1 (entget (ssname CDTB 0))
  	;CDTC_11 (atof (cdr (assoc 1 CDTC_1)))
     ; )
    ;(setq CDTC_2 (entget (ssname CDTB 1))
     ; CDTC_22 (atof (cdr (assoc 1 CDTC_2)))
     ; )
    ;(setq CDTC_3 (entget (ssname CDTB 2))
     ; CDTC_33 (atof (cdr (assoc 1 CDTC_3)))
     <img src='http://www.cadviet.com/forum/public/style_emoticons/<#EMO_DIR#>/wink.png' class='bbc_emoticon' alt=';)' />
   ; (setq CDTC_4 (entget (ssname CDTB 3))
     ; CDTC_44 (atof (cdr (assoc 1 CDTC_4)))
	; )
    (setq N (1+ N))
    );dong vong lap repeat
  (princ)
  );ket thuc ham
     
      
********************************************
;chuong trinh chinh goi cac ham tren
;ve o luoi
(defun c:vol ()
  (vol)
  )
;ghi thu tu o luoi
(defun c:TTOL ()
  (TTOL)
  )
;them text vao text cu
(defun c:themtext ()
  (themtext)
  )
;tinh cao do thi cong
(defun c:CDTC ()
  (CDTC)
    )
;ve ranh gioi dao dap
(defun c:RGDD ()
  (RGDD)
  )
;tinh cao do trung binh o luoi
(defun c:CDTB ()
  (CDTB)
  (setq Timfile (findfile "ve o luoi va tinh gia tri o luoi.LSP"))
  (load Timfile)
  (prompt Timfile)
  (princ)
  )
;lap bang tong hop khoi luong
(defun c:THKL ()
  (THKL)
  )

chào bác: e mới bắt đầu học san nền nên ko biết cách dùng lisp của bác?

bác có thể chỉ cách dùng lisp này ko ạ

Chia sẻ bài đăng này


Liên kết tới bài đăng
Chia sẻ trên các trang web khác
ongke21    0

có bác nào có lisp để tìm giao điểm giữa một đường thẳng có z=const với các đường đồng mức khi vẽ trên bình đồ không?cho em xin tham khảo với. thanks các bác!

Chia sẻ bài đăng này


Liên kết tới bài đăng
Chia sẻ trên các trang web khác
phamthanhbinh    3.123

có bác nào có lisp để tìm giao điểm giữa một đường thẳng có z=const với các đường đồng mức khi vẽ trên bình đồ không?cho em xin tham khảo với. thanks các bác!

 

Hề hề hề,

Bạn tham khảo cái này xem có dùng được không nhé. Nếu cần bỏ sung gì thì post lên.

http://www.cadviet.com/upfiles/3/5194_timgiaodiemvoiddm_1.lsp

  • Vote tăng 1

Chia sẻ bài đăng này


Liên kết tới bài đăng
Chia sẻ trên các trang web khác
ongke21    0

cảm kích bác PhamThanhBinh vô cùng. bác có thể cho em hỏi thêm là sau khi mình tìm được cao độ giao điểm rồi thì có thể gán cao độ đó cho giao điểm mình vừa tìm được không bác? thanks bác.

Chia sẻ bài đăng này


Liên kết tới bài đăng
Chia sẻ trên các trang web khác

Tạo một tài khoản hoặc đăng nhập để nhận xét

Bạn cần phải là một thành viên để lại một bình luận

Tạo tài khoản

Đăng ký một tài khoản mới trong cộng đồng của chúng tôi. Điều đó dễ mà.

Đăng ký tài khoản mới

Đăng nhập

Bạn có sẵn sàng để tạo một tài khoản ? Đăng nhập tại đây.

Đăng nhập ngay


×