Jump to content

lisp kết hợp PL & UCS

Bạn đã biết vì sao bài của bạn bị mod xoá rồi ư?

Đây là lisp cho bạn (chú ý kích thước trên bản vẽ khác kết quả dim nhé)

(defun C:PL2( / p1 len p2)
(initget 1) (setq p1 (getpoint "\nChon diem bat dau: "))
(setq len (atof (cdr (assoc 1 (entget (car (entsel "\nChon Text de lay chieu dai: ")))))))
(setq p2 (polar p1 (/ pi -2) len))
(entmakex (list (cons 0 "LINE") (cons 10 p1) (cons 11 p2)))
(acet-sysvar-set (list "osmode" 0 "cmdecho" 0))
(command "ucs" p2 "")
(acet-sysvar-restore)
(command "pline"))
;----- CHU Y: Gia tri dim tren ban ve cho thay: muon co ket qua dung can phai nhan/chia chieu dai cho 1 he so.

 

Trước hết cảm ơn Bác đã giành thời gian giúp em.

Em chạy lisp của bác nhưng nó báo lỗi:

 

 

Command: pl2

 

Chon diem bat dau:

Chon Text de lay chieu dai: ; error: no function definition: ACET-SYSVAR-SET

Bác xem lại giúp em

Cách dùng

  1. Tải tệp 190977_pl2.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 PL2 để chạy lisp.

Mã nguồn 190977_pl2.lsp

;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/62157-y%C3%AAu-c%E1%BA%A7u-lisp-k%E1%BA%BFt-h%E1%BB%A3p-pl-ucs/
(defun C:PL2( / p1 len p2)
(initget 1) (setq p1 (getpoint "\nChon diem bat dau: "))
(setq len (atof (cdr (assoc 1 (entget (car (entsel "\nChon Text de lay chieu dai: ")))))))
(setq p2 (polar p1 (/ pi -2) len))
(entmakex (list (cons 0 "LINE") (cons 10 p1) (cons 11 p2)))
(acet-sysvar-set (list "osmode" 0 "cmdecho" 0))
(command "ucs" p2 "")
(acet-sysvar-restore)
(command "pline"))
;----- CHU Y: Gia tri dim tren ban ve cho thay: muon co ket qua dung can phai nhan/chia chieu dai cho 1 he so.

Thảo luận gốc

Lisp được chia sẻ trong chủ đề [ Yêu Cầu ] lisp kết hợp PL & UCS. Xem đúng bài viết #190977 để đọc hướng dẫn và trao đổi thêm.

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