Jump to content

Lisp lệnh CCBLQ trong chủ đề “nhờ các bác viết lisp copy và xoay đối tượng hướng về nhau”

(defun c:ccblq ()

(princ "\nChon mot block")
(setq dchon (entsel))
(while
(or
(null (car dchon))
(and (/= "INSERT" (cdr (assoc 0 (entget (car dchon)))))
)
)
(princ "\nChon block khong thanh cong. Chon lai Block!")
(setq dchon (entsel))
)

(setq dchond (car dchon))
(setq diemdcl (getpoint "Diem chuan"))

(setq diemdclm (getpoint diemdcl"\nDiem thu nhat"))
(command ".copy" dchond "" "_non" diemdcl "_non" diemdclm "")
(setq diemdclh (getpoint diemdclm"\nDiem thu hai"))
(setq gocbl (angle diemdclh diemdclm))
(setq DTMs (subst (cons 50 (+ (/ pi 2) gocbl)) (assoc 50 (entget (entlast))) (entget (entlast))))
(entmod DTMs)

(command ".copy" dchond "" "_non" diemdcl "_non" diemdclh "")
(setq DTMs (subst (cons 50 (+ (/ (* 3 pi) 2) gocbl)) (assoc 50 (entget (entlast))) (entget (entlast))))
(entmod DTMs)

(setq diemdclm diemdclh)

(while (setq diemdclh (getpoint diemdclm"\nDiem tiep theo <Enter de ket thuc>!"))

(command ".copy" dchond "" "_non" diemdcl "_non" diemdclm "")
(setq gocbl (angle diemdclh diemdclm))
(setq DTMs (subst (cons 50 (+ (/ pi 2) gocbl)) (assoc 50 (entget (entlast))) (entget (entlast))))
(entmod DTMs)

(command ".copy" dchond "" "_non" diemdcl "_non" diemdclh "")
(setq DTMs (subst (cons 50 (+ (/ (* 3 pi) 2) gocbl)) (assoc 50 (entget (entlast))) (entget (entlast))))
(entmod DTMs)

(setq diemdclm diemdclh)

)
(princ))
(defun c:ccblq ()

(princ "\nChon mot block")
(setq dchon (entsel))
(while
(or
(null (car dchon))
(and (/= "INSERT" (cdr (assoc 0 (entget (car dchon)))))
)
)
(princ "\nChon block khong thanh cong. Chon lai Block!")
(setq dchon (entsel))
)

(setq dchond (car dchon))
(setq diemdcl (getpoint "Diem chuan"))

(setq diemdclm (getpoint diemdcl"\nDiem thu nhat"))
(command ".copy" dchond "" "_non" diemdcl "_non" diemdclm "")
(setq diemdclh (getpoint diemdclm"\nDiem thu hai"))
(setq gocbl (angle diemdclh diemdclm))
(setq DTMs (subst (cons 50 (+ (/ pi 2) gocbl)) (assoc 50 (entget (entlast))) (entget (entlast))))
(entmod DTMs)

(command ".copy" dchond "" "_non" diemdcl "_non" diemdclh "")
(setq DTMs (subst (cons 50 (+ (/ (* 3 pi) 2) gocbl)) (assoc 50 (entget (entlast))) (entget (entlast))))
(entmod DTMs)

(setq diemdclm diemdclh)

(while (setq diemdclh (getpoint diemdclm"\nDiem tiep theo <Enter de ket thuc>!"))

(command ".copy" dchond "" "_non" diemdcl "_non" diemdclm "")
(setq gocbl (angle diemdclh diemdclm))
(setq DTMs (subst (cons 50 (+ (/ pi 2) gocbl)) (assoc 50 (entget (entlast))) (entget (entlast))))
(entmod DTMs)

(command ".copy" dchond "" "_non" diemdcl "_non" diemdclh "")
(setq DTMs (subst (cons 50 (+ (/ (* 3 pi) 2) gocbl)) (assoc 50 (entget (entlast))) (entget (entlast))))
(entmod DTMs)

(setq diemdclm diemdclh)

)
(princ))

Viết xong mới thấy có rồi. Tiếc công nên cũng up lên. Lệnh CCBLQ

 

 

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 432692_ccblq.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 CCBLQ để chạy lisp.

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

