;以下是我做的简易粗糙度.可以完成大部粗糙度标注了.
(defun hh-czd (/ sca tornil mode val PT0 bool angl1 angl2 angl3 angl4 p1 P4 P2) (setq sca (getvar "dimscale")) ;放大比例 (vl-load-com) (setq tornil (entsel "\n点取欲放置粗糙度的曲线")) (while (not (or (= mode 3) (= mode 11) (= mode 13) (= mode 32) (= mode 25) ) ) (setq mode (car (setq TMP (grread 2))) val (cadr tmp) ) ;击空格时val=32 (setq PT0 (vlax-curve-getclosestpointto (car tornil) val)) ;pt0为曲线上离鼠标最近点的坐标 (setq angl1 (angle val pt0)) (setq bool (and (>= angl1 pi) (< angl1 (* 2 PI)))) (if bool (progn (setq angl2 (- angl1 3.665191) angl3 (- angl1 2.617993878) ) (setq p1 (polar pt0 angl2 (* 5 sca))) (setq p4 (polar pt0 angl2 (* 10 sca))) (setq p2 (polar pt0 angl3 (* 5 sca))) (redraw) (grdraw pt0 P4 1) (grdraw pt0 P2 1) (grdraw p1 P2 1) ) ;end progn (progn (setq angl2 (+ angl1 3.926991) angl3 (+ angl1 2.617993878) ) (setq p1 (polar pt0 angl2 (* 5 sca))) (setq p4 (polar pt0 angl2 (* 10 sca))) (setq p2 (polar pt0 angl3 (* 5 sca))) (redraw) (grdraw pt0 P4 1) (grdraw pt0 P2 1) (grdraw p1 P2 1) ) ;end progn ) ;end if ) ;end while (redraw) (setq angl4 (- (* (/ angl1 PI) 180) 270)) (setq angl2 (- (* (/ angl1 PI) 180) 90)) (if bool (command "-insert" "ccd1" PT0 sca sca angl4) (command "-insert" "ccd2" PT0 sca sca angl2) ) ) ;end czd
(defun C:czd () (hh-czd) )
|