Jump to content

Lisp lệnh SHOW trong chủ đề “Giao diện hộp thoại trong AutoLisp”

Kiểu này chuối lắm dùng file *.chm hoặc *.hlp hay hơn nhiều

code đây không biết có đúng ý bạn không?

Thuty.dcl:

(defun read-txt (filename / open_f line_r list-out file_read)
(setq list-out nil)
(if (/= (findfile filename) nil)
 (progn  
 (setq file_read (open filename "r"))
 (while
 (/= nil
 (setq line_r (read-line file_read))
  )
 (setq list-out (append list-out (list line_r)))
  )
 (close file_read)
)
(princ)  
)
list-out
)
;;;;;;;;;;;;;;;
;==== Load and check dialog ===========
; dia_name : string
(defun loadcl ( dia_name)
 (if (= -1 (setq dcl_id (load_dialog (strcat dia_name ".dcl"))))
(progn
  (alert (strcat dia_name ".dcl" "not found")
  (setq dialogloaded nil)
)		 
);p
(setq dialogloaded 1)
);f
);defun
;;;;;;;;;;;=========================
(defun c:show (/ fname  l1  dcl_id dialogloaded)
 (setq fname (getfiled "chon file"  "c:\\"  "*" 16)); lựa chọn file
;(setq fname "c:\\abc\\abc.txt"); hoặc chỉ định file
 (if (and
(/= fname nil)
(> (loadcl "thuty") 0); load and check dialog 
  ) 
  (if (not (new_dialog "thuty" dcl_id))
 (exit); Error
 (progn;else
		(start_list "doctxt")	 
		(mapcar' add_list (read-txt fname))  
		(end_list)
		(start_dialog)						 
		(done_dialog)
	(unload_dialog dcl_id)
);p

  );if1 
  );if
 (princ)
);defun

Have fun

Anh có thể tạo giúp e trong list đó có các cột được không ! Ví dụ như là trong bảng layer thì có các cột là linetype, lineweight...e muốn trong bảng list box đó của e có các cột ma nội dung các cột chỉ là các text thôi!

Tệp .lsp gốc không còn trên máy chủ. Hãy chép mã nguồn bên dưới (lấy từ bài viết gốc) vào một tệp văn bản, lưu với đuôi .lsp.

Cách dùng

  1. Chép mã nguồn, lưu thành tệp 15527_show.lsp.
  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 SHOW để chạy lisp.

Mã nguồn 15527_show.lsp (trích từ bài viết gốc)

(defun read-txt (filename / open_f line_r list-out file_read)
(setq list-out nil)
(if (/= (findfile filename) nil)
 (progn  
 (setq file_read (open filename "r"))
 (while
 (/= nil
 (setq line_r (read-line file_read))
  )
 (setq list-out (append list-out (list line_r)))
  )
 (close file_read)
)
(princ)  
)
list-out
)
;;;;;;;;;;;;;;;
;==== Load and check dialog ===========
; dia_name : string
(defun loadcl ( dia_name)
 (if (= -1 (setq dcl_id (load_dialog (strcat dia_name ".dcl"))))
(progn
  (alert (strcat dia_name ".dcl" "not found")
  (setq dialogloaded nil)
)		 
);p
(setq dialogloaded 1)
);f
);defun
;;;;;;;;;;;=========================
(defun c:show (/ fname  l1  dcl_id dialogloaded)
 (setq fname (getfiled "chon file"  "c:\\"  "*" 16)); lựa chọn file
;(setq fname "c:\\abc\\abc.txt"); hoặc chỉ định file
 (if (and
(/= fname nil)
(> (loadcl "thuty") 0); load and check dialog 
  ) 
  (if (not (new_dialog "thuty" dcl_id))
 (exit); Error
 (progn;else
		(start_list "doctxt")	 
		(mapcar' add_list (read-txt fname))  
		(end_list)
		(start_dialog)						 
		(done_dialog)
	(unload_dialog dcl_id)
);p

  );if1 
  );if
 (princ)
);defun

Thảo luận gốc

Lisp được chia sẻ trong chủ đề Giao diện hộp thoại trong AutoLisp. Xem đúng bài viết #15527 để đọc hướng dẫn và trao đổi thêm.

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