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

tien2005

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

    513
  • Đã tham gia

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

  • Ngày trúng

    59

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


  1. 1 giờ} trướ}c, Duong Nhat Duy đã nói:

    Cảm ơn bạn nhé, nhưng vẫn không phải ý mình :((

    Hàm addPageSetup là hàm thêm 1 pagesetup mới.

    Hàm sát với ý mình nhất là hàm SetCurrentPageSetup, ví dụ:

    • cadvietlisp.lsp
      lisp help
    •  
    
    (SetCurrentPageSetup (vla-get-activedocument (vlax-get-acad-object)) "Setup2"

    Hàm này chuyển Page setup về "Setup2", ý mình muốn chuyển về None, mình đã thử đổi số thành None, "", nil nhưng vẫn ko đc :((

     

    Bạn chỉ cần tạo pagesetup trên layout (cài đặt máy in, giấy, ....) sau đó coupyform cho các layout khác thì tất cả là None. Bạn tham khảo code sau

    ;;;https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/using-and-characters-in-vla-put-canonicalmedianame/td-p/4842089
    (defun c:pagesetups()
      (setq	doc	 (vla-get-ActiveDocument (vlax-get-acad-object)))
        (setq plotCfgs (vla-get-ActiveLayout doc))
        (vla-RefreshPlotDeviceInfo plotCfg)
     
        ;; Set the plot device
        (vla-put-ConfigName plotCfg "DWG To PDG.pc3")
        ;; Set the paper size
        (vla-put-CanonicalMediaName plotCfg "ANSI B \(11.00 x 17.00 Inches\)")
        
        (vla-put-PaperUnits plotCfg acMillimeters)
    
          (setq PLOT_BL (vlax-safearray-fill (vlax-make-safearray vlax-vbDouble '(0 . 1)) '(-53.540381 -6.990000))
            PLOT_TR (vlax-safearray-fill (vlax-make-safearray vlax-vbDouble '(0 . 1)) '(814.00000000 537.00000000))
        )
        (vla-SetWindowToPlot plotCfg PLOT_BL PLOT_TR)
        (vla-put-PlotType plotCfg acWindow)
    
        (vla-put-UseStandardScale plotCfg :vlax-true)
        (vla-put-StandardScale plotCfg ac1_2)
        (vla-put-CenterPlot plotCfg :vlax-false)
        ;; Hide paperspace objects
        (vla-put-PlotHidden plotCfg :vlax-false)
    
          ;; Set the plot offset
        (setq origin (vlax-make-safearray vlax-vbDouble '(0 . 1)))
        (vlax-safearray-fill origin (list 0.0 0.0))
        (vla-put-PlotOrigin plotCfg origin)
      
        (vla-put-PlotRotation plotCfg ac90degrees)
        (vla-put-PlotViewportBorders plotCfg :vlax-false)
        (vla-put-PlotViewportsFirst plotCfg :vlax-false)
        (vla-put-PlotWithLineweights plotCfg :vlax-true)
        (vla-put-ScaleLineweights plotCfg :vlax-false)
        (vla-put-PlotWithPlotStyles plotCfg :vlax-true)
        (vla-put-ShowPlotStyles plotCfg :vlax-true)
        (vla-put-StyleSheet plotCfg "MTO_monochrome_Half_Size.ctb")
        (vla-RefreshPlotDeviceInfo plotCfg)
    
      ;http://forums.augi.com/showthread.php?44555-Apply-page-setup-to-multiple-layouts
    (vlax-map-collection
    	(vla-get-layouts doc)
    	'(lambda (x)
    	   (if (eq (vla-get-modeltype x) :vlax-false)
    	     (vl-catch-all-error-p (vl-catch-all-apply 'vla-copyfrom (list x plotCfgs)))
    	   )
    	 )
          )
        (princ)
    )

     

    • Vote tăng 1

  2. @Duong Nhat DuyMình chưa rõ ý của Bạn. Bạn có thể kiểm tra tên pagesetup của layout

    ;http://theswamp.org/lilly_pond/cab/plotstuff.lsp?nossi=1
    ; Jason Piercey   Jun 12 2003, 1:39 pm  
    ; Get current page setup
    ; [layout] - string, layout name 
    ; returns current pagesetup of [layout] 
    (defun currentPagesetup (layout) 
     (cdr 
      (assoc 
       1 
       (dictsearch 
        (cdar 
         (dictsearch 
          (namedobjdict) 
          "acad_layout" 
          ) 
         ) 
        layout 
        ) 
       ) 
      ) 
     ) 

     


  3. @vanhuyou Bạn dùng thử

    (defun c:tcdt (/ att ent len ss)
      (setvar 'DIMZIN 0)
      (and (setq ss (ssget "_+.:S:E" '((0 . "*LINE"))))
           (setq ent (ssname ss 0))
           (not (redraw ent 3))
           (setq att (car (nentsel "\nPick Att: ")))
           (eq (cdr (assoc 0 (entget att))) "ATTRIB")
           (setq
    	 len (vlax-curve-getDistAtParam ent (vlax-curve-getEndParam ent))
           ) ;_ end of setq
           (not
    	 (vla-put-textstring
    	   (vlax-ename->vla-object att)
    	   (strcat (vla-get-textstring (vlax-ename->vla-object att))
    		   " - "
    		   (rtos len 2 0)
    	   ) ;_ end of strcat
    	 ) ;_ end of vla-put-textstring
           ) ;_ end of not
           (redraw ent 4)
      ) ;_ end of and
      (princ)
    ) ;_ end of defun

     


  4. 10 giờ trước, thanhduan2407 đã nói:

    Các bác cho em hỏi chút ạ!

    Em rất muốn tạo bảng Table như trong hình nhưng đang vướng 1 số chỗ. Rất mong các bác cho em lời tư vấn hoặc giới thiệu cho em một vài hàm hoặc 1 số trang web có tài liệu em nghiên cứu. Việc tạo table với cấu trúc file đơn giản như STT X Y Z CODE thì em nghiên cứu hàm Addtable của Lee-Mac em làm được rồi. Nhưng cấu trúc file phức tạp như trong hình thì hơi khó. Rất mong các bác tương trợ. Cảm ơn các bác nhiều.

    https://i844.photobucket.com/albums/ab7/thanhduan2407/Screenshot_1_zpsj03s9mz8.jpg

     

    @thanhduan2407Để mergecell bạn dùng hàm này xử lý cho từng thằng

    (vl-catch-all-apply
    		   (function (lambda () (vla-MergeCells VlaObj minRow maxRow minCol maxCol )))
    		 )

    minRow maxRow minCol maxCol là số hàng, cột để xác định phạm vi các ô cần merge


  5. Bạn down lisp từ link trên về rồi dùng notepad (hoặc tại dòng cửa sổ acad đánh lệnh "vlide" để mở chương trình visual lisp) để mở lên rồi thêm lệnh của Bạn vào

    ;;-----------------------------------------------------------------------------------------------------------------------------------------------------;;
    ;;  Command Pattern  |  Layer Name    |       Description       |    Colour    |   Linetype   |    Lineweight    |       Plot       |    Plot Style    ;;
    ;;-----------------------------------------------------------------------------------------------------------------------------------------------------;;
    ;;     [string]      |   [string]     |         [string]        | 0 < int <256 |   [string]   | -3 = Default     |  1 = Will Plot   |     [string]     ;;
    ;;                   |                |     Use "" for none     |              |              |  0 <= int <= 211 |  0 = Won't Plot  |  Use nil for CTB ;;
    ;;-----------------------------------------------------------------------------------------------------------------------------------------------------;;
     
    ("[DM]TEXT,TEXT"       "TEXT"           "Text Layer"                   2        "Continuous"           -3                 1                 nil         )
    ("DIM*,*LEADER"        "DIMENSIONS"     "Dimension Layer"              3        "Continuous"           -3                 1                 nil         )
    ("*VPORT*"             "DEFPOINTS"      ""                             7        "Continuous"           -3                 0                 nil         )
    ("XLINE"               "XLINE"          "Construction Lines"          12        "HIDDEN"                0                 0                 nil         )
     
    ;;-----------------------------------------------------------------------------------------------------------------------------------------------------;;

    ("[DM]TEXT,TEXT"       "TEXT"           "Text Layer"                   2        "Continuous"           -3                 1                 nil         )

    ("DIM*,*LEADER,DDD"        "DIMENSIONS"     "Dimension Layer"              3        "Continuous"           -3                 1                 nil         )

    ("*VPORT*"             "DEFPOINTS"      ""                             7        "Continuous"           -3                 0                 nil         )

    ("XLINE"               "XLINE"          "Construction Lines"          12        "HIDDEN"                0                 0                 nil         )

     

    Khi Bạn dùng lệnh DDD thì dim mới được tạo sẽ ở layer DIMENSIONS

    Các thông số trên Bạn có thể thêm tên lệnh, thay đổi tên layer, màu sắc, Linetype , Lineweight, .... theo ý của BẠn

    • Like 1
×