Lisp đo bán kính sau khi Fillet
13 phút trước, ngokiet đã nói:Hình như bác không xem kỹ. nếu 2 line hay 2 arc thì mới có entlast đễ ghi kích thước thì dễ rồi. 2 polyline thì khó.
Vấn đề của mình là ở chỗ này.
Sau khi filett xong nó trở thành 1 đối tượng làm sao để chọn đối tượng đó (mình có lisp đo đường polyline rồi)
Lisp đo đường polyline có đường cong:
(defun c:DSE (/ h lt acadobj ddat e s dis doc i modelspace obj ang ang1 ang2 m etype LM:BulgeCenter)
(defun LM:BulgeCenter (p1 p2 B)
(polar p1 (+ (angle p1 p2) (- (/ pi 2) (* 2 (atan B)))) (/ (* (distance p1 p2) (1+ (* b B))) 4 B)))
(defun etype (e / x)
(or (setq x (entget e)) (and (setq x (entget (entdel e))) (entdel e)))
(cdr (assoc 0 x)))
(setq acadObj (vlax-get-acad-object))
(setq doc (vla-get-activedocument acadObj))
(setq modelSpace (vla-get-modelspace doc))
;(setq i 0)
(setq h (getvar "Dimtxt"))
(setq lt (getvar "Dimscale"))
(if (setq j -1
s (ssget '((0 . "*POLYLINE")))
)
(repeat (sslength s)
(setq e (ssname s (setq j (1+ j))))
(setq i 0)
(if (wcmatch (etype e) "*POLYLINE")
(if (setq ddat (getpoint (vlax-curve-getstartpoint e) "\nPhia dat Dim (Pick diem):"))
(progn
(setq ang1 (angle (vlax-curve-getstartpoint e) (vlax-curve-getpointatparam e (1+ i)))
ang2 (angle (vlax-curve-getstartpoint e) ddat)
ang (- ang2 ang1))
(cond ((= ang1 0)
(cond ((< ang2 (* pi 1.0)) (setq m -2.0))
(t (setq m +2.0))))
((= ang1 (* pi 0.5))
(cond ((< ang2 (* pi 0.5)) (setq m +2.0))
((> ang2 (* pi 1.5)) (setq m +2.0))
(t (setq m -2.0))))
((= ang1 (* pi 1.0))
(cond ((< ang2 (* pi 1.0)) (setq m +2.0))
((> ang2 (* pi 2.0)) (setq m -2.0))
(t (setq m -2.0))))
((= ang1 (* pi 1.5))
(cond ((< ang2 (* pi 0.5)) (setq m -2.0))
((< ang2 (* pi 1.5)) (setq m +2.0))
((> ang2 (* pi 1.5)) (setq m -2.0))
(t (setq m -2.0))))
(t
(cond ((< ang (* pi 0.0)) (setq m +2.0))
((< ang (* pi 1.0)) (setq m -2.0))
((< ang (* pi 2.0)) (setq m +2.0)))))
(setq obj (vlax-ename->vla-object e))
;(setq dis (distance ddat (vlax-curve-getstartpoint e)))
(setq dis (* (* h lt) 2.5))
(repeat (fix (vlax-curve-getendparam e))
(if (= 0 (vla-getbulge obj i))
(vla-adddimaligned modelSpace
(vlax-3d-point (vlax-curve-getpointatparam e i))
(vlax-3d-point (vlax-curve-getpointatparam e (1+ i)))
(vlax-3d-point (polar (vlax-curve-getpointatparam e (+ i 0.5))
(- (angle '(0 0 0) (vlax-curve-getfirstderiv e (+ i 0.5))) (/ pi m))
dis)))
(progn
(vla-adddimarc modelSpace
(vlax-3d-point (LM:BulgeCenter (vlax-curve-getpointatparam e i)
(vlax-curve-getpointatparam e (1+ i))
(vla-getbulge obj i)))
(vlax-3d-point (vlax-curve-getpointatparam e i))
(vlax-3d-point (vlax-curve-getpointatparam e (1+ i)))
(vlax-3d-point (polar (vlax-curve-getpointatparam e (+ i 0.5))
(- (angle '(0 0 0) (vlax-curve-getfirstderiv e (+ i 0.5))) (/ pi m))
dis)))
(vla-adddimradial modelSpace
(vlax-3d-point (LM:BulgeCenter (vlax-curve-getpointatparam e i)
(vlax-curve-getpointatparam e (1+ i))
(vla-getbulge obj i)))
(vlax-3d-point (vlax-curve-getpointatparam e (+ i 0.5)))
-0.5))) ;if
(setq i (1+ i))) ;Repeat
) ;progn
) ;if
)
); repeat
) ;if
(princ))
- Tải lisp
- 436170_dse.lsp
Cách dùng
- Tải tệp 436170_dse.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 DSE để chạy lisp.
Mã nguồn 436170_dse.lsp
;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/176141-gi%C3%BAp-%C4%91%E1%BB%A1-lisp-%C4%91o-b%C3%A1n-k%C3%ADnh-sau-khi-fillet/
(defun c:DSE (/ h lt acadobj ddat e s dis doc i modelspace obj ang ang1 ang2 m etype LM:BulgeCenter)
(defun LM:BulgeCenter (p1 p2 B)
(polar p1 (+ (angle p1 p2) (- (/ pi 2) (* 2 (atan B)))) (/ (* (distance p1 p2) (1+ (* b B))) 4 B)))
(defun etype (e / x)
(or (setq x (entget e)) (and (setq x (entget (entdel e))) (entdel e)))
(cdr (assoc 0 x)))
(setq acadObj (vlax-get-acad-object))
(setq doc (vla-get-activedocument acadObj))
(setq modelSpace (vla-get-modelspace doc))
;(setq i 0)
(setq h (getvar "Dimtxt"))
(setq lt (getvar "Dimscale"))
(if (setq j -1
s (ssget '((0 . "*POLYLINE")))
)
(repeat (sslength s)
(setq e (ssname s (setq j (1+ j))))
(setq i 0)
(if (wcmatch (etype e) "*POLYLINE")
(if (setq ddat (getpoint (vlax-curve-getstartpoint e) "\nPhia dat Dim (Pick diem):"))
(progn
(setq ang1 (angle (vlax-curve-getstartpoint e) (vlax-curve-getpointatparam e (1+ i)))
ang2 (angle (vlax-curve-getstartpoint e) ddat)
ang (- ang2 ang1))
(cond ((= ang1 0)
(cond ((< ang2 (* pi 1.0)) (setq m -2.0))
(t (setq m +2.0))))
((= ang1 (* pi 0.5))
(cond ((< ang2 (* pi 0.5)) (setq m +2.0))
((> ang2 (* pi 1.5)) (setq m +2.0))
(t (setq m -2.0))))
((= ang1 (* pi 1.0))
(cond ((< ang2 (* pi 1.0)) (setq m +2.0))
((> ang2 (* pi 2.0)) (setq m -2.0))
(t (setq m -2.0))))
((= ang1 (* pi 1.5))
(cond ((< ang2 (* pi 0.5)) (setq m -2.0))
((< ang2 (* pi 1.5)) (setq m +2.0))
((> ang2 (* pi 1.5)) (setq m -2.0))
(t (setq m -2.0))))
(t
(cond ((< ang (* pi 0.0)) (setq m +2.0))
((< ang (* pi 1.0)) (setq m -2.0))
((< ang (* pi 2.0)) (setq m +2.0)))))
(setq obj (vlax-ename->vla-object e))
;(setq dis (distance ddat (vlax-curve-getstartpoint e)))
(setq dis (* (* h lt) 2.5))
(repeat (fix (vlax-curve-getendparam e))
(if (= 0 (vla-getbulge obj i))
(vla-adddimaligned modelSpace
(vlax-3d-point (vlax-curve-getpointatparam e i))
(vlax-3d-point (vlax-curve-getpointatparam e (1+ i)))
(vlax-3d-point (polar (vlax-curve-getpointatparam e (+ i 0.5))
(- (angle '(0 0 0) (vlax-curve-getfirstderiv e (+ i 0.5))) (/ pi m))
dis)))
(progn
(vla-adddimarc modelSpace
(vlax-3d-point (LM:BulgeCenter (vlax-curve-getpointatparam e i)
(vlax-curve-getpointatparam e (1+ i))
(vla-getbulge obj i)))
(vlax-3d-point (vlax-curve-getpointatparam e i))
(vlax-3d-point (vlax-curve-getpointatparam e (1+ i)))
(vlax-3d-point (polar (vlax-curve-getpointatparam e (+ i 0.5))
(- (angle '(0 0 0) (vlax-curve-getfirstderiv e (+ i 0.5))) (/ pi m))
dis)))
(vla-adddimradial modelSpace
(vlax-3d-point (LM:BulgeCenter (vlax-curve-getpointatparam e i)
(vlax-curve-getpointatparam e (1+ i))
(vla-getbulge obj i)))
(vlax-3d-point (vlax-curve-getpointatparam e (+ i 0.5)))
-0.5))) ;if
(setq i (1+ i))) ;Repeat
) ;progn
) ;if
)
); repeat
) ;if
(princ))Thảo luận gốc
Lisp được chia sẻ trong chủ đề [Giúp đỡ] Lisp đo bán kính sau khi Fillet. Xem đúng bài viết #436170 để đọc hướng dẫn và trao đổi thêm.