Jump to content

Lisp lệnh IMF trong chủ đề “Viết lisp theo yêu cầu [phần 2]”


Phiphi dùng lisp IMF (insert multi files) dưới đây

Cách dùng

  1. Tải tệp 90778_imf.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 IMF để chạy lisp.

Mã nguồn 90778_imf.lsp

;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/13203-vi%E1%BA%BFt-lisp-theo-y%C3%AAu-c%E1%BA%A7u-ph%E1%BA%A7n-2/?page=39
(defun c:imf()
 (setq pathname (vl-filename-directory (getfiled "Hay chon file dwg bat ky thuoc thu muc" "" "dwg" 0))
filelist (vl-sort (vl-directory-files pathname "*.dwg") '	p (getpoint "\nDiem chen: ")
xht (car p)
yht (cadr p)	
 )
 (setq oldos (getvar "osmode"))
 (setvar "osmode" 0)
 (foreach filename filelist    
   (command "-insert" (strcat pathname "/" filename) (list xht yht) 1.0 1.0 0.0)
   (vla-getboundingbox (vlax-ename->vla-object (entlast)) 'p1 'p2)    
   (setq
     p1 (vlax-safearray->list p1)
     p2 (vlax-safearray->list p2)      
     xht (+ xht (abs (car (mapcar '- p2 p1))))
     blname (cdr (assoc 2 (entget (entlast))))
   )
   (command ".explode" (entlast) "")    
   (command "-purge" "Block" blname "N")
 )
 (setvar "osmode" oldos)
 (princ)
)

Thảo luận gốc

Lisp được chia sẻ trong chủ đề Viết lisp theo yêu cầu [phần 2]. Xem đúng bài viết #90778 để đọc hướng dẫn và trao đổi thêm.

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