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

newghost0000

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

    7
  • Đã tham gia

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

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


  1. 2 giờ trước, Doan Nguyen Van đã nói:

    Bạn phải hiểu rằng cách sắp xếp trên Cad không giống như Excel là hàng và cột, mà nó có rất nhiều thứ tự khác nhau, cụ thể do người dùng.

    Text của bạn lệch 1mm thôi thì thứ tự đã khác đi rồi, nên mình mới bảo bạn đưa bản vẽ cụ thể lên để còn nắm được

    vậy chắc mình phải bỏ ý định này thôi. copy paste từng text cho chắc.tks bạn đã quan tâm


  2. 2 giờ trước, Doan Nguyen Van đã nói:

    Bạn không post File mẫu lên thì còn mơ hồ lắm 

    THANK BÁC

    có thể hiểu đơn giản lisp sẽ copy trên cad giống như copy paste trên excel. 

    VD : A1 B1 C1 D1 .....CHỌN 4 Ô VÀ COPY

    PASTE VÀO Ô A3 B3 C3 D3. MẶC KỆ CÁC Ô A3 B3 C3 D3 CÓ DỮ LIỆU TEXT GÌ.KẾT QUẢ CẦN LÀ CÁC Ô A3 B3 C3 D3 VẪN GIỮ NGUYÊN VỊ TRÍ TRÊN CAD VÀ CÁC THUỘC TÍNH. CHỈ CÓ NỘI DUNG LÀ GIỐNG A1 B1 C1 D1

    • Vote giảm 1

  3. 1 giờ} trướ}c, huunhantvxdts đã nói:

    Cái này còn phụ thuộc vào cách săp xếp của text không thì sẽ lấy râu ông này chắp cằm và kia

    có thể mặc định theo cách mình chọn đối tượng copy, qui ước từ trái qua phải, từ trên xuống dưới, qui định số đối tượng copy phải bằng số đối tượng paste. như kiểu paste 1 hàng 1 cột trong excel


  4. Vào lúc 12/9/2016 tại 10:11, hainguyen2014 đã nói:

    Code cho bạn. Hy vong là đúng yêu cầu. he he

     

     

    
    (defun c:dcc (/ sl s1 s2)
    (setvar "cmdecho" 0)
    (setq s1 (entget (car (entsel "\nChon text goc:"))))
    (princ "\nChon cac Text can thay doi.")
    (setq s2 (ssget '((0 . "TEXT,MTEXT"))))
    (setq sl (sslength s2))
    (setq dem 0)
    (while (< dem sl)
    (setq nds2 (entget (ssname s2 dem)))
    (setq text (cdr (assoc 1 s1)))
    (setq thaythe (subst (cons 1 text) (assoc 1 nds2) nds2))
    (entmod thaythe)
    (setq dem (1+ dem))
    )
    )
    

    bạn có thể làm lại lisp này không

    1. Tên lệnh.

    2. Chọn đối tượng text cần copy.(có thể 1 hoặc nhiều đối tượng)

    3. Chọn đối tượng text cần paste (có thể 1 hoặc nhiều đối tượng). số đối tượng copy bằng số đối tượng paste

    4. Kết thúc lệnh.

    Chỉ cần lấy text bên copy, bên paste hoàn toàn giữ lại mọi thuộc tính ban đầu

    Cảm ơn bạn!


  5. ;**************************************************
    ;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
×