Về vấn đề lisp xoay block theo đường dẫn
Mình có sưu tầm một lisp trên CV của bác KangKung, lisp có công dụng xoay đối tượng block theo đường line, pline, nhưng spline thì không thực hiện được.
Xin nhờ các anh em trong diễn đàn chỉnh sửa giúp nhé, xin cảm ơn.
;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/69764-y%C3%AAu-c%E1%BA%A7u-lisp-xoay-block-theo-h%C6%B0%E1%BB%9Bng-pline-cho-tr%C6%B0%E1%BB%9Bc/
;========LISP XOAY BLOCK THEO HUONG TUYEN==========
;=============KANGKUNG 28/03/2013==================
(defun C:QB()
(command "UNDO" "BE")
(setq tuyen nil)
(while (= (setq tuyen (car (entsel "\n Chon tuyen:\n"))) nil))
(setq taphop(ssget '((0 . "INSERT"))))
(setq index 0)
(while (< index (sslength taphop))
(setq block(entget (ssname taphop index)))
(setq insertpoint(cdr (assoc 10 block)))
(if (= (vlax-curve-getDistAtPoint tuyen (vlax-curve-getClosestPointTo tuyen insertpoint)) (vla-get-length (vlax-ename->vla-object tuyen)))
(entmod (subst (cons 50 (+ pi (angle (vlax-curve-getClosestPointTo tuyen insertpoint) ( vlax-curve-getPointAtDist tuyen (+ (vlax-curve-getDistAtPoint tuyen (vlax-curve-getClosestPointTo tuyen insertpoint)) -0.001))))) (assoc 50 block) block))
(entmod (subst (cons 50 (+ pi (angle ( vlax-curve-getPointAtDist tuyen (+ (vlax-curve-getDistAtPoint tuyen (vlax-curve-getClosestPointTo tuyen insertpoint)) 0.001)) (vlax-curve-getClosestPointTo tuyen insertpoint)))) (assoc 50 block) block))
)
(setq index (+ index 1)))
(command "UNDO" "END")
)
(princ "\n Written By KangKung - 28/03/2013\n")
(princ "\n Nhap KK de chay chuong trinh\n")
- Tải lisp
- 439947_qb.lsp
Cách dùng
- Tải tệp 439947_qb.lsp về máy.
- 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ẽ.
- Gõ lệnh QB để chạy lisp.
Mã nguồn 439947_qb.lsp
;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/177593-nh%E1%BB%9D-ch%E1%BB%89nh-s%E1%BB%ADa-v%E1%BB%81-v%E1%BA%A5n-%C4%91%E1%BB%81-lisp-xoay-block-theo-%C4%91%C6%B0%E1%BB%9Dng-d%E1%BA%ABn/
;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/69764-y%C3%AAu-c%E1%BA%A7u-lisp-xoay-block-theo-h%C6%B0%E1%BB%9Bng-pline-cho-tr%C6%B0%E1%BB%9Bc/
;========LISP XOAY BLOCK THEO HUONG TUYEN==========
;=============KANGKUNG 28/03/2013==================
(defun C:QB()
(command "UNDO" "BE")
(setq tuyen nil)
(while (= (setq tuyen (car (entsel "\n Chon tuyen:\n"))) nil))
(setq taphop(ssget '((0 . "INSERT"))))
(setq index 0)
(while (< index (sslength taphop))
(setq block(entget (ssname taphop index)))
(setq insertpoint(cdr (assoc 10 block)))
(if (= (vlax-curve-getDistAtPoint tuyen (vlax-curve-getClosestPointTo tuyen insertpoint)) (vla-get-length (vlax-ename->vla-object tuyen)))
(entmod (subst (cons 50 (+ pi (angle (vlax-curve-getClosestPointTo tuyen insertpoint) ( vlax-curve-getPointAtDist tuyen (+ (vlax-curve-getDistAtPoint tuyen (vlax-curve-getClosestPointTo tuyen insertpoint)) -0.001))))) (assoc 50 block) block))
(entmod (subst (cons 50 (+ pi (angle ( vlax-curve-getPointAtDist tuyen (+ (vlax-curve-getDistAtPoint tuyen (vlax-curve-getClosestPointTo tuyen insertpoint)) 0.001)) (vlax-curve-getClosestPointTo tuyen insertpoint)))) (assoc 50 block) block))
)
(setq index (+ index 1)))
(command "UNDO" "END")
)
(princ "\n Written By KangKung - 28/03/2013\n")
(princ "\n Nhap KK de chay chuong trinh\n")Thảo luận gốc
Lisp được chia sẻ trong chủ đề [NHỜ CHỈNH SỬA] Về vấn đề lisp xoay block theo đường dẫn. Xem đúng bài viết #439947 để đọc hướng dẫn và trao đổi thêm.