Lisp lệnh TD trong chủ đề “nhờ các bác viết giúp e lips pick 1 điểm xuất ra tọa độ dưới dạng (x;y)”
Có phải như vầy không.
(defun c:td( / get-x get-y oce xp yp rwc )
(setq oce (getvar "cmdecho"))
(setvar "cmdecho" 0)
(setvar "luprec" 4)
(main)
(setvar "cmdecho" oce)
)
;;;----------------------------- Leader Placement Routine ---------------------
;;; Here is where the leaders are actually written to the database
;;; based upon the value of coordinates passed from module "MAIN" .
;;; Null points are ignored.
(defun do_put_leader( xyp )
(command "_.leader" rwc pause "" xyp "")
)
;;;----------------------------- xyz coordinate breakdown ----------------------
;;; This routine accepts a point from the calling function and breaks it down
;;; into X,Y values.
(defun get_xyz ( pt )
(strcat "(" (rtos (* 0.001 (car pt)) 2 3) ";" (rtos (* 0.001 (cadr pt)) 2 3) ")"))
;;;-------------------Secondary main module------------------------------------
;;; Accepts the user input and allows the user to select many objects in
;;; succession.
(defun main()
(setq olddim (getvar "dimstyle"))
(setq a (getreal "\n Input Text Height for Annotation : <2.5> "))
(if (null a) (setq a 2.5))
(setvar "dimtxt" a)
(while (setq rwc (getpoint "\nSelect point: "))
(do_put_leader (get_xyz rwc))
)
(command "dimstyle" "restore" olddim)
)
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
- Chép mã nguồn, lưu thành tệp 294917_td.lsp.
- 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 TD để chạy lisp.
Mã nguồn 294917_td.lsp (trích từ bài viết gốc)
(defun c:td( / get-x get-y oce xp yp rwc )
(setq oce (getvar "cmdecho"))
(setvar "cmdecho" 0)
(setvar "luprec" 4)
(main)
(setvar "cmdecho" oce)
)
;;;----------------------------- Leader Placement Routine ---------------------
;;; Here is where the leaders are actually written to the database
;;; based upon the value of coordinates passed from module "MAIN" .
;;; Null points are ignored.
(defun do_put_leader( xyp )
(command "_.leader" rwc pause "" xyp "")
)
;;;----------------------------- xyz coordinate breakdown ----------------------
;;; This routine accepts a point from the calling function and breaks it down
;;; into X,Y values.
(defun get_xyz ( pt )
(strcat "(" (rtos (* 0.001 (car pt)) 2 3) ";" (rtos (* 0.001 (cadr pt)) 2 3) ")"))
;;;-------------------Secondary main module------------------------------------
;;; Accepts the user input and allows the user to select many objects in
;;; succession.
(defun main()
(setq olddim (getvar "dimstyle"))
(setq a (getreal "\n Input Text Height for Annotation : <2.5> "))
(if (null a) (setq a 2.5))
(setvar "dimtxt" a)
(while (setq rwc (getpoint "\nSelect point: "))
(do_put_leader (get_xyz rwc))
)
(command "dimstyle" "restore" olddim)
)
Thảo luận gốc
Lisp được chia sẻ trong chủ đề nhờ các bác viết giúp e lips pick 1 điểm xuất ra tọa độ dưới dạng (x;y). Xem đúng bài viết #294917 để đọc hướng dẫn và trao đổi thêm.