- 积分
- 3689
- 明经币
- 个
- 注册时间
- 2006-3-31
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2019-12-18 21:11:13
|
显示全部楼层
本帖最后由 caiqs 于 2019-12-18 22:01 编辑
;;试试这个吧,应该可以用了只要是曲线就行
;;圆椭圆多段线样条构造线射线都可以,按A可以锁定中点;;块可以了
(vl-load-com)
;;求两点之中点
(defun getmidpt (p1 p2)
(mapcar '(lambda (x)
(* 0.5 x)
)
(mapcar '+ p1 p2)
)
)
(defun getprep (spt ept p3 / tmppt intpt)
(setq tmppt (polar p3 (+ (angle spt ept) (* 0.5 pi)) 10))
(setq intpt (inters tmppt p3 spt ept nil))
)
;;;用A键切换中垂线和智能捕捉中点垂线
(defun c:ts2 (/ ang ang1 endpt ent entdat entpick
etype intpt len midpt mode p1 p2
pickpt pt ret startpt tmppt
)
(while (and
(setq entpick (vl-catch-all-apply 'entsel '("\n選取直線 :")))
(not (VL-CATCH-ALL-ERROR-P entpick))
)
(setq ent (car entpick))
(setq entdat (entget ent)
etype (cdr (assoc 0 entdat))
)
(setq pickpt (cadr entpick)) ;_点取的点
(cond
((member etype
'("CIRCLE" "ELLIPSE" "RAY" "LINE" "XLINE" "SPLINE"
"LWPOLYLINE")
)
(setq intpt (vlax-curve-getClosestPointTo ent pickpt)) ;_最近点
)
(t (setq intpt (osnap pickpt "_nea")))
)
(setq ang1 (angle pickpt intpt))
(setq
;;startpt (cdr (assoc 10 entdat))
startpt (polar intpt (+ ang1 (* 0.5 PI)) 10)
endpt (polar intpt (- ang1 (* 0.5 PI)) 10)
;; endpt (cdr (assoc 11 entdat))
;;midpt (getmidpt startpt endpt)
midpt (osnap intpt "_mid")
;;len (DISTANCE startpt endpt)
len 1000.0
ang (angle startpt endpt)
mode nil
)
(while (and
(setq ret (grread t 12))
(member (car ret) '(2 5))
)
(redraw)
(cond
((= (car ret) 2) (setq mode (not mode)))
(mode
(cond
((member etype '("CIRCLE" "ELLIPSE" "RAY"))
(setq intpt (cdr (assoc 10 entdat)))
)
(t
(if midpt
(setq intpt midpt)
(setq intpt (osnap pt "_mid"))
)
)
)
)
((= (car ret) 5)
(setq pt (cadr ret))
;;; (setq intpt (getprep startpt endpt pt))
(setq intpt (osnap pt "_nea,_int,End,_mid,_cen,_qua,_tan"))
)
)
(if (null intpt)
(progn
(setq tmppt (polar pt ang1 10))
(setq intpt (INTERS pt tmppt startpt endpt nil))
)
)
(setq p1 (polar intpt (+ ang (* 0.5 PI)) (* 0.5 len))
p2 (polar intpt (- ang (* 0.5 pi)) (* 0.5 len))
)
(grdraw p1 p2 3 1)
)
(redraw)
(if (= (car ret) 3)
(entmake (list '(0 . "LINE")
(cons 10 P1)
(cons 11 P2)
)
)
)
)
)
|
|