culiang10086 发表于 2015-9-29 13:30
程序只能从弧的右侧到左侧吗
顺时针
- ;圆弧转PL线弦长定距版
- ;code by edata @mjtd.com 2015-9-28 22:14:47
- (defun c:tt(/ ss en ds lst x)
- (if(and (setq ss(ssget '((0 . "arc"))))
- (setq ds(getreal "\n输入等分弦长间距:")))
- (while(setq en(ssname ss 0))
- (setq lst(sk_div_pts en ds))
- (and lst
- (entmake (append (list '(0 . "LWPOLYLINE")
- '(100 . "AcDbEntity")
- '(100 . "AcDbPolyline")
- (cons 90 (length lst))
- )
- (mapcar '(lambda (x) (cons 10 x)) lst)
- )
- )
- )
- (setq ss(ssdel en ss))
- )
- )
- (princ)
- )
- ;;arc定距弦长等分函数
- (defun sk_div_pts(en ds / obj arc_len lst i reptime cen pt rad xian_len)
- (if en
- (progn
- (setq obj(vlax-ename->vla-object en)
- arc_len(vla-get-arclength obj)
- xian_len(distance (vlax-curve-getStartPoint obj)(vlax-curve-getEndPoint obj))
- )
- (cond
- ((or (>= ds xian_len) (>= ds arc_len))
- (setq lst(list(vlax-curve-getStartPoint obj)(vlax-curve-getEndPoint obj)))
- )
- ((< ds arc_len)
- (setq reptime (fix (/ arc_len ds)))
- (setq i -1
- pt (vlax-curve-getEndPoint obj)
- rad(vla-get-radius obj)
- cen(cdr(assoc 10 (entget en)))
- lst(list pt))
- (repeat reptime
- (setq pt(polar cen (- (angle cen pt) (sk_atan (* ds 0.5) rad)) rad))
- (setq lst(cons pt lst))
- )
- (if (not(equal (vlax-curve-getStartPoint obj) (car lst) 1e-8))
- (setq lst(cons (vlax-curve-getStartPoint obj) lst))
- )
- )
- )
- )
- )
- )
- ;;已知弦长半径求圆心角
- (defun sk_atan(a c / b)
- (if(and a c)
- (progn
- (setq b(sqrt(abs(-(* c c)(* a a)))))
- (* (atan (/ (* a 1.0) b)) 2.0)
- )
- )
- )
|