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

Nhờ các bác pro sửa lại lisp dùm em với ạ. em cần thêm 1 hàng khoảng cách cộng dồn

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

;**************************************************
;CHUONG TRINH AUTOLISP NHAP SO LIEU - VE MCN KENH *
;**************************************************
(defun dxf (code elist)
    (cdr (assoc code elist))
)

(defun c:NHAP () TL TL1 TLD fin fin1 fout read_formatline0 read_formatline1 dong_nhap
              dong_nhap1 so_mc solieu_mc solieu_mc1 tenmc ten_mc MSS 
        sodiem_hc sodiem_mdtn vitritencoc vitri_coc X1 Y1 Y2
        STT del_ta xx1 xx2 yy1 yy2 yy10 yy20 H H1 Pdau Pcuoi
        p1 p2 p4 p41 p5 p6 p7 p8 p9 )    ;1

    (setq TL1 0.0)
    (setq TL1 (getreal "Input m <scale :1/m> : "))
    (setq TL (/ TL1 200.0))
    ;(setq TLD (* TL 50.0))

    (command "layer" "make" "mdtn" "C" "7" "mdtn" )
    (command)
    (command "layer" "make" "hoan-cong" "C" "6" "hoan-cong")
    (command)
    (command "linetype" "l" "dot2" "" "")
    (command "linetype" "l" "dashed2" "" "")
    (command "ltscale" 50)
    (command "layer" "make" "giong" "C" "8" "giong")
    (command)
    (command "layer" "make" "giong" "L" "dot2" "giong")
    (command)
    (command "layer" "make" "de" "C" "1" "de")
    (command)
    (command "layer" "make" "kenh" "C" "1" "kenh")
    (command)
    (command "layer" "make" "textvn" "C" "6" "textvn")
    (command)
    (command "layer" "make" "text" "C" "7" "text")
    (command)
    (command "style" "vnam" "vhelvcn.ttf" "0.0" "1" "0" "n" "n")
    (command)
    
    

  (if (setq fin1 (open (getfiled "IMPORT TEXT FILE" "" "txt" 8) "r"))     ;2'
     (progn                                ;2
         (setq read_formatline0 (read-line fin1))
    (setq read_formatline0 (substr read_formatline0 1 25))
    (setq read_formatline1 (substr "CanalDesign-Topo-TextFile" 1 25) )
    
    (if (= read_formatline0 read_formatline1)            ;3
        (progn                            ;4
        (setq fout (open "filedem" "w"))
        
         (while (setq dong_nhap (read-line fin1))
        (progn
        (setq dong_nhap1 (strcat "(" dong_nhap ")"))
        (write-line dong_nhap1 fout)
        )
        );while
        (close fin1)
        (close fout)
        
        (setq fin (open "filedem" "r"))
          (setq so_mc 0.0)
        
        (while     (setq solieu_mc (read-line fin))        ;5
            (progn                         ;6
            (setq so_mc (+ so_mc 1) )
            (setq solieu_mc1 (read solieu_mc))
            (setq vitritencoc 2 ten_mc "")
        (while (/= (setq tenmc (substr solieu_mc vitritencoc 1)) "\t")
            (progn
            (setq ten_mc (strcat ten_mc tenmc))
            (setq vitritencoc (+ vitritencoc 1))
            )
        );while
            (setq sodiem_mdtn (nth 1 solieu_mc1))
            (setq sodiem_hc (nth 2 solieu_mc1))
            (setq MSS 0.00)
            (setq MSS (nth 3 solieu_mc1))
            (setq vitri_coc (nth 4 solieu_mc1))
            (setq X1 0.00 Y1 0.00 Y2 0.00)
            (setq X1 (read-line fin)
                  X1 (read X1))
             ; Khoang cach coc        
            (setq Y1 (read-line fin)
                  Y1 (read Y1))
            ; Cao do MDTN        
            (setq Y2 (read-line fin)
                  Y2 (read Y2))
            ; Cao do hoan cong
            
        
            
; **************************************
; Ve mat dat tu nhien
; **************************************
                  (setq STT 0   del_ta 0.00)
                (setq xx1 0.00 xx2 0.00 yy1 0.00 yy2 0.00 yy10 0.00 yy20 0.00)
                (setq yy10 (nth STT Y1))
                (setq yy1 (+ (* (- yy10 MSS) 1000.00) (* so_mc -20000.00)))

                (setq xx1 del_ta)
                   (setq STT (+ STT 1))
                (setq yy20 (nth STT Y1))
                (setq yy2 (+ (* (- yy20 MSS) 1000.0) (* so_mc -20000.0)))

                (setq xx2 (nth STT X1))
                (setq del_ta (+ del_ta (* xx2 1000.00)))

                (setq P1 (list xx1 yy1))
                (setq Pdau (list (- xx1 1) (- yy1 1)))
                (setq P2 (list del_ta yy2))
                (setq Pcuoi (list (+ del_ta 1) (+ yy2 1)))
                
                (setq P4 (list del_ta (* so_mc -20000.0)))
                (setq P41 (list xx1 (* so_mc -20000.0)))
                (setq P5 (list (+ xx1 (/ (* xx2 1000.0)  2.0)) (- (* so_mc -20000.0) (* TL 2500.0))))
                (setq P6 (list xx1  (- (* so_mc -20000.0) (* TL 2000.0))))
                (setq P7 (list xx1 (- (* so_mc -20000.0) (* TL 3000.0))))
                (setq P8 (list del_ta  (- (* so_mc -20000.0) (* TL 2000.0))))
                (setq P9 (list del_ta (- (* so_mc -20000.0) (* TL 3000.0))))

                (command "layer" "set" "giong")
                (command)
                (command "line" P1 P41 )
                (command)
                (command "line" P2 P4 )
                (command)

                (command "layer" "set" "mdtn")
                (command)
                (command "pline" P1 P2 "")
                (command)

                (command "line" P6 P7 )
                (command)
                (command "line" P8 P9 )
                (command)
                (command "style" "vnam")
                (command)
                (command "layer" "set" "text")
                (command)
                (setq H 0.00 H1 0.00)
                (setq H (* TL 500.0))
                
                (command "text" "MC" P5 H 0 (rtos (* xx2 1.0) 2 1)) ; ghi khoang cach
                (command)
                (command "text" "BR" P41 H 0 (strcat "MSS :" (rtos (* MSS 1.0) 2 2) "  ")) ; ghi muc so sanh
                (command)
                (command "text" "MR" P41 H 90 (strcat (rtos (* yy10 1.0) 2 2 ) " ")) ; ghi cao do
                (command)
                (command "text" "MR" P4 H 90 (strcat (rtos (* yy20 1.0) 2 2 ) " ")) ; ghi cao do
                (command)
                    (if (= (+ vitri_coc 1) STT ) ; 9
                        (progn    ;10
                        (command "insert" "coc" P1 TL TL 0)
                        (command)
                        ) ; 10
                    ) ; 9

                        (command "layer" "set" "textvn")
                        (command)
                        (setq P41 (list (- xx1 (* TL 7500.0)) (+ (* so_mc -20000.0) 8000.0)))
                        (setq H1 (* TL 1000.0))
                        (command "text" P41 H1 0 ten_mc)
                        (command)
    
            (repeat (- sodiem_mdtn 1)            ;7
                (progn                     ;8
                (setq yy1 (nth STT Y1))
                (setq yy1 (+ (* (- yy1 MSS) 1000.0) (* so_mc -20000.0)))

                (setq xx1 del_ta)
                   (setq STT (+ STT 1))
                (setq yy20 (nth STT Y1))
                (setq yy2 (+ (* (- yy20 MSS) 1000.0) (* so_mc -20000.0)))

                (setq xx2 (nth STT X1))
                (setq del_ta (+ del_ta (* xx2 1000.0)))

                (setq P1 (list xx1 yy1))
                (setq P2 (list del_ta yy2))
        
                (setq P4 (list del_ta (* so_mc -20000.0)))
                (setq P5 (list (+ xx1 (/ (* xx2 1000.0)  2.0)) (- (* so_mc -20000.0) (* TL 2500.0))))
                (setq P6 (list del_ta  (- (* so_mc -20000.0) (* TL 2000.0))))
                (setq P7 (list del_ta (- (* so_mc -20000.0) (* TL 3000.0))))

                (command "layer" "set" "giong")
                (command)                
                (command "line" P2 P4 )
                (command)
                
                (command "layer" "set" "mdtn")
                (command)
                (command "pline" P1 P2 "")
                (command)

                (command "line" P6 P7 )
                (command)

                (command "style" "standard")
                (command)
                (command "layer" "set" "text")
                (command)

                (command "text" "MC" P5 H 0 (rtos (* xx2 1.0) 2 1)) ; ghi khoang cach
                (command)

                (command "text" "MR" P4 H 90 (strcat (rtos (* yy20 1.0) 2 2) " ")) ; ghi cao do
                (command)
                    (if (= (+ vitri_coc 1) STT ) ; 9
                        (progn    ;10
                        (command "insert" "coc" P1 TL TL 0)
                        (command)
                        ) ; 10
                    ) ; 9
                ) ; 8
                
                ); 7
                (setq P1 (list (* (- 0 8000) TL) (* so_mc -20000.0)))
                (setq P2 (list (* (- 0 8000) TL)  (- (* so_mc -20000.0) (* TL 2000.0))))
                (setq P5 (list (* (- 0 8000) TL) (- (* so_mc -20000.0) (* TL 3000.0))))
                (command "layer" "set" "mdtn")
                (command)
                (command "line" P1 P4 )
                (command)
                (command "line" P2 P6 )
                (command)
                (command "line" P5 P7 )
                (command)
                (command "line" P1 P5 )
                (command)
                (setq P1 (list (* (- 0 8000) TL) (- (* so_mc -20000.0) (* TL 1000.0))))
                (setq P2 (list (* (- 0 8000) TL)  (- (* so_mc -20000.0) (* TL 2500.0))))

                (command "layer" "set" "text")
                (command)

                (command "text" "ML" P1 H 0 " Cao ñoä maët ñaát töï nhieân") ; ghi khoang cach
                (command)

                (command "text" "ML" P2 H 0 " Khoaûng caùch ñieåm ño") ; ghi cao do
                (command)
            
                    
; **************************************
; Ve mat hoan cong
; **************************************
        (if (/= sodiem_hc 0)
        (progn
                  (setq STT 0   del_ta 0.00)
                (setq xx1 0.00 xx2 0.00 yy1 0.00 yy2 0.00 yy20 0.00)
                (setq yy10 (nth STT Y2))
                (setq yy1 (+ (* (- yy10 MSS) 1000.0) (* so_mc -20000.0)))

                (setq xx1 del_ta)
                   (setq STT (+ STT 1))
                (setq yy20 (nth STT Y2))
                (setq yy2 (+ (* (- yy20 MSS) 1000.0) (* so_mc -20000.0)))

                (setq xx2 (nth STT X1))
                (setq del_ta (+ del_ta (* xx2 1000.0)))

                (setq P1 (list xx1 yy1))
                (setq Pdau2 (list (- xx1 1) (- yy1 1)))
                (setq P2 (list del_ta yy2))
                (setq Pcuoi2 (list (+ del_ta 1) (+ yy2 1)))
                (setq P4 (list del_ta (* so_mc -20000.0)))
                (setq P41 (list xx1 (* so_mc -20000.0)))

                (setq P42 (list del_ta (- (* so_mc -20000.0) (* TL 3000.0))))
                (setq P412 (list xx1 (- (* so_mc -20000.0) (* TL 3000.0))))
                (setq P5 (list (+ xx1 (/ (* xx2 1000.0)  2.0)) (- (* so_mc -20000.0) (* TL 5500.0))))
                (setq P6 (list xx1  (- (* so_mc -20000.0) (* TL 5000.0))))
                (setq P7 (list xx1 (- (* so_mc -20000.0) (* TL 6000.0))))
                (setq P8 (list del_ta  (- (* so_mc -20000.0) (* TL 5000.0))))
                (setq P9 (list del_ta (- (* so_mc -20000.0) (* TL 6000.0))))

                (command "layer" "set" "giong")
                (command)
                (command "line" P1 P41 )
                (command)
                (command "line" P2 P4 )
                (command)

                (command "layer" "set" "hoan-cong")
                (command)
                (command "pline" P1 P2 "")
                (command)

                (command "line" P6 P7 )
                (command)
                (command "line" P8 P9 )
                (command)
                (command "style" "vnam")
                (command)
                (command "layer" "set" "text")
                (command)
                (command "text" "MC" P5 H 0 (rtos (* xx2 1.0) 21)) ; ghi khoang cach
                (command)
                
                (command "text" "MR" P412 H 90 (strcat (rtos (* yy10 1.0) 2 2 ) " ")) ; ghi cao do
                (command)
                (command "text" "MR" P42 H 90 (strcat (rtos (* yy20 1.0) 2 2 ) " ")) ; ghi cao do
                (command)
                        
    
            (repeat (- sodiem_hc 1)            ;7
                (progn                     ;8
                (setq yy1 (nth STT Y2))
                (setq yy1 (+ (* (- yy1 MSS) 1000.0) (* so_mc -20000.0)))

                (setq xx1 del_ta)
                   (setq STT (+ STT 1))
                (setq yy20 (nth STT Y2))
                (setq yy2 (+ (* (- yy20 MSS) 1000.0) (* so_mc -20000.0)))

                (setq xx2 (nth STT X1))
                (setq del_ta (+ del_ta (* xx2 1000.0)))

                (setq P1 (list xx1 yy1))
                (setq P2 (list del_ta yy2))
                (setq P4 (list del_ta (* so_mc -20000.0)))
                (setq P42 (list del_ta (- (* so_mc -20000.0) (* TL 3000.0))))
                (setq P5 (list (+ xx1 (/ (* xx2 1000.0)  2.0)) (- (* so_mc -20000.0) (* TL 5500.0))))
                (setq P6 (list del_ta  (- (* so_mc -20000.0) (* TL 5000.0))))
                (setq P7 (list del_ta (- (* so_mc -20000.0) (* TL 6000.0))))

                (command "layer" "set" "giong")
                (command)                
                (command "line" P2 P4 )
                (command)
                
                (command "layer" "set" "hoan-cong")
                (command)
                (command "pline" P1 P2 "")
                (command)

                (command "line" P6 P7 )
                (command)

                (command "style" "standard")
                (command)
                (command "layer" "set" "text")
                (command)

                (command "text" "MC" P5 H 0 (rtos (* xx2 1.0) 21)) ; ghi khoang cach
                (command)

                (command "text" "MR" P42 H 90 (strcat (rtos (* yy20 1.0) 2 2) " ")) ; ghi cao do
                (command)
                
                ) ; 8
                ); 7
                (setq P1 (list (* (- 0 8000) TL)  (- (* so_mc -20000.0) (* TL 3000.0))))
                (setq P2 (list (* (- 0 8000) TL)  (- (* so_mc -20000.0) (* TL 5000.0))))
                (setq P5 (list (* (- 0 8000) TL) (- (* so_mc -20000.0) (* TL 6000.0))))
                (command "layer" "set" "mdtn")
                (command)
                (command "line" P2 P6 )
                (command)
                (command "line" P5 P7 )
                (command)
                (command "line" P1 P5 )
                (command)
                (setq P1 (list (* (- 0 8000) TL) (- (* so_mc -20000.0) (* TL 4000.0))))
                (setq P2 (list (* (- 0 8000) TL)  (- (* so_mc -20000.0) (* TL 5500.0))))

                (command "layer" "set" "text")
                (command)

                (command "text" "ML" P1 H 0 " Cao ñoä ñieåm hoaøn coâng") ; ghi khoang cach
                (command)

                (command "text" "ML" P2 H 0 " Khoaûng caùch ñieåm hoaøn coâng") ; ghi cao do
                (command)
    );if
       );progn

    ;Noi duong mdtn
                (command "layer" "set" "mdtn")
                (command)
                (command "layer" "off" "hoan-cong")
                (command)
                (command "layer" "off" "giong")
                (command)
                (command "layer" "off" "text")
                (command)

                (setq P1 (list (* TL (- 0 12000.0)) (- (* so_mc -20000.0) (* TL 12000.0))))
                (setq P2 (list 300000 (+ (* so_mc -20000.0)  30000)))
                
                (command "zoom" "W" P1 P2)
                (command)
                ;(setq ssent1 (ssget "W" Pdau Pcuoi))
                ;(setq ent1 (ssname ssent1 0))
                (command "pedit" "W" Pdau Pcuoi "j" "W" P1 P2  "")
                (command)
                (command "layer" "on" "hoan-cong")
                (command)
                (command "layer" "on" "giong")
                (command)
                (command "layer" "on" "text")
                (command)
    ;Noi duong hoan cong
                (if (/= sodiem_hc 0)
                (progn
                (command "layer" "set" "hoan-cong")
                (command)
                (command "layer" "off" "mdtn")
                (command)
                (command "layer" "off" "giong")
                (command)
                (command "layer" "off" "text")
                (command)
                (command "zoom" "W" P1 P2)
                (command)
                ;(setq ssent1 (ssget "W" Pdau Pcuoi))
                ;(setq ent1 (ssname ssent1 0))
                (command "pedit" "W" Pdau2 Pcuoi2 "j" "W" P1 P2  "")
                (command)
                (command "layer" "on" "mdtn")
                (command)
                (command "layer" "on" "giong")
                (command)
                (command "layer" "on" "text")
                (command)

                )
                )
            ) ;6
            );5
            (close fin)
            
        );4
        (progn
        (princ "Sai tap tin : Error fileformat")
        (alert "Sai tap tin : Error fileformat")
        (exit)
        )
        );3
        ) ;2
        (progn
        (princ "error filename")
        (alert "error filename")
        (exit)
        )
        ) ;2'
        (setq p1 (list -12000 -9900) p2 (list 62000 -10200))
        (command "zoom" "W" p1 p2)
        (command)
        )            

hinh mat cat.png

mai text.png

  • Vote giảm 3

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

Bó tay chủ thớt. quăng cái lisp lên với vài cái hình, rồi nhờ vả thì chờ tới mùa quýt thôi.

 

  • Like 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
1 giờ trước, CadExTools đã nói:

Bó tay chủ thớt. quăng cái lisp lên với vài cái hình, rồi nhờ vả thì chờ tới mùa quýt thôi.

 

THÊM THÔNG TIN GÌ NỮA ĐỂ EM ÚP BÙ Ạ

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

×