Lisp lệnh LEN trong chủ đề “đo SPL nhanh nhất _ HTR”
các bác cho em hỏicác bác cho em hỏi em có 1 đo9ạn SPL , giao của spl với các đoạn thẳng là A,B,C,D,E,Flàm sao để đo chiều dài các đoạn AB,CB,CD, EFcủa nó 1 các nhanh nhất hoặc các bác có lisp cho em cũng ddược .Thank các bác
Bạn sài thử LISP này :
Chấp nhận các đối tuợng : LINE,ARC,SPLINE,LWPOLYLINE,POLYLINE,CIRCLE,ELLIPSE
(defun c:len (/ *error* vl ov ob p1 p2 pa1 pa2 len)
(defun *error* (msg)
(if ov (mapcar 'setvar vl ov))
(redraw ob 4)
(if (not(wcmatch (strcase msg) "*BREAK,*EXIT*,*CANCEL*"))
(princ (strcat "\n** Error: " msg " **")))
(princ))
(vl-load-com)
(setq vl '("CMDECHO" "OSMODE" "orthomode")
ov (mapcar 'getvar vl))
(mapcar 'setvar vl '(0 33 0))
(while
(not
(and
(setq ob (car(entsel "\nChon doi tuong can do (LINE,ARC,SPLINE,LWPOLYLINE,POLYLINE,CIRCLE,ELLIPSE) : ")))
(if ob (wcmatch (cdr (assoc 0 (entget ob))) "*LINE,ARC,CIRCLE,ELLIPSE") )
)
)
(alert "\nDoi tuong da chon khong phu hop.
\nChap nhan cac doi tuong : LINE,ARC,SPLINE,LWPOLYLINE,POLYLINE,CIRCLE,ELLIPSE
\nChon lai :")
)
(redraw ob 3)
(while (and
(setq p1 (getpoint "\nTu diem :"))
(setq p2 (getpoint "\nDem diem :"))
)
(if (and
(setq pa1 (vlax-curve-getParamAtPoint ob p1))
(setq pa2 (vlax-curve-getParamAtPoint ob p2))
)
(progn
(setq len (abs (- (vlax-curve-getdistatparam ob pa1)
(vlax-curve-getdistatparam ob pa2))) )
(princ (strcat "\nChieu dai la : " (rtos len) "\n-------------------"))
)
(alert "\nDiem chon khong thuoc doi tuong can do ! \nChon lai :" )
)
)
(redraw ob 4)
(mapcar 'setvar vl ov)
(princ)
)
- Tải lisp
- 73814_len.lsp
Cách dùng
- Tải tệp 73814_len.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 LEN để chạy lisp.
Mã nguồn 73814_len.lsp
;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/13554-%C4%91o-spl-nhanh-nh%E1%BA%A5t-_-htr/
(defun c:len (/ *error* vl ov ob p1 p2 pa1 pa2 len)
(defun *error* (msg)
(if ov (mapcar 'setvar vl ov))
(redraw ob 4)
(if (not(wcmatch (strcase msg) "*BREAK,*EXIT*,*CANCEL*"))
(princ (strcat "\n** Error: " msg " **")))
(princ))
(vl-load-com)
(setq vl '("CMDECHO" "OSMODE" "orthomode")
ov (mapcar 'getvar vl))
(mapcar 'setvar vl '(0 33 0))
(while
(not
(and
(setq ob (car(entsel "\nChon doi tuong can do (LINE,ARC,SPLINE,LWPOLYLINE,POLYLINE,CIRCLE,ELLIPSE) : ")))
(if ob (wcmatch (cdr (assoc 0 (entget ob))) "*LINE,ARC,CIRCLE,ELLIPSE") )
)
)
(alert "\nDoi tuong da chon khong phu hop.
\nChap nhan cac doi tuong : LINE,ARC,SPLINE,LWPOLYLINE,POLYLINE,CIRCLE,ELLIPSE
\nChon lai :")
)
(redraw ob 3)
(while (and
(setq p1 (getpoint "\nTu diem :"))
(setq p2 (getpoint "\nDem diem :"))
)
(if (and
(setq pa1 (vlax-curve-getParamAtPoint ob p1))
(setq pa2 (vlax-curve-getParamAtPoint ob p2))
)
(progn
(setq len (abs (- (vlax-curve-getdistatparam ob pa1)
(vlax-curve-getdistatparam ob pa2))) )
(princ (strcat "\nChieu dai la : " (rtos len) "\n-------------------"))
)
(alert "\nDiem chon khong thuoc doi tuong can do ! \nChon lai :" )
)
)
(redraw ob 4)
(mapcar 'setvar vl ov)
(princ)
)Thảo luận gốc
Lisp được chia sẻ trong chủ đề đo SPL nhanh nhất _ HTR. Xem đúng bài viết #73814 để đọc hướng dẫn và trao đổi thêm.
