优化了当拾取点为第一象限点时除数为零的错误
- (defun c:test(/ angf angs ent obj os para pt vecf vecs)
- (setq os (getvar "osmode"))
- (setq ent (car (entsel)))
- (setq obj (vlax-ename->vla-object ent))
- (while (setq pt (getpoint "\n拾取点:"))
- (setq para (vlax-curve-getParamAtPoint obj (setq pt (vlax-curve-getClosestPointTo obj pt))))
- ;;切线
- (setq vecf (vlax-curve-getFirstDeriv obj para))
- (setq angf (angle pt (mapcar '+ pt vecf)))
- ;;法线
- (setq vecs (vlax-curve-getsecondDeriv obj para))
- (setq angs (angle pt (mapcar '+ pt vecs)))
- (setvar "osmode" 0)
- (command "_.line" (polar pt (+ angf pi) 100) (polar pt angf 100) "")
- (command "_.line" (polar pt (+ angs pi) 100) (polar pt angs 100) "")
- (setvar "osmode" os)
- )
- (setvar "osmode" os)
- (princ)
- )
|