Jump to content

Lisp lệnh SL trong chủ đề “Lisp Rãi Thép Sàn”

mình c?ng có lisp này. v? mình up lên giúp b?n

(defun c:SL ( / a1 c)
(setq luu (getvar "osmode"))
(setq lay (getvar "clayer"))
;(command "layer" "s" "Defpoints" "")
;(command "osnap" "Perp,Near")
(setq a1 (getdist "\nCh\U+1ECDn kho\U+1EA3ng r\U+1EA3i th\U+00E9p: ")) 
(or (and a (or (= (type a) 'int) (= (type a) 'real))) (setq a 200))
(setq a (cond ((getdist (strcat "\nKho\U+1EA3ng c\U+00E1ch thanh th\U+00E9p <" (rtos a 2 2) ">:"))) (a)))
(or (and hbv (or (= (type hbv) 'int) (= (type hbv) 'real))) (setq hbv 10))
(setq hbv (cond ((getreal (strcat "\nduong kinh thep <" (rtos hbv 2 2) ">: "))) (hbv)))
(setq c (+ (/ a1 a) 1))
(while (setq ent (nentsel "\nCh\U+1ECDn ghi gi\U+00E1 tr\U+1ECB (Text ho\U+0103c ATT):" ))
(and (wcmatch (cdr (assoc 0 (entget (car ent)))) "ATTRIB,*TEXT")
(vla-put-textstring (vlax-ename->vla-object  (car ent)) (strcat (rtos c 2 0) "%%c" (rtos hbv 2 0) "a" (rtos a 2 0) ) )))
(SETVAR "clayer" lay)
(setvar "osmode" luu)
(princ)
)

Cách dùng

  1. Tải tệp 401585_sl.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 SL để chạy lisp.

Mã nguồn 401585_sl.lsp

;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/163324-lisp-r%C3%A3i-th%C3%A9p-s%C3%A0n/
(defun c:SL ( / a1 c)
(setq luu (getvar "osmode"))
(setq lay (getvar "clayer"))
;(command "layer" "s" "Defpoints" "")
;(command "osnap" "Perp,Near")
(setq a1 (getdist "\nCh\U+1ECDn kho\U+1EA3ng r\U+1EA3i th\U+00E9p: ")) 
(or (and a (or (= (type a) 'int) (= (type a) 'real))) (setq a 200))
(setq a (cond ((getdist (strcat "\nKho\U+1EA3ng c\U+00E1ch thanh th\U+00E9p <" (rtos a 2 2) ">:"))) (a)))
(or (and hbv (or (= (type hbv) 'int) (= (type hbv) 'real))) (setq hbv 10))
(setq hbv (cond ((getreal (strcat "\nduong kinh thep <" (rtos hbv 2 2) ">: "))) (hbv)))
(setq c (+ (/ a1 a) 1))
(while (setq ent (nentsel "\nCh\U+1ECDn ghi gi\U+00E1 tr\U+1ECB (Text ho\U+0103c ATT):" ))
(and (wcmatch (cdr (assoc 0 (entget (car ent)))) "ATTRIB,*TEXT")
(vla-put-textstring (vlax-ename->vla-object  (car ent)) (strcat (rtos c 2 0) "%%c" (rtos hbv 2 0) "a" (rtos a 2 0) ) )))
(SETVAR "clayer" lay)
(setvar "osmode" luu)
(princ)
)

Thảo luận gốc

Lisp được chia sẻ trong chủ đề Lisp Rãi Thép Sàn. Xem đúng bài viết #401585 để đọc hướng dẫn và trao đổi thêm.

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