Jump to content

Lisp lệnh XML trong chủ đề “Cần giúp lisp hiện mã màu plot style”

Mình đang dùng cad 2013 nhưng nó cũng k hiện rõ màu số bao nhiêu mà chỉ hiện là bylayer thôi. mún biết màu số bao nhiêu phải bật LA lên mới thấy dc.

(Defun c:XML ( )

                   
(princ "\nChon doi tuong muon xem thuoc tinh")
(setq doituong1 (entsel))
(while
(null doituong1)
(princ "\nChon doi tuong muon xem thuoc tinh")
(setq doituong1 (entsel))
)

(setq doituong (car doituong1))
(setq doituong (entget doituong))


 (setq LAYERDOITUONG (cdr (assoc 8 doituong)))
 (setq COLORDOITUONG (cdr (assoc 62 doituong)))

  (setq TENLOP (TBLOBJNAME "LAYER" LAYERDOITUONG))
  (setq DOCLOP (entget TENLOP))
  (setq MAULOP (cdr (assoc 62 DOCLOP)))

 (Cond
  ((= COLORDOITUONG nill) 
  (setq COLORDOITUONG (strcat "BYLAYER <" (itoa MAULOP) ">"))
  )
  ((/= COLORDOITUONG nill) 
  (setq COLORDOITUONG (itoa COLORDOITUONG))
  )
  )

(alert (strcat 
    "\n -LAYER               : " LAYERDOITUONG
   "\n -COLOR              : " COLORDOITUONG))

(PRINC))

Cách dùng

  1. Tải tệp 228801_xml.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 XML để chạy lisp.

Mã nguồn 228801_xml.lsp

;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/69407-c%E1%BA%A7n-gi%C3%BAp-lisp-hi%E1%BB%87n-m%C3%A3-m%C3%A0u-plot-style/
(Defun c:XML ( )

                   
(princ "\nChon doi tuong muon xem thuoc tinh")
(setq doituong1 (entsel))
(while
(null doituong1)
(princ "\nChon doi tuong muon xem thuoc tinh")
(setq doituong1 (entsel))
)

(setq doituong (car doituong1))
(setq doituong (entget doituong))


 (setq LAYERDOITUONG (cdr (assoc 8 doituong)))
 (setq COLORDOITUONG (cdr (assoc 62 doituong)))

  (setq TENLOP (TBLOBJNAME "LAYER" LAYERDOITUONG))
  (setq DOCLOP (entget TENLOP))
  (setq MAULOP (cdr (assoc 62 DOCLOP)))

 (Cond
  ((= COLORDOITUONG nill) 
  (setq COLORDOITUONG (strcat "BYLAYER <" (itoa MAULOP) ">"))
  )
  ((/= COLORDOITUONG nill) 
  (setq COLORDOITUONG (itoa COLORDOITUONG))
  )
  )

(alert (strcat 
    "\n -LAYER               : " LAYERDOITUONG
   "\n -COLOR              : " COLORDOITUONG))

(PRINC))

Thảo luận gốc

Lisp được chia sẻ trong chủ đề Cần giúp lisp hiện mã màu plot style. Xem đúng bài viết #228801 để đọc hướng dẫn và trao đổi thêm.

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