Jump to content

Lisp lệnh BYLAYER trong chủ đề “Làm sao để chuyển line weight trong block thành bylayer?”

Lisp chuyển màu, linetype, lineweight tất cả các đối tượng trong bản vẽ về ByLayer.

(defun C:ByLayer()
  (vl-load-com)
  (vla-startundomark (vla-get-activedocument(vlax-get-acad-object)))
  (vlax-for for-item (vla-get-blocks(vla-get-activedocument(vlax-get-acad-object)))
    (vlax-for item for-item
      (vla-put-Lineweight item -1)
      (vla-put-color item 256)
      (vla-put-linetype item "ByLayer")
      )
    )
  (vla-endundomark (vla-get-activedocument(vlax-get-acad-object)))
  (princ)
  )

Cách dùng

  1. Tải tệp 258357_bylayer.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 BYLAYER để chạy lisp.

Mã nguồn 258357_bylayer.lsp

;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/72965-l%C3%A0m-sao-%C4%91%E1%BB%83-chuy%E1%BB%83n-line-weight-trong-block-th%C3%A0nh-bylayer/
(defun C:ByLayer()
  (vl-load-com)
  (vla-startundomark (vla-get-activedocument(vlax-get-acad-object)))
  (vlax-for for-item (vla-get-blocks(vla-get-activedocument(vlax-get-acad-object)))
    (vlax-for item for-item
      (vla-put-Lineweight item -1)
      (vla-put-color item 256)
      (vla-put-linetype item "ByLayer")
      )
    )
  (vla-endundomark (vla-get-activedocument(vlax-get-acad-object)))
  (princ)
  )

Thảo luận gốc

Lisp được chia sẻ trong chủ đề Làm sao để chuyển line weight trong block thành bylayer?. Xem đúng bài viết #258357 để đọc hướng dẫn và trao đổi thêm.

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