;;; 程序整理BY USER2128(HLCAD),欢迎使用。- ;;; 返回多段线凸度处的 (圆心点坐标 半径 起始角 终止角)
- ;|
- Ex:
- (mapcar (function (lambda(x) (apply 'cvtbulge x)))
- (mapcar 'cdr (plarcinfo (entget (car (entsel))))))
- ==> (((1746.88 1442.56) 100.0 1.83905 2.86187)
- ((1775.67 1450.48) 100.0 0.268258 1.83905))
- (圆心点坐标 半径 起始角 终止角)
- |;
- (defun cvtbulge (sp bulge ep / cotbce x1 x2 y1 y2 temp
- cen rad sa ea)
- (setq x1 (car sp) x2 (car ep))
- (setq y1 (cadr sp) y2 (cadr ep))
- (setq cotbce (/ (- (/ 1.0 bulge) bulge) 2.0))
-
- ; Compute center point and radius
- (setq cen (list (/ (+ x1 x2 (- (* (- y2 y1) cotbce))) 2.0)
- (/ (+ y1 y2 (* (- x2 x1) cotbce) ) 2.0))
- )
- (setq rad (distance cen sp))
-
- ; Compute start and end angles
- (setq sa (atan (- y1 (cadr cen)) (- x1 (car cen))))
- (setq ea (atan (- y2 (cadr cen)) (- x2 (car cen))))
- (if (< sa 0.0) ; Eliminate negative angles
- (setq sa (+ sa (* 2.0 pi)))
- )
- (if (< ea 0.0)
- (setq ea (+ ea (* 2.0 pi)))
- )
- (if (< bulge 0.0) ; Swap angles if clockwise
- (progn
- (setq temp sa)
- (setq sa ea)
- (setq ea temp)
- )
- )
- (list cen rad sa ea)
- )
- ;;; =============================================
- ;;;程序得到多段线在哪个顶点开始有圆弧,并且圆弧的信息。
- ;;; (plarcinfo (entget (car (entsel))))
- ; ==> ((2 (1566.14 815.301 0.0) 0.567253 (1625.41 877.383 0.0))
- ; (4 (1537.78 1194.31 0.0) 0.414214 (1476.26 1229.18 0.0)))
- (defun plarcinfo (el / i lst bl)
- (setq i -1)
- (if (setq lst (vl-remove nil
- (mapcar
- (function (lambda (y) (setq i (1+ i)) (if (zerop y) nil i)))
- (setq bl(mapcar 'cdr(vl-remove-if-not '(lambda(x)(=(car x)42))el)))
- )))
- (mapcar 'cons lst
- (mapcar '(lambda (x y)
- (setq e (cdr (assoc -1 el)))
- (list (vlax-curve-getpointatparam e x)
- y
- (vlax-curve-getpointatparam e (1+ x))
- )
- ) lst (vl-remove 0. bl))
- )
- )
- )
- ;;; =============================================
|