潜伏,
这将绘制样条曲线(我希望是齿轮的正确轮廓)
- (defun c:gear (/ e o r a i l)
- (if
- (and
- (setq e (car (entsel)))
- (eq (cdr (assoc 0 (setq e (entget e)))) "CIRCLE")
- )
- (progn
- (setq o (cdr (assoc 10 e))
- r (cdr (assoc 40 e))
- a (/ pi 180)
- i -1)
- (repeat 360
- (setq l (cons (polar (polar o (* a (setq i (1+ i))) r) (- (* a i) (/ pi 2)) (* a i r)) l))
- )
- (entmake
- (append
- (list
- '(0 . "SPLINE")
- '(100 . "AcDbEntity")
- '(100 . "AcDbSpline")
- '(70 . 40)
- '(71 . 3)
- (cons 74 (length l))
- '(44 . 1.0e-010)
- )
- (mapcar '(lambda (x) (cons 11 x)) l)
- )
- )
- )
- )
- (princ)
- )
这将绘制曲线的切线
- (defun c:tgl (/ vs unit e p l d)
- (vl-load-com)
- (defun unit (l / d)
- (if (> (setq d (distance '(0 0 0) l)) 0.0)
- (mapcar '(lambda (x) (/ x d)) l)
- )
- )
- (defun vs (v s)
- (mapcar '(lambda (x) (* x s)) v)
- )
-
- (if
- (and
- (setq e (ssget "_:E:S" '((0 . "*POLYLINE,SPLINE,ARC,CIRCLE,ELLIPSE"))))
- (setq e (ssname e 0))
- (not (redraw e 3))
- (setq p (getpoint "\nSelect point on object: "))
- (equal p (setq p (vlax-curve-GetClosestPointTo e p)) 1e-10)
- (not (redraw e 4))
- )
- (progn
- (setq l (* 0.1 (vlax-curve-GetDistAtParam e (vlax-curve-GetEndParam e)))
- d (vs (unit (vlax-curve-GetFirstderiv e (vlax-curve-GetParamAtPoint e p))) l)
- )
- (entmake
- (list
- '(0 . "line")
- (cons 10 (mapcar '- p d))
- (cons 11 (mapcar '+ p d))
- )
- )
- )
- )
- (princ)
- )
您可能需要调整这些功能以满足您的需要。
第一个是绘制一条完整的曲线,因为它穿过整个圆。显然,你不需要这样。
第二条将绘制一条长度等于所选曲线20%的线,但可以进行调整。 |