Jump to content

Lisp điều khiển Plot Transpareny trong hộp thoại Plot

Quick Google và 1cent code để bạn dùng ^^
 

(defun LayoutTransparency (layout ON / xType xData )
  (setq xData (vlax-make-safearray vlax-vbVariant '(0 . 1)))
  (setq xType (vlax-make-safearray vlax-vbInteger '(0 . 1)))
  (vlax-safearray-fill xData (list(vlax-make-variant "PLOTTRANSPARENCY")(vlax-make-variant ON)))
  (vlax-safearray-fill xType (list 1001 1071))
  (vla-setXdata layout  xType xData)
  (entmod(entget (vlax-vla-object->ename layout) '("*")))
  (princ (strcat "Plot Transparency now is " (if (zerop ON) "OFF" "ON") "!"))
  (princ)
)
(defun c:ON() 
    (LayoutTransparency (vla-get-activelayout (vla-get-activedocument(vlax-get-acad-object))) 1) ;       1=ON 0=off
)
(defun c:OFF() 
    (LayoutTransparency (vla-get-activelayout (vla-get-activedocument(vlax-get-acad-object))) 0) ;       1=ON 0=off
)

 

Cách dùng

  1. Tải tệp 456773_on_off.lsp về máy.
  2. Trong AutoCAD gõ lệnh APPLOAD, chọn tệp vừa tải rồi bấm Load. Cũng có thể kéo thả tệp .lsp vào cửa sổ bản vẽ.
  3. Gõ lệnh ON OFF để chạy lisp.

Mã nguồn 456773_on_off.lsp

;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/187140-h%E1%BB%8Fi-lisp-%C4%91i%E1%BB%81u-khi%E1%BB%83n-plot-transpareny-trong-h%E1%BB%99p-tho%E1%BA%A1i-plot/
(defun LayoutTransparency (layout ON / xType xData )
  (setq xData (vlax-make-safearray vlax-vbVariant '(0 . 1)))
  (setq xType (vlax-make-safearray vlax-vbInteger '(0 . 1)))
  (vlax-safearray-fill xData (list(vlax-make-variant "PLOTTRANSPARENCY")(vlax-make-variant ON)))
  (vlax-safearray-fill xType (list 1001 1071))
  (vla-setXdata layout  xType xData)
  (entmod(entget (vlax-vla-object->ename layout) '("*")))
  (princ (strcat "Plot Transparency now is " (if (zerop ON) "OFF" "ON") "!"))
  (princ)
)
(defun c:ON() 
    (LayoutTransparency (vla-get-activelayout (vla-get-activedocument(vlax-get-acad-object))) 1) ;       1=ON 0=off
)
(defun c:OFF() 
    (LayoutTransparency (vla-get-activelayout (vla-get-activedocument(vlax-get-acad-object))) 0) ;       1=ON 0=off
)

Thảo luận gốc

Lisp được chia sẻ trong chủ đề [Hỏi] Lisp điều khiển Plot Transpareny trong hộp thoại Plot. Xem đúng bài viết #456773 để đọc hướng dẫn và trao đổi thêm.

Về Thư viện AutoLisp (trang 320)