(defun c:ccblq ()

(princ "\nChon mot block")
(setq dchon (entsel))
(while
(or
(null (car dchon))
(and (/= "INSERT" (cdr (assoc 0 (entget (car dchon)))))
)
)
(princ "\nChon block khong thanh cong. Chon lai Block!")
(setq dchon (entsel))
)

(setq dchond (car dchon))
(setq diemdcl (getpoint "Diem chuan"))

(setq diemdclm (getpoint diemdcl"\nDiem thu nhat"))
(command ".copy" dchond "" "_non" diemdcl "_non" diemdclm "")
(setq diemdclh (getpoint diemdclm"\nDiem thu hai"))
(setq gocbl (angle diemdclh diemdclm))
(setq DTMs (subst (cons 50 (+ (/ pi 2) gocbl)) (assoc 50 (entget (entlast))) (entget (entlast))))
(entmod DTMs)

(command ".copy" dchond "" "_non" diemdcl "_non" diemdclh "")
(setq DTMs (subst (cons 50 (+ (/ (* 3 pi) 2) gocbl)) (assoc 50 (entget (entlast))) (entget (entlast))))
(entmod DTMs)

(setq diemdclm diemdclh)

(while (setq diemdclh (getpoint diemdclm"\nDiem tiep theo <Enter de ket thuc>!"))

(command ".copy" dchond "" "_non" diemdcl "_non" diemdclm "")
(setq gocbl (angle diemdclh diemdclm))
(setq DTMs (subst (cons 50 (+ (/ pi 2) gocbl)) (assoc 50 (entget (entlast))) (entget (entlast))))
(entmod DTMs)

(command ".copy" dchond "" "_non" diemdcl "_non" diemdclh "")
(setq DTMs (subst (cons 50 (+ (/ (* 3 pi) 2) gocbl)) (assoc 50 (entget (entlast))) (entget (entlast))))
(entmod DTMs)

(setq diemdclm diemdclh)

)
(princ))

(defun c:ccblq ()

(princ "\nChon mot block")
(setq dchon (entsel))
(while
(or
(null (car dchon))
(and (/= "INSERT" (cdr (assoc 0 (entget (car dchon)))))
)
)
(princ "\nChon block khong thanh cong. Chon lai Block!")
(setq dchon (entsel))
)

(setq dchond (car dchon))
(setq diemdcl (getpoint "Diem chuan"))

(setq diemdclm (getpoint diemdcl"\nDiem thu nhat"))
(command ".copy" dchond "" "_non" diemdcl "_non" diemdclm "")
(setq diemdclh (getpoint diemdclm"\nDiem thu hai"))
(setq gocbl (angle diemdclh diemdclm))
(setq DTMs (subst (cons 50 (+ (/ pi 2) gocbl)) (assoc 50 (entget (entlast))) (entget (entlast))))
(entmod DTMs)

(command ".copy" dchond "" "_non" diemdcl "_non" diemdclh "")
(setq DTMs (subst (cons 50 (+ (/ (* 3 pi) 2) gocbl)) (assoc 50 (entget (entlast))) (entget (entlast))))
(entmod DTMs)

(setq diemdclm diemdclh)

(while (setq diemdclh (getpoint diemdclm"\nDiem tiep theo <Enter de ket thuc>!"))

(command ".copy" dchond "" "_non" diemdcl "_non" diemdclm "")
(setq gocbl (angle diemdclh diemdclm))
(setq DTMs (subst (cons 50 (+ (/ pi 2) gocbl)) (assoc 50 (entget (entlast))) (entget (entlast))))
(entmod DTMs)

(command ".copy" dchond "" "_non" diemdcl "_non" diemdclh "")
(setq DTMs (subst (cons 50 (+ (/ (* 3 pi) 2) gocbl)) (assoc 50 (entget (entlast))) (entget (entlast))))
(entmod DTMs)

(setq diemdclm diemdclh)

)
(princ))

Thảo luận gốc

Lisp được chia sẻ trong chủ đề nhờ các bác viết lisp copy và xoay đối tượng hướng về nhau. Xem đúng bài viết #432692 để đọc hướng dẫn và trao đổi thêm.

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