Chuyển đến nội dung
Diễn đàn CADViet

lenhatanh

Thành viên
  • Số lượng nội dung

    72
  • Đã tham gia

  • Lần ghé thăm cuối

Bài đăng được đăng bởi lenhatanh


  1. 1. Bạn tạo 1 project mới, với Templates là ObjectArx/... Templates này sẽ có khi bạn cài ObjARXWiz.msi

    5987103980_c31aeb69b7.jpg

    h2 của kthung78, trên Flickr

    2. Thứ tự các bước khởi tạo cho Project Arx của bạn

    5987104042_8576f2e735.jpg

    h3 của kthung78, trên Flickr

     

    5987104096_4d2afb9ce9.jpg

    h4 của kthung78, trên Flickr

     

    5986545209_8595b54d28.jpg

    h5 của kthung78, trên Flickr

     

    5986545247_a115038eef.jpg

    h6 của kthung78, trên Flickr

     

    5987104310_3bd4aa406d.jpg

    h8 của kthung78, trên Flickr

     

    5986545423_c70c8faab0.jpg

    h9 của kthung78, trên Flickr

     

    5986545473_9dab0ebff1.jpg

    h10 của kthung78, trên Flickr

     

    5987104558_790ddecbf9.jpg

    h13 của kthung78, trên Flickr

     

    5987104634_6ca91967fc.jpg

    h14 của kthung78, trên Flickr

     

    5987104692_0d36602f79.jpg

    h15 của kthung78, trên Flickr

     

    5987104812_0712ca240e.jpg

    h17 của kthung78, trên Flickr

     

    Bạn có thể gửi cho mình Project này không, mình bắt đầu học về Object ARX.

    địa chỉ mail:  dunggiamdinh@gmail.com

    rất cảm ơn.


  2. Hi Detailing !

    mình đang học và thử build một file *.arx (dùng VS2005, CAD2007, ObjectARX 2007, 2006) nhưng khi build project thi bị lỗi như sau: ... cannot open file 'mfc70.lib'

    Nhờ bạn chỉ cho mình cách khắc phục lỗi trên với. (mình đã tìm 'mfc70.lib' trên máy và trên "Google" nhưng không tìm thấy file mfc70.lib).


  3. Tôi có một file Excel và một lisp để mở file Excel rồi ghi số liệu mới vào.

    Tôi muốn lisp thực hiện theo hai cách sau:

    1- Mở file Excel, xóa toàn bộ nội dung cũ trong các Sheet để ghi số liệu mới.

    2- Mở file Excel, xóa toàn bộ các Sheet cũ, tạo các Sheet mới và ghi số liệu mới.

    Tôi quá kém về các hàm Vla... nên không thực hiện được, nhờ mọi người giúp đỡ nhé,

    xin cảm ơn.

    fIle Excel:  http://www.cadviet.com/upfiles/3/88193_du_tkk_1.rar

    file lsp:

    ; Test lisp 09/09/2014
    ;-----------------------------------------------------------------------------------------
    (defun C:excel()
      (vl-load-com)
      (setq lst_Sheet '("Kenh_chinh" "Kenh_CI" "Kenh_CII" "Kenh_CIII" "Kenh_ND"))
      (if (not fn)
        (progn
    	  (setq fn (getfiled "Select Excel File" "" "xls" 0))
    	  (if fn
            (progn
    		  (WriteToExcel fn lst_Sheet T)
    		)
    		(progn
    		  (WriteToExcel nil lst_Sheet T)
            )
    	  )	
    	)
      )
    )
    ;------------------------------------------------------------------------------
    (defun WriteToExcel (ExcelFile$ lst_Sheet Visible / Sheet$ Sheets@ Worksheet n)
      (if (= (type ExcelFile$) 'STR)
        (if (findfile ExcelFile$)
          (setq *ExcelFile$ ExcelFile$)
          (progn
            (alert (strcat "Excel file " ExcelFile$ " not found."))
            (exit)
          )
        )
        (setq *ExcelFile$ "")
      )
      (gc)
      (if (setq *ExcelApp% (vlax-get-object "Excel.Application"))
        (progn
          (alert "Close all Excel spreadsheets to continue!")
          (vlax-release-object *ExcelApp%)(gc)
        )
      )
      (setq *ExcelApp% (vlax-get-or-create-object "Excel.Application"))
      (if ExcelFile$
        (if (findfile ExcelFile$)
          (vlax-invoke-method (vlax-get-property *ExcelApp% 'WorkBooks) 'Open ExcelFile$)
          (vlax-invoke-method (vlax-get-property *ExcelApp% 'WorkBooks) 'Add)
        )
        (vlax-invoke-method (vlax-get-property *ExcelApp% 'WorkBooks) 'Add)
      )
      (if Visible
        (vla-put-visible *ExcelApp% :vlax-true)
      )
      (setq n 0)
      (repeat (length lst_Sheet)
        (setq SheetName$ (nth n lst_Sheet))
        (if (= (type SheetName$) 'STR)
          (progn
            (vlax-for Sheet$ (vlax-get-property *ExcelApp% "Sheets")
              (setq Sheets@ (append Sheets@ (list (vlax-get-property Sheet$ "Name"))))
            )
    ;		(if (member SheetName$ Sheets@)
    ;          (vlax-for Worksheet (vlax-get-property *ExcelApp% "Sheets")
    ;            (if (= (vlax-get-property Worksheet "Name") "Kenh_ND")
    ;              (vlax-invoke-method Worksheet "Delete")
    ;            )
    ;          )
    ;        )
    		(if (member SheetName$ Sheets@)
              (vlax-for Worksheet (vlax-get-property *ExcelApp% "Sheets")
                (if (= (vlax-get-property Worksheet "Name") "Kenh_ND")
                  (vlax-invoke-method Worksheet "ClearContents")
                )
              )
            )
            (if (member SheetName$ Sheets@)
              (vlax-for Worksheet (vlax-get-property *ExcelApp% "Sheets")
                (if (= (vlax-get-property Worksheet "Name") SheetName$)
                  (vlax-invoke-method Worksheet "Activate")	  
                )
              )
              (vlax-put-property (vlax-invoke-method (vlax-get-property *ExcelApp% "Sheets") "Add") "Name" SheetName$)
    		)
          )
        )
        (setq n (1+ n))
      )
      (princ)
    )
    

  4. Bạn có thể viết một đoạn code thể hiện \p hoặc \x được không ? mình đang vướng chỗ này.

    (defun c:dii ()
      (setq i 1)
      (while
        (setq ee (car (entsel "\n Chon Doi tuong: ")))
        (setq di (cdr (assoc 10 (entget ee))))
        (setq tbl (strcat "Block " (rtos i 2 0)))
        (command "_Dimaligned" "L" "M" "" tbl di)
        (setq i (+ i 1))
      )
      (princ)
    )
    

  5. Nếu là chủ đầu tư thì yêu cầu cấp, nếu là đơn vị thi công thì xin TVTK file tiên lượng của hạng mục này.

    Trong đó sẽ có đầy đủ diễn toán tính khối lượng của từng công tác (w=Dài*Rộng*Cao*số cấu kiện)...

     - Phá dỡ cống cũ phải có bản vẽ hiện trạng cống cũ mới tính được.

     - Phải có phần vẽ thép của cống mới tính được khối lượng (hoặc nhân bao nhiêu cân một khối BT).

     - Nếu cống giống y chang định hình thì xin tên định hình... trong đó có khối lượng cơ bản.

    Chúc hoàn thành công việc !

    • Vote tăng 1

  6. Mình có một đoạn code vẽ đường thẳng qua hai điểm sẽ được nhập trên màn hình:  

     

    (defun C:Ve (/ d1 d2)

       (command "line" (setq d1 (getpoint "\nStart point... : ")))

       (command (setq d2 (getpoint "\nEnd point... : ")))

       (command "")

    )

     

    Mình muốn khi thực hiện lênh c:ve sẽ làm được như sau:

     - Sau khi pick điểm d1 trêm màn hình sẽ xuất hiện dây chun quay quanh điểm d1 như lệnh "line" hoặc Pline" của CAD để chọn tiếp điểm d2..

     - Có thể chọn "ortho" ON hoặc OFF để có thể chọn điểm d2 thẳng hàng (đứng hoặc ngang) so với điểm d1.

    Nhờ các bạn chỉ giúp cách viết lại đoạn code trên nhé, xin cảm ơn trước.

     

    • Vote giảm 1

  7. Bạn nào có Hồ sơ thiết kế (bản vẽ thi công càng tốt) một công trình bất kỳ: thủy lợi, thủy điện, giao thông, xây dựng... do nước ngoài thiết kế thì cho mình xin để tham khảo nhé.

    File CAD càng tốt nhé, hồ sơ xin post lên diễn đàn hoặc gửi cho mình theo đ/c: dunggiamdinh@gmail.com

    Xin cảm ơn ! 


  8. Chào phamthanhbinh.

    với ... (command "cecolor"4 "-boundary" pt1 "")...

    theo mình hiểu thì sau khi đổi mmầu vẽ thành màu 4, CAD sẽ thực hiện lênh "-boundary" với điểm pick là pt1.

    mình đã thử với nhiều bản vẽ thì thấy như sau:

      1- Mở bản vẽ cũ ra (các hình đã vẽ từ trước) thì sau khi pick điểm (pt1) các đường Polyline do lệnh "-boundary" tạo ra bị ẩn (nằm ở lớp dưới nên không nhìn thấy được), nết rê chuột qua thì thấy hilight. Do đó không rõ mình đã pick đủ hình chưa ? 

      2- Cũng trên bản vẽ đó, bạn vẽ một miền kín mới và sử dụng lisp thì các đường Polyline do lệnh "-boundary" tạo ra hiện mầu 4 và nằm ở lớp trên, cho bạn biết đã pick những vùng nào, pick đủ hình chưa.

      3- còn (command "erase" ss "") là xóa hết những đường Polyline do lệnh "-boundary" tạo ra sau khi đã xuất hiện cho bạn xem (= màu 4), trả lại bản vẽ như cũ...

    Nhờ bạn và các bạn trên diễn đàn góp ý kiến để khắc phục cho trường hợp 1. 


  9. Chào các bạn.

    Các bạn cho mình hỏi có lệnh hoặc "set" biến hệ thống nào để các Polylines được tạo ra sau khi dùng lệnh "Boundary"

    luôn nằm trên cùng (nhìn thấy được theo màu của layer hiện hành).

    [Vì mình đang dùng lisp "Tính diện tích và lập bảng", khi mở bản vẽ cũ ra, pick vào miền kín thì không thấy đường bao đổi mầu như lênh trong lisp: (command "Cecolor" 4 "-boundary" pt1 "")... còn khi vẽ một miền kín mới rồi pick... thì OK.]

    mình đang dùng CAD-2010.

    ;; free lisp from cadviet.com
    ;;; this lisp was downloaded from http://www.cadviet.com/forum/topic/12432-da-xong-nho-giup-lisp-tinh-dien-tich-va-lap-bang/page-2
    
    
    (defun c:bdt()
    
    (setvar "cmdecho" 0)
    
    (command "undo" "begin")
    
    (setq lacol (getvar "CEColor"))
    
    (setq ladin (getvar "dimzin"))
    
    (setq laos (getvar "osmode"))  
    
    (if (not tl) (setq tl 1))
    
    (if (not h) (setq h 1))
    
    (setq tl1 (getreal (strcat "\nty le ban ve < 1/" (rtos tl 2 0) " >: 1/"))
    
        caot1 (getreal (strcat "\nCao text < " (rtos h 2 2) " >: ")))
    
    (if tl1 (setq tl tl1))
    
    (if caot1 (setq h caot1))
    
    (setq k 0 tdt 0)
    
    
    
    (setvar "dimzin" 0)
    
    (setvar "OSMODE" 0)
    
    (setq PT (getpoint "\nChon diem xuat bang thong ke dien tich (mep trai):"))
    
    (setq     P1 (list (+ (car PT)(* 6 h)) (cadr PT))
    
        P2 (list (+ (car PT)(* 22 h)) (cadr PT))
    
        P3 (list (car PT) (- (cadr PT)(* 3 h)))
    
        P4 (list (car P1) (cadr P3))
    
        P5 (list (car P2) (cadr P3))
    
        P6 (list (+ (car PT)(* 11 h)) (+ (cadr PT)(* 2 h)))
    
        P7 (list (+ (car PT)(* 3 h)) (- (cadr PT)(* 1.5 h)))
    
        P8 (list (+ (car PT)(* 14 h)) (- (cadr PT)(* 1.5 h)))
    
    );setq
    
    (command "pline" PT P2 P5 P3 "C"
    
            "pline" P1 P4 ""
    
            "text" "m" P6 (* 1.2 h) 0 "%%UB¶ng thèng kª diÖn tÝch"
    
            "text" "m" P7 h 0 "STT"
    
            "text" "m" P8 h 0 "DiÖn tÝch (m2)"
    
    );command
    
    
    
    (setq pt1 (getpoint "\n Chon mien tinh dien tich : "))
    
    (while (/= pt1 nil)
    
    (command "erase" ss "")
    
    (setq k (+ 1 k))
    
    (command "TEXT" "m" pt1 (* 3 h) 0 (rtos k 2 0))
    
    (setq PT (list (car P3) (cadr P3))
    
        P1 (list (+ (car PT)(* 6 h)) (cadr PT))
    
        P2 (list (+ (car PT)(* 22 h)) (cadr PT))
    
        P3 (list (car PT) (- (cadr PT)(* 3 h)))
    
        P4 (list (car P1) (cadr P3))
    
        P5 (list (car P2) (cadr P3))
    
        P7 (list (+ (car PT)(* 3 h)) (- (cadr PT)(* 1.5 h)))
    
        P8 (list (+ (car PT)(* 14 h)) (- (cadr PT)(* 1.5 h)))
    
        P9 (list (car PT) (- (cadr P3)(* 3 h)))
    
        P10 (list (car P1) (cadr P9))
    
        P11 (list (car P2) (cadr P9))
    
        P12 (list (car P7) (- (cadr P3)(* 1.5 h)))
    
        P13 (list (car P8) (cadr P12))
    
        );setq
    
    (setq frome (entlast));; chon doi tuong cuoi cung truoc khi boundary
    
    (command "cecolor"4 "-boundary" pt1 "");; boundary
    
    (setq toe (entlast));; chon doi tuong cuoi cung sau khi boundary
    
    (setq cur frome	ss (ssadd) S 0)
    
    (while 	(not (eq cur toe));; chon cac doi tuong tu frome den toe
    
    	(setq cur (entnext cur) ss (ssadd cur ss))
    
    	(command "area" "S" "O" ss "" "")
    
    	(setq dt (getvar "area") S (+ S dt))
    
    );while
    
    (command "area" "A" "O" "L" "" "")
    
    (setq dt (getvar "area"))
    
    (setq S (* (+ S (* dt 2)) tl tl) tdt (+ s tdt))  
    
    (setvar "CEColor" lacol)
    
    (command "pline" PT P2 P5 P3 "C"
    
    	 "pline" P1 P4 ""
    
    	 "text" "m" P7 h 0 (rtos k 2 0)
    
    	 "text" "m" P8 h 0 (rtos s 2 2))
    
    (setq pt1 (getpoint (strcat "\nTong dien tich = " (rtos tdt 2 3) "m2. chon mien do tiep theo...")))
    
    );while
    
    (command "erase" ss "")
    
    (setq ss nil)
    
    (setvar "DIMZIN" ladin)
    
    (command     "pline" P3 P9 P11 P5 "C"
    
            "pline" P10 P4 ""
    
            "text" "m" P12 h 0 "Tæng"
    
            "text" "m" P13 h 0 (rtos tdt 2 2)
    
    );command
    
    (setvar "OSMODE" laos)
    
    (command "undo" "end")
    
    (setvar "cmdecho" 1)
    
    )
    
    

     

     


  10. Mọi người dùng thử lisp "Đo diện tích, xuât kết quả ra CAD và Excel" và đóng góp ý kiến nhé.

    Cám ơn sự góp ý, đóng góp và code của các bạn Hà, Bình, Ketxu, tnmtpc...

    - File Dien_tich_01.dcl

    Dientich01 : dialog {
     label = "  *** - TÝnh DiÖn TÝch Cho C¸c MÆt C¾t Ngang - Hec 13";
     fixed_width = center;
    :  boxed_column {
     : row {
    fixed_width = true;
     children_alignment = centered;
     : edit_box {
      label = "Ti Le Ve MCN:";
      key = "tle";
      edit_width = 6;
      edit_height = 1;
    }
     : edit_box {
      label = "Ten Mat Cat:";
      fixed_width = true;
      key = "ten";
      edit_width = 6;
      edit_height = 1;
    }
    : edit_box {
      label = "Khoang Cach C.Don:";
      fixed_width = true;
      key = "cdon";
      edit_width = 6;
      edit_height = 1;
    }
     }
    }
     :spacer { height=0.5; }
    //-----------------------------
    : boxed_column {
     label = "-------------Thanh Phan - Hang Muc Tinh Dien Tich:";
     : row {  
    fixed_width = true;
    children_alignment = Right;
    : toggle {
      key = "t1";
      mnemonic = "b";
     	value = "0";
    }
    : edit_box {
      label = "S";
      key = "e1";
      edit_width = 30;
    }
    : text {
      label = "=                	";
      key = "s1";
      edit_width = 100;
    }
    : button {
      label = "Pick" ;
      is_default = true ;
      key = "p1" ;
      width = 26;
    }
     }
    //-----------------------------
     : row {  
    fixed_width = true;
    children_alignment = Right;
    : toggle {
      key = "t2";
      mnemonic = "b";
     	value = "0";
    }
    : edit_box {
      label = "S";
      key = "e2";
      edit_width = 30;
    }
    : text {
      label = "=                	";
      key = "s2";
      edit_width = 100;
    }
    : button {
      label = "Pick" ;
      is_default = true ;
      key = "p2" ;
      width = 26;
    }
     }
    //-----------------------------
     : row {  
    fixed_width = true;
    children_alignment = Right;
    : toggle {
      key = "t3";
      mnemonic = "b";
     	value = "0";
    }
    : edit_box {
      label = "S";
      key = "e3";
      edit_width = 30;
    }
    : text {
      label = "=                	";
      key = "s3";
      edit_width = 100;
    }
    : button {
      label = "Pick" ;
      is_default = true ;
      key = "p3" ;
      width = 26;
    }
     }
    //-----------------------------
     : row {  
    fixed_width = true;
    children_alignment = Right;
    : toggle {
      key = "t4";
      mnemonic = "b";
     	value = "0";
    }
    : edit_box {
      label = "S";
      key = "e4";
      edit_width = 30;
    }
    : text {
      label = "=                	";
      key = "s4";
      edit_width = 100;
    }
    : button {
      label = "Pick" ;
      is_default = true ;
      key = "p4" ;
      width = 26;
    }
     }
    //-----------------------------
     : row {  
    fixed_width = true;
    children_alignment = Right;
    : toggle {
      key = "t5";
      mnemonic = "b";
     	value = "0";
    }
    : edit_box {
      label = "S";
      key = "e5";
      edit_width = 30;
    }
    : text {
      label = "=                	";
      key = "s5";
      edit_width = 100;
    }
    : button {
      label = "Pick" ;
      is_default = true ;
      key = "p5" ;
      width = 26;
    }
     }
    //-----------------------------
     : row {  
    fixed_width = true;
    children_alignment = Right;
    : toggle {
      key = "t6";
      mnemonic = "b";
     	value = "0";
    }
    : edit_box {
      label = "S";
      key = "e6";
      edit_width = 30;
    }
    : text {
      label = "=                	";
      key = "s6";
      edit_width = 100;
    }
    : button {
      label = "Pick" ;
      is_default = true ;
      key = "p6" ;
      width = 26;
    }
     }
    //-----------------------------
     : row {  
    fixed_width = true;
    children_alignment = Right;
    : toggle {
      key = "t7";
      mnemonic = "b";
     	value = "0";
    }
    : edit_box {
      label = "S";
      key = "e7";
      edit_width = 30;
    }
    : text {
      label = "=                	";
      key = "s7";
      edit_width = 100;
    }
    : button {
      label = "Pick" ;
      is_default = true ;
      key = "p7" ;
      width = 26;
    }
     }  
    //-----------------------------
     : row {  
    fixed_width = true;
    children_alignment = Right;
    : toggle {
      key = "t8";
      mnemonic = "b";
     	value = "0";
    }
    : edit_box {
      label = "S";
      key = "e8";
      edit_width = 30;
    }
    : text {
      label = "=                	";
      key = "s8";
      edit_width = 100;
    }
    : button {
      label = "Pick" ;
      is_default = true ;
      key = "p8" ;
      width = 26;
    }
     }  
    //-----------------------------
     : row {  
    fixed_width = true;
    children_alignment = Right;
    : toggle {
      key = "t9";
      mnemonic = "b";
     	value = "0";
    }
    : edit_box {
      label = "S";
      key = "e9";
      edit_width = 30;
    }
    : text {
      label = "=                	";
      key = "s9";
      edit_width = 100;
    }
    : button {
      label = "Pick" ;
      is_default = true ;
      key = "p9" ;
      width = 26;
    }
     }
    //-----------------------------
     : row {  
    fixed_width = true;
    children_alignment = Right;
    : toggle {
      key = "t10";
      mnemonic = "b";
     	value = "0";
    }
    : edit_box {
      label = "S";
      key = "e10";
      edit_width = 30;
    }
    : text {
      label = "=                	";
      key = "s10";
      edit_width = 100;
    }
    : button {
      label = "Pick" ;
      is_default = true ;
      key = "p10" ;
      width = 26;
    }
     }
    }
    //-----------------------------    
     : row {
    fixed_height = true;
    children_alignment = centered;
    : spacer { height=3; }
    // : spacer { width=3; }
    : button {
      label = "Xuat sang Excel" ;
      is_default = true ;
      key = "excel" ;
      width = 20;
    }
    : button {
      label = "OK" ;
      is_default = true ;
      key = "start" ;
      width = 20;
    }
    : button {
      label = "Cancel" ;
      width = 20;
      is_cancel= true ;
    }
    // : text_part { label = "paragraph 1"; }
    // : paragraph {
    //   : text_part { label = "paragraph 1"; }
    //   : spacer { height=0.1; }
    //   : text_part { label = "paragraph 2"; }
    //   : text_part { label = "paragraph 3"; }
    // }
    // : paragraph {
    //   : concatenation {
    // 	: text_part {label = "column 1";}
    // 	: text_part {label = "column 2";}
    // 	: text_part {label = "column 3";}
    //   }
    // }
    :spacer { height=0.1; }
     }
    }
    

    - File lisp:

    ;---------Tinh Dien Tich Dao, Dap (Cho M.cat) - dientich-01
    ;**********************************************************
    (defun Get_tle (/ g:tle)
     (set_tile "error" "")
     (setq g:tle (get_tile "tle"))
     (setq tle (atof g:tle))
    )
    ;------------------------------------------
    (defun Get_ten (/ g:ten)
     (set_tile "error" "")
     (setq g:ten (get_tile "ten"))
     (setq ten g:ten)
    )
    ;------------------------------------------
    (defun Get_cdon (/ g:cdon)
     (set_tile "error" "")
     (setq g:cdon (get_tile "cdon"))
     (setq cdon (atof g:cdon))
    )
    ;------------------------------------------
    ;------------------------------------------
    (defun Get_t1()
     (set_tile "error" "")
     (setq g:t1 (get_tile "t1"))
     (setq t1 g:t1)
     (cond
    ((= g:t1 "1")
     	(mode_tile "e1" 0)
     	(mode_tile "s1" 0)
     	(mode_tile "p1" 0)
    )
    (T
     	(mode_tile "e1" 1)
     	(mode_tile "s1" 1)
     	(mode_tile "p1" 1)
     	(set_tile "e1" (setq g:e1 ""))
     	(set_tile "s1" (STRCAT "= " (setq g:s1 (rtos 0.0 2 3)) " m2"))
    )
     )
    )
    ;------------------------------------------
    (defun Get_t2()
     (set_tile "error" "")
     (setq g:t2 (get_tile "t2"))
     (setq t2 g:t2)
     (cond
    ((= g:t2 "1")
     	(mode_tile "e2" 0)
     	(mode_tile "s2" 0)
     	(mode_tile "p2" 0)
    )
    (T
     	(mode_tile "e2" 1)
     	(mode_tile "s2" 1)
     	(mode_tile "p2" 1)
     	(set_tile "e2" (setq g:e2 ""))
     	(set_tile "s2" (STRCAT "= " (setq g:s2 (rtos 0.0 2 3)) " m2"))
    )
     )
    )
    ;------------------------------------------
    (defun Get_t3()
     (set_tile "error" "")
     (setq g:t3 (get_tile "t3"))
     (setq t3 g:t3)
     (cond
    ((= g:t3 "1")
     	(mode_tile "e3" 0)
     	(mode_tile "s3" 0)
     	(mode_tile "p3" 0)
    )
    (T
     	(mode_tile "e3" 1)
     	(mode_tile "s3" 1)
     	(mode_tile "p3" 1)
     	(set_tile "e3" (setq g:e3 ""))
     	(set_tile "s3" (STRCAT "= " (setq g:s3 (rtos 0.0 2 3)) " m2"))
    )
     )
    )
    ;------------------------------------------
    (defun Get_t4()
     (set_tile "error" "")
     (setq g:t4 (get_tile "t4"))
     (setq t4 g:t4)
     (cond
    ((= g:t4 "1")
     	(mode_tile "e4" 0)
     	(mode_tile "s4" 0)
     	(mode_tile "p4" 0)
    )
    (T
     	(mode_tile "e4" 1)
     	(mode_tile "s4" 1)
     	(mode_tile "p4" 1)
     	(set_tile "e4" (setq g:e4 ""))
     	(set_tile "s4" (STRCAT "= " (setq g:s4 (rtos 0.0 2 3)) " m2"))
    )
     )
    )
    ;------------------------------------------
    (defun Get_t5()
     (set_tile "error" "")
     (setq g:t5 (get_tile "t5"))
     (setq t5 g:t5)
     (cond
    ((= g:t5 "1")
     	(mode_tile "e5" 0)
     	(mode_tile "s5" 0)
     	(mode_tile "p5" 0)
    )
    (T
     	(mode_tile "e5" 1)
     	(mode_tile "s5" 1)
     	(mode_tile "p5" 1)
     	(set_tile "e5" (setq g:e5 ""))
     	(set_tile "s5" (STRCAT "= " (setq g:s5 (rtos 0.0 2 3)) " m2"))
    )
     )
    )
    ;------------------------------------------
    (defun Get_t6()
     (set_tile "error" "")
     (setq g:t6 (get_tile "t6"))
     (setq t6 g:t6)
     (cond
    ((= g:t6 "1")
     	(mode_tile "e6" 0)
     	(mode_tile "s1" 0)
     	(mode_tile "p6" 0)
    )
    (T
     	(mode_tile "e6" 1)
     	(mode_tile "s6" 1)
     	(mode_tile "p6" 1)
     	(set_tile "e6" (setq g:e6 ""))
     	(set_tile "s6" (STRCAT "= " (setq g:s6 (rtos 0.0 2 3)) " m2"))
    )
     )
    )
    ;------------------------------------------
    (defun Get_t7()
     (set_tile "error" "")
     (setq g:t7 (get_tile "t7"))
     (setq t7 g:t7)
     (cond
    ((= g:t7 "1")
     	(mode_tile "e7" 0)
     	(mode_tile "s7" 0)
     	(mode_tile "p7" 0)
    )
    (T
     	(mode_tile "e7" 1)
     	(mode_tile "s7" 1)
     	(mode_tile "p7" 1)
     	(set_tile "e7" (setq g:e7 ""))
     	(set_tile "s7" (STRCAT "= " (setq g:s7 (rtos 0.0 2 3)) " m2"))
    )
     )
    )
    ;------------------------------------------
    (defun Get_t8()
     (set_tile "error" "")
     (setq g:t8 (get_tile "t8"))
     (setq t8 g:t8)
     (cond
    ((= g:t8 "1")
     	(mode_tile "e8" 0)
     	(mode_tile "s8" 0)
     	(mode_tile "p8" 0)
    )
    (T
     	(mode_tile "e8" 1)
     	(mode_tile "s8" 1)
     	(mode_tile "p8" 1)
     	(set_tile "e8" (setq g:e8 ""))
     	(set_tile "s8" (STRCAT "= " (setq g:s8 (rtos 0.0 2 3)) " m2"))
    )
     )
    )
    ;------------------------------------------
    (defun Get_t9()
     (set_tile "error" "")
     (setq g:t9 (get_tile "t9"))
     (setq t9 g:t9)
     (cond
    ((= g:t9 "1")
     	(mode_tile "e9" 0)
     	(mode_tile "s9" 0)
     	(mode_tile "p9" 0)
    )
    (T
     	(mode_tile "e9" 1)
     	(mode_tile "s9" 1)
     	(mode_tile "p9" 1)
     	(set_tile "e9" (setq g:e9 ""))
     	(set_tile "s9" (STRCAT "= " (setq g:s9 (rtos 0.0 2 3)) " m2"))
    )
     )
    )
    ;------------------------------------------
    (defun Get_t10()
     (set_tile "error" "")
     (setq g:t10 (get_tile "t10"))
     (setq t10 g:t10)
     (cond
    ((= g:t10 "1")
     	(mode_tile "e10" 0)
     	(mode_tile "s10" 0)
     	(mode_tile "p10" 0)
    )
    (T
     	(mode_tile "e10" 1)
     	(mode_tile "s10" 1)
     	(mode_tile "p10" 1)
     	(set_tile "e10" (setq g:e10 ""))
     	(set_tile "s10" (STRCAT "= " (setq g:s10 (rtos 0.0 2 3)) " m2"))
    )
     )
    )
    ;------------------------------------------
    ;------------------------------------------
    (defun Get_e1()
     (set_tile "error" "")
     (setq g:e1 (get_tile "e1"))
     (setq e1 g:e1)
    )
    ;------------------------------------------
    (defun Get_e2()
     (set_tile "error" "")
     (setq g:e2 (get_tile "e2"))
     (setq e2 g:e2)
    )
    ;------------------------------------------
    (defun Get_e3()
     (set_tile "error" "")
     (setq g:e3 (get_tile "e3"))
     (setq e3 g:e3)
    )
    ;------------------------------------------
    (defun Get_e4()
     (set_tile "error" "")
     (setq g:e4 (get_tile "e4"))
     (setq e4 g:e4)
    )
    ;------------------------------------------
    (defun Get_e5()
     (set_tile "error" "")
     (setq g:e5 (get_tile "e5"))
     (setq e5 g:e5)
    )
    ;------------------------------------------
    (defun Get_e6()
     (set_tile "error" "")
     (setq g:e6 (get_tile "e6"))
     (setq e6 g:e6)
    )
    ;------------------------------------------
    (defun Get_e7()
     (set_tile "error" "")
     (setq g:e7 (get_tile "e7"))
     (setq e7 g:e7)
    )
    ;------------------------------------------
    (defun Get_e8()
     (set_tile "error" "")
     (setq g:e8 (get_tile "e8"))
     (setq e8 g:e8)
    )
    ;------------------------------------------
    (defun Get_e9()
     (set_tile "error" "")
     (setq g:e9 (get_tile "e9"))
     (setq e9 g:e9)
    )
    ;------------------------------------------
    (defun Get_e10()
     (set_tile "error" "")
     (setq g:e10 (get_tile "e10"))
     (setq e10 g:e10)
    )
    ;------------------------------------------
    ;------------------------------------------
    (defun Get_p1()
     (set_tile "error" "")
     (dientich)
    ;  (alert (strcat "\n tri so g:btct = " g:btct))
    )
    ;------------------------------------------
    (defun Get_p2()
     (set_tile "error" "")
     (dientich)
    )
    ;------------------------------------------
    (defun Get_p3()
     (set_tile "error" "")
     (dientich)
    )
    ;------------------------------------------
    (defun Get_p4()
     (set_tile "error" "")
     (dientich)
    )
    ;------------------------------------------
    (defun Get_p5()
     (set_tile "error" "")
     (dientich)
    )
    ;------------------------------------------
    (defun Get_p6()
     (set_tile "error" "")
     (dientich)
    )
    ;------------------------------------------
    (defun Get_p7()
     (set_tile "error" "")
     (dientich)
    )
    ;------------------------------------------
    (defun Get_p8()
     (set_tile "error" "")
     (dientich)
    )
    ;------------------------------------------
    (defun Get_p9()
     (set_tile "error" "")
     (dientich)
    )
    ;------------------------------------------
    (defun Get_p10()
     (set_tile "error" "")
     (dientich)
    )
    ;------------------------------------------
    ;;;mode_tile - 0 = an (Tat), 1 = Hien (mo)
    ;------------------------------------------
    (defun Setloc()
     (if (not tle) (setq tle 50.0))
     (set_tile "tle" (setq g:tle (rtos tle 2 0)))
    
     (if (not ten) (setq ten "A-A"))
     (set_tile "ten" (setq g:ten ten))
    
     (if (not cdon) (setq cdon 0.0))
     (set_tile "cdon" (setq g:cdon (rtos cdon 2 2)))
    
     (if (not e1) (setq e1 ""))
     (set_tile "e1" (setq g:e1 e1))
    
     (if (not e2) (setq e2 ""))
     (set_tile "e2" (setq g:e2 e2))
    
     (if (not e3) (setq e3 ""))
     (set_tile "e3" (setq g:e3 e3))
    
     (if (not e4) (setq e4 ""))
     (set_tile "e4" (setq g:e4 e4))
    
     (if (not e5) (setq e5 ""))
     (set_tile "e5" (setq g:e5 e5))
    
     (if (not e6) (setq e6 ""))
     (set_tile "e6" (setq g:e6 e6))
    
     (if (not e7) (setq e7 ""))
     (set_tile "e7" (setq g:e7 e7))
    
     (if (not e8) (setq e8 ""))
     (set_tile "e8" (setq g:e8 e8))
    
     (if (not e9) (setq e9 ""))
     (set_tile "e9" (setq g:e9 e9))
    
     (if (not e10) (setq e10 ""))
     (set_tile "e10" (setq g:e10 e10))
    
     (if (not dt1) (setq dt1 0.0))
     (set_tile "s1" (STRCAT "= " (setq g:s1 (rtos dt1 2 3)) " m2"))
    
     (if (not dt2) (setq dt2 0.0))
     (set_tile "s2" (STRCAT "= " (setq g:s2 (rtos dt2 2 3)) " m2"))
    
     (if (not dt3) (setq dt3 0.0))
     (set_tile "s3" (STRCAT "= " (setq g:s3 (rtos dt3 2 3)) " m2"))
    
     (if (not dt4) (setq dt4 0.0))
     (set_tile "s4" (STRCAT "= " (setq g:s4 (rtos dt4 2 3)) " m2"))
    
     (if (not dt5) (setq dt5 0.0))
     (set_tile "s5" (STRCAT "= " (setq g:s5 (rtos dt5 2 3)) " m2"))
    
     (if (not dt6) (setq dt6 0.0))
     (set_tile "s6" (STRCAT "= " (setq g:s6 (rtos dt6 2 3)) " m2"))
    
     (if (not dt7) (setq dt7 0.0))
     (set_tile "s7" (STRCAT "= " (setq g:s7 (rtos dt7 2 3)) " m2"))
    
     (if (not dt8) (setq dt8 0.0))
     (set_tile "s8" (STRCAT "= " (setq g:s8 (rtos dt8 2 3)) " m2"))
    
     (if (not dt9) (setq dt9 0.0))
     (set_tile "s9" (STRCAT "= " (setq g:s9 (rtos dt9 2 3)) " m2"))
    
     (if (not dt10) (setq dt10 0.0))
     (set_tile "s10" (STRCAT "= " (setq g:s10 (rtos dt10 2 3)) " m2"))
     (if (not g:t1) (setq g:t1 "1"))
     (set_tile "t1" g:t1)
     (cond
    ((= g:t1 "1")
     	(mode_tile "e1" 0)
     	(mode_tile "s1" 0)
     	(mode_tile "p1" 0)
    )
    (T
     	(mode_tile "e1" 1)
     	(mode_tile "s1" 1)
     	(mode_tile "p1" 1)
    )
     )
     (if (not g:t2) (setq g:t2 "0"))
     (set_tile "t2" g:t2)
     (cond
    ((= g:t2 "1")
     	(mode_tile "e2" 0)
     	(mode_tile "s2" 0)
     	(mode_tile "p2" 0)
    )
    (T
     	(mode_tile "e2" 1)
     	(mode_tile "s2" 1)
     	(mode_tile "p2" 1)
    )
     )
     (if (not g:t3) (setq g:t3 "0"))
     (set_tile "t3" g:t3)
     (cond
    ((= g:t3 "1")
     	(mode_tile "e3" 0)
     	(mode_tile "s3" 0)
     	(mode_tile "p3" 0)
    )
    (T
     	(mode_tile "e3" 1)
     	(mode_tile "s3" 1)
     	(mode_tile "p3" 1)
    )
     )
     (if (not g:t4) (setq g:t4 "0"))
     (set_tile "t4" g:t4)
     (cond
    ((= g:t4 "1")
     	(mode_tile "e4" 0)
     	(mode_tile "s4" 0)
     	(mode_tile "p4" 0)
    )
    (T
     	(mode_tile "e4" 1)
     	(mode_tile "s4" 1)
     	(mode_tile "p4" 1)
    )
     )
     (if (not g:t5) (setq g:t5 "0"))
     (set_tile "t5" g:t5)
     (cond
    ((= g:t5 "1")
     	(mode_tile "e5" 0)
     	(mode_tile "s5" 0)
     	(mode_tile "p5" 0)
    )
    (T
     	(mode_tile "e5" 1)
     	(mode_tile "s5" 1)
     	(mode_tile "p5" 1)
    )
     )
     (if (not g:t6) (setq g:t6 "0"))
     (set_tile "t6" g:t6)
     (cond
    ((= g:t6 "1")
     	(mode_tile "e6" 0)
     	(mode_tile "s1" 0)
     	(mode_tile "p6" 0)
    )
    (T
     	(mode_tile "e6" 1)
     	(mode_tile "s6" 1)
     	(mode_tile "p6" 1)
    )
     )
     (if (not g:t7) (setq g:t7 "0"))
     (set_tile "t7" g:t7)
     (cond
    ((= g:t7 "1")
     	(mode_tile "e7" 0)
     	(mode_tile "s7" 0)
     	(mode_tile "p7" 0)
    )
    (T
     	(mode_tile "e7" 1)
     	(mode_tile "s7" 1)
     	(mode_tile "p7" 1)
    )
     )
     (if (not g:t8) (setq g:t8 "0"))
     (set_tile "t8" g:t8)
     (cond
    ((= g:t8 "1")
     	(mode_tile "e8" 0)
     	(mode_tile "s8" 0)
     	(mode_tile "p8" 0)
    )
    (T
     	(mode_tile "e8" 1)
     	(mode_tile "s8" 1)
     	(mode_tile "p8" 1)
    )
     )
     (if (not g:t9) (setq g:t9 "0"))
     (set_tile "t9" g:t9)
     (cond
    ((= g:t9 "1")
     	(mode_tile "e9" 0)
     	(mode_tile "s9" 0)
     	(mode_tile "p9" 0)
    )
    (T
     	(mode_tile "e9" 1)
     	(mode_tile "s9" 1)
     	(mode_tile "p9" 1)
    )
     )
     (if (not g:t10) (setq g:t10 "0"))
     (set_tile "t10" g:t10)
     (cond
    ((= g:t10 "1")
     	(mode_tile "e10" 0)
     	(mode_tile "s10" 0)
     	(mode_tile "p10" 0)
    )
    (T
     	(mode_tile "e10" 1)
     	(mode_tile "s10" 1)
     	(mode_tile "p10" 1)
    )
     )
    )
    ;---------------
    (defun Restore()
     (command "LUPREC" 2 "color" "bylayer" "osmode" 97)
     (setq *ERROR* Olderr)
     (setvar "BLIPMODE" Oldblp) (setvar "CMDECHO" Oldech)
     (setvar "PICKBOX" 4) (setvar "DIMZIN" 8)
    )
    ;----------------------------------------------------------------------------
    (defun C:dientich-01 (/ Oldblp Oldech Olderr Dial nhim What_next ten cdon sdo
     t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 s1 s2 s3 s4 s5 s6 s7 s8 s9 s10
     p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 dt1 dt2 dt3 dt4 dt5 dt6 dt7 dt8 dt9 dt10
     g:e1 g:e2 g:e3 g:e4 g:e5 g:e6 g:e7 g:e8 g:e9 g:e10                    
     g:s1 g:s2 g:s3 g:s4 g:s5 g:s6 g:s7 g:s8 g:s9 g:s10)
     (setq Oldblp (getvar "BLIPMODE") Oldech (getvar "CMDECHO") Olderr *ERROR*)
     (setvar "BLIPMODE" 0) (setvar "DIMZIN" 0) (setvar "PICKBOX" 0) (setvar "CMDECHO" 0)
     (COMMAND "LUPREC" 4 "osnap" "None" "UCS" "W")
    ;----------------------------------------------
    (defun *ERROR* (Msg)
     (princ "\nError: ") (princ Msg)
     (unload_dialog Dial)
     (Restore)
     (princ)
    )
    ;---------------------------------------------
     (setq Dial (load_dialog "Dien_tich_01.DCL"))
     (setq What_next 2)
     (while (> What_next 1)
    (if (not (new_dialog "Dientich01" Dial))
     	(progn (Restore) (exit))
     )
    (Setloc)
    (action_tile "tle" "(Get_tle)")
    (action_tile "ten" "(Get_ten)")
    (action_tile "cdon" "(Get_cdon)")
    
    (action_tile "t1" "(Get_t1)")
    (action_tile "t2" "(Get_t2)")
    (action_tile "t3" "(Get_t3)")
    (action_tile "t4" "(Get_t4)")
    (action_tile "t5" "(Get_t5)")
    (action_tile "t6" "(Get_t6)")
    (action_tile "t7" "(Get_t7)")
    (action_tile "t8" "(Get_t8)")
    (action_tile "t9" "(Get_t9)")
    (action_tile "t10" "(Get_t10)")
    
    (action_tile "e1" "(Get_e1)")
    (action_tile "e2" "(Get_e2)")
    (action_tile "e3" "(Get_e3)")
    (action_tile "e4" "(Get_e4)")
    (action_tile "e5" "(Get_e5)")
    (action_tile "e6" "(Get_e6)")
    (action_tile "e7" "(Get_e7)")
    (action_tile "e8" "(Get_e8)")
    (action_tile "e9" "(Get_e9)")
    (action_tile "e10" "(Get_e10)")
    
    (action_tile "p1" "(done_dialog 2)")
    (action_tile "p2" "(done_dialog 3)")
    (action_tile "p3" "(done_dialog 4)")
    (action_tile "p4" "(done_dialog 5)")
    (action_tile "p5" "(done_dialog 6)")
    (action_tile "p6" "(done_dialog 7)")
    (action_tile "p7" "(done_dialog 8)")
    (action_tile "p8" "(done_dialog 9)")
    (action_tile "p9" "(done_dialog 10)")
    (action_tile "p10" "(done_dialog 11)")
    (action_tile "excel" "(done_dialog 12)")
    (action_tile "Accept" "(done_dialog 1)")
    (action_tile "cancel" "(done_dialog 0)")
    (setq What_next (start_dialog))
    (cond
     	((= What_next 1) (Go))
     	((= What_next 2) (Get_p1))
     	((= What_next 3) (Get_p2))
     	((= What_next 4) (Get_p3))
     	((= What_next 5) (Get_p4))
     	((= What_next 6) (Get_p5))
     	((= What_next 7) (Get_p6))
     	((= What_next 8) (Get_p7))
     	((= What_next 9) (Get_p8))
     	((= What_next 10) (Get_p9))
     	((= What_next 11) (Get_p10))
     	((= What_next 12) (WriteToExcel))
    )
     )
     (unload_dialog Dial)
     (Restore)
     (princ)
    )
    ;;;--------------------------------------------------------------
    (defun dientich (/ bli cmd E Eo En do diem s oldcolor nam Enam)
     (setq do nil s nil Ename (ssadd))
     (setq E "P") (initget 128 "P S")
     (setq Eo (getkword "\nSelect Entity or Pick Point (S/<P>) : "))
     (if Eo (setq E Eo))
     (cond
    ((= E "P")
    (command "color" 112 "linetype" "S" "hidden" "" "osmode" 0)
    (while
      	(setq diem (getpoint "\n Pick point...(<Retern> to end) :"))
      	(command "boundary" diem "" "area" "E" "L")
      	(setq s (getvar "area"))
      	(setq do (cons s do))
      	(setq name (entlast))
      	(setq Ename (ssadd name Ename))    
    )
    (setq Sdo (eval (cons + do)))
    (command "erase" Ename "" "color" "Bylayer" "linetype" "S" "continuous" "")
    )
    (T
    (setq En (ssget))
    (command "area" "E" En)
    (setq Sdo (getvar "area"))
    )
     )
     (setq tile (/ tle 100))
     (cond
    ((= What_next 2) (setq dt1 (* Sdo tile tile)))
    ((= What_next 3) (setq dt2 (* Sdo tile tile)))
    ((= What_next 4) (setq dt3 (* Sdo tile tile)))
    ((= What_next 5) (setq dt4 (* Sdo tile tile)))
    ((= What_next 6) (setq dt5 (* Sdo tile tile)))
    ((= What_next 7) (setq dt6 (* Sdo tile tile)))
    ((= What_next 8) (setq dt7 (* Sdo tile tile)))
    ((= What_next 9) (setq dt8 (* Sdo tile tile)))
    ((= What_next 10) (setq dt9 (* Sdo tile tile)))
    ((= What_next 11) (setq dt10 (* Sdo tile tile)))
     )
    )
    ;;;--------------------------------------------------------------
    (defun Go (/ p Enam Ena m n)
     (SETQ P (GETPOINT "\nStart point...: "))
     (setq oblist (ssadd))
     (if (> dt1 0)
     	(progn
       	(command "text" "J" "R" p "0" (strcat "S " e1 " (m2) ="))
    ;    	(setq obl (entlast) oblist (ssadd obl oblist))
       	(command "text" (polar p 0.0 (getvar "Textsize")) "0" (rtos dt1 2 3))
    ;    	(setq obl (entlast) oblist (ssadd obl oblist))
    ;    	(command "attdef" "" e1 e1 dt1 (polar p 0.0 (getvar "Textsize")) "")
    ;    	(setq obl (entlast) oblist (ssadd obl oblist))
       	(setq p (polar p (- (/ pi 2)) (* (getvar "Textsize") 2.0)))
     	)
     )
     (if (> dt2 0)
     	(progn
       	(command "text" "J" "R" p "0" (strcat "S " e2 " (m2) ="))
       	(command "text" (polar p 0.0 (getvar "Textsize")) "0" (rtos dt2 2 3))
       	(setq p (polar p (- (/ pi 2)) (* (getvar "Textsize") 2.0)))
     	)
     )
     (if (> dt3 0)
     	(progn
       	(command "text" "J" "R" p "0" (strcat "S " e3 " (m2) ="))
       	(command "text" (polar p 0.0 (getvar "Textsize")) "0" (rtos dt3 2 3))
       	(setq p (polar p (- (/ pi 2)) (* (getvar "Textsize") 2.0)))
     	)
     )
     (if (> dt4 0)
     	(progn
       	(command "text" "J" "R" p "0" (strcat "S " e4 " (m2) ="))
       	(command "text" (polar p 0.0 (getvar "Textsize")) "0" (rtos dt4 2 3))
       	(setq p (polar p (- (/ pi 2)) (* (getvar "Textsize") 2.0)))
     	)
     )
     (if (> dt5 0)
     	(progn
       	(command "text" "J" "R" p "0" (strcat "S " e5 " (m2) ="))
       	(command "text" (polar p 0.0 (getvar "Textsize")) "0" (rtos dt5 2 3))
       	(setq p (polar p (- (/ pi 2)) (* (getvar "Textsize") 2.0)))
     	)
     )
     (if (> dt6 0)
     	(progn
       	(command "text" "J" "R" p "0" (strcat "S " e6 " (m2) ="))
       	(command "text" (polar p 0.0 (getvar "Textsize")) "0" (rtos dt6 2 3))
       	(setq p (polar p (- (/ pi 2)) (* (getvar "Textsize") 2.0)))
     	)
     )
     (if (> dt7 0)
     	(progn
       	(command "text" "J" "R" p "0" (strcat "S " e7 " (m2) ="))
       	(command "text" (polar p 0.0 (getvar "Textsize")) "0" (rtos dt7 2 3))
       	(setq p (polar p (- (/ pi 2)) (* (getvar "Textsize") 2.0)))
     	)
     )
     (if (> dt8 0)
     	(progn
       	(command "text" "J" "R" p "0" (strcat "S " e8 " (m2) ="))
       	(command "text" (polar p 0.0 (getvar "Textsize")) "0" (rtos dt8 2 3))
       	(setq p (polar p (- (/ pi 2)) (* (getvar "Textsize") 2.0)))
     	)
     )
     (if (> dt9 0)
     	(progn
       	(command "text" "J" "R" p "0" (strcat "S " e9 " (m2) ="))
       	(command "text" (polar p 0.0 (getvar "Textsize")) "0" (rtos dt9 2 3))
       	(setq p (polar p (- (/ pi 2)) (* (getvar "Textsize") 2.0)))
     	)
     )
     (if (> dt10 0)
     	(progn
       	(command "text" "J" "R" p "0" (strcat "S " e10 " (m2) ="))
       	(command "text" (polar p 0.0 (getvar "Textsize")) "0" (rtos dt10 2 3))
       	(setq p (polar p (- (/ pi 2)) (* (getvar "Textsize") 2.0)))
     	)
     )
    ;  (command "Block" "Du" "Y" p oblist "")
     (setq Enam (ssget "X" '((0 . "LWPOLYLINE") (62 . 112) (6 . "HIDDEN"))))
     (setq m 0)
     (repeat (sslength Enam)
    (setq Ena (ssname Enam m))
    (command "_erase" Ena "")
    (setq m (+ m 1))
     )
     (COMMAND "LUPREC" 4 "osmode" 33 "linetype" "S" "Continuous" "" "OOPS")
    )
    ;;;-----------------------------------------------------------------------------
    (defun WriteToExcel (/ *ExcelApp% lst_data cviec Cell& i)
     (setq lst_data '() cviec '())
     (setq lst_data (cons ten lst_data) lst_data (cons (rtos cdon 2 2) lst_data))
     (if (> dt1 0) (setq lst_data (cons (rtos dt1 2 3) lst_data)))
     (if (> dt2 0) (setq lst_data (cons (rtos dt2 2 3) lst_data)))
     (if (> dt3 0) (setq lst_data (cons (rtos dt3 2 3) lst_data)))
     (if (> dt4 0) (setq lst_data (cons (rtos dt4 2 3) lst_data)))
     (if (> dt5 0) (setq lst_data (cons (rtos dt5 2 3) lst_data)))
     (if (> dt6 0) (setq lst_data (cons (rtos dt6 2 3) lst_data)))
     (if (> dt7 0) (setq lst_data (cons (rtos dt7 2 3) lst_data)))
     (if (> dt8 0) (setq lst_data (cons (rtos dt8 2 3) lst_data)))
     (if (> dt9 0) (setq lst_data (cons (rtos dt9 2 3) lst_data)))
     (if (> dt10 0) (setq lst_data (cons (rtos dt10 2 3) lst_data)))
     (setq lst_data (reverse lst_data))
    
     (setq cviec (cons "M.Cat" cviec) cviec (cons "C.Don" cviec))
     (if (> dt1 0) (setq cviec (cons e1 cviec)))
     (if (> dt2 0) (setq cviec (cons e2 cviec)))
     (if (> dt3 0) (setq cviec (cons e3 cviec)))
     (if (> dt4 0) (setq cviec (cons e4 cviec)))
     (if (> dt5 0) (setq cviec (cons e5 cviec)))
     (if (> dt6 0) (setq cviec (cons e6 cviec)))
     (if (> dt7 0) (setq cviec (cons e7 cviec)))
     (if (> dt8 0) (setq cviec (cons e8 cviec)))
     (if (> dt9 0) (setq cviec (cons e9 cviec)))
     (if (> dt10 0) (setq cviec (cons e10 cviec)))
     (setq cviec (reverse cviec))
     (vl-load-com)
     (if
    (or
     	(not (setq *ExcelApp% (vlax-get-object "Excel.Application")))
     	(= (vla-get-visible *ExcelApp%) :vlax-false)
    )
    (progn
     	(setq *ExcelApp% (vlax-get-or-create-object "Excel.Application"))
     	(vlax-invoke-method (vlax-get-property *ExcelApp% 'WorkBooks) 'Add)
     	(vla-put-visible *ExcelApp% :vlax-true)
    )
     )
     (setq i 1)
     (while (/= (getcell (strcat "A" (itoa i))) "")
    		(setq i (1+ i))
     )
    ;  (alert (strcat "So dong hien tai: " (rtos i 2 0)))
     (setq Cell& (strcat "A" (itoa i)))
     (putcell Cell& cviec)
     (setq Cell& (strcat "A" (itoa (+ i 1))))  
     (putcell Cell& lst_data)
    )
    ;-------------------------------------------------------------------------------
    ; GetCell - Returns the cell value from the *ExcelData@ list
    ; Arguments: 1
    ;   Cell$ = Cell ID
    ; Syntax example: (GetCell "E19") = value of cell E19
    ;-------------------------------------------------------------------------------
    (defun GetCell (Cell$ / ExcelRange^ ExcelVariant^ )
      (setq ExcelRange^ (vlax-get-property *ExcelApp% "Range" Cell$))
     	(setq ExcelVariant^ (vlax-get-property ExcelRange^ 'Value))
     	(setq ExcelValue (vlax-variant-value ExcelVariant^))
     	(setq ExcelValue
       	(cond
         	((= (type ExcelValue) 'INT) (itoa ExcelValue))
         	((= (type ExcelValue) 'REAL) (rtosr ExcelValue))
         	((= (type ExcelValue) 'STR) (vl-string-trim " " ExcelValue))
         	((/= (type ExcelValue) 'STR) "")
       	);cond
     	);setq
     ExcelValue
    );defun GetCell
    ;-------------------------------------------------------------------------------
    ; PutCell - Put values into Excel cells
    ; Arguments: 2
    ;   StartCell$ = Starting Cell ID
    ;   Data@ = Value or list of values
    ; Syntax examples:
    ; (PutCell "A1" "PART NUMBER") = Puts PART NUMBER in cell A1
    ; (PutCell "B3" '("Dim" 7.5 "9.75")) = Starting with cell B3 put Dim, 7.5, and 9.75 across
    ;-------------------------------------------------------------------------------
    (defun PutCell (StartCell$ Data@ / Cell$ Column# ExcelRange Row#)
     (if (= (type Data@) 'STR)
    (setq Data@ (list Data@))
     )
     (setq ExcelRange (vlax-get-property *ExcelApp% "Cells"))
     (if (Cell-p StartCell$)
    (setq Column# (car (ColumnRow StartCell$))
         	Row# (cadr (ColumnRow StartCell$))
    );setq
    (if (vl-catch-all-error-p
         	(setq Cell$ (vl-catch-all-apply 'vlax-get-property
           	(list (vlax-get-property *ExcelApp% "ActiveSheet") "Range" StartCell$))
         	);setq
       	);vl-catch-all-error-p
       	(alert (strcat "The cell ID \"" StartCell$ "\" is invalid."))
       	(setq Column# (vlax-get-property Cell$ "Column")
             	Row# (vlax-get-property Cell$ "Row")
       	);setq
    );if
     );if
     (if (and Column# Row#)
    (foreach Item Data@
     	(vlax-put-property ExcelRange "Item" Row# Column# (vl-princ-to-string Item))
     	(setq Column# (1+ Column#))
    );foreach
     );if
     (princ)
    );defun PutCell
    ;-------------------------------------------------------------------------------
    (defun ColumnRow (Cell$ / Column$ Char$ Row#)
     (setq Column$ "")
     (while (< 64 (ascii (setq Char$ (strcase (substr Cell$ 1 1)))) 91)
    (setq Column$ (strcat Column$ Char$)
         	Cell$ (substr Cell$ 2)
    );setq
     );while
     (if (and (/= Column$ "") (numberp (setq Row# (read Cell$))))
    (list (Alpha2Number Column$) Row#)
    '(1 1);default to "A1" if there's a problem
     );if
    );defun ColumnRow
    ;-------------------------------------------------------------------------------
    ; Cell-p - Evaluates if the argument Cell$ is a valid cell ID
    ; Function By: Gilles Chanteau from Marseille, France
    ; Arguments: 1
    ;   Cell$ = String of the cell ID to evaluate
    ; Syntax examples: (Cell-p "B12") = t, (Cell-p "BT") = nil
    ;-------------------------------------------------------------------------------
    (defun Cell-p (Cell$)
     (and (= (type Cell$) 'STR)
    (or (= (strcase Cell$) "A1")
     	(not (equal (ColumnRow Cell$) '(1 1)))
    );or
     );and
    );defun Cell-p
    ;-------------------------------------------------------------------------------
    (defun rtosr (RealNum~ / DimZin# ShortReal$)
     (setq DimZin# (getvar "DIMZIN"))
     (setvar "DIMZIN" 8)
     (setq ShortReal$ (rtos RealNum~ 2 8))
     (setvar "DIMZIN" DimZin#)
     ShortReal$
    );defun rtosr
    ;-------------------------------------------------------------------------------
    ; Alpha2Number - Converts Alpha string into Number
    ; Function By: Gilles Chanteau from Marseille, France
    ; Arguments: 1
    ;   Str$ = String to convert
    ; Syntax example: (Alpha2Number "ABC") = 731
    ;-------------------------------------------------------------------------------
    (defun Alpha2Number (Str$ / Num#)
     (if (= 0 (setq Num# (strlen Str$)))
    0
    (+ (* (- (ascii (strcase (substr Str$ 1 1))) 64) (expt 26 (1- Num#)))
      	(Alpha2Number (substr Str$ 2))
    );+
     );if
    );defun Alpha2Number
    ;-------------------------------------------------------------------------------
    ; Number2Alpha - Converts Number into Alpha string
    ; Function By: Gilles Chanteau from Marseille, France
    ; Arguments: 1
    ;   Num# = Number to convert
    ; Syntax example: (Number2Alpha 731) = "ABC"
    ;-------------------------------------------------------------------------------
    (defun Number2Alpha (Num# / Val#)
     (if (< Num# 27)
    (chr (+ 64 Num#))
    (if (= 0 (setq Val# (rem Num# 26)))
     	(strcat (Number2Alpha (1- (/ Num# 26))) "Z")
     	(strcat (Number2Alpha (/ Num# 26)) (chr (+ 64 Val#)))
    );if
     );if
    );defun Number2Alpha
    

    • Vote tăng 1

  11. Thêm trường hợp thứ 3 thì phải bỏ trường hợp thứ nhất chứ? Và trường hợp này chính là trường hợp thứ 2?

    Lisp trên của bạn Hà chạy lần 2, 3... đều đóng Book cũ và mở Book mới - OK,

    ý mình là: "Nếu chưa có Excel thì mở Boock mới, nếu có rồi thì thôi".

    Như trên mình đã dùng hàm (if... mà không được, nhờ Bạn xem giúp:

    (setq xlApp (vlax-get-or-create-object "Excel.Application"))
    (if xlApp
    (progn
    (alert "Excel spreadsheets opening")
    )
    (progn
    (setq xlApp (vlax-get-or-create-object "Excel.Application"))
    (setq xlCells (vlax-get-property (vlax-get-property (vlax-get-property (vlax-invoke-method (vlax-get-property xlApp "Workbooks") "Add") "Sheets") "Item" 1) "Cells"))
    )
    )
    

×