- ;;图中的基线是已知的(但请先连接起来)
- ;;现在知道每间隔一定距离后基线和產生线的距离,怎样自动生成这条產生线
- ;;BY 龙龙仔(LUCAS)
- (defun C:PER_CUR (/ ANG ANG1 D1 E1 E2
- EE1 EE1PT EE2 EE2PT HOLDECHO HOLDEDGE
- HOLDOSMODE HOLDPROJ N PT
- )
- (vl-load-com) ;; Tony Tanzillo.
- ;; (vector-side (origin) (direction) (point))
- ;; Returns an integer code indicating position of (point)
- ;; in relation to the directed vector whose endpoints are
- ;; <origin> and <direction>.
- ;; Result Meaning
- ;; -1 Point is to the right of vector.
- ;; 0 Point is on (colinear with) vector
- ;; 1 Point is to the left of vector.
- ;; usage : (vector-side (getpoint) (getpoint) (getpoint)) (defun VECTOR-SIDE (V1 V2 P / R)
- (setq R (- (* (- (car V2) (car V1)) (- (cadr P) (cadr V1)))
- (* (- (cadr V2) (cadr V1)) (- (car P) (car V1)))
- )
- )
- (cond ((equal R 0.0 1e-8) 0)
- (t (fix (/ (abs R) R)))
- )
- ) (setq HOLDECHO (getvar "CMDECHO"))
- (setvar "CMDECHO" 0)
- (command "_.UNDO" "GROUP")
- (setq HOLDOSMODE (getvar "OSMODE"))
- (setvar "OSMODE" 0)
- (setq HOLDEDGE (getvar "EDGEMODE"))
- (setvar "edgemode" 0)
- (setq HOLDPROJ (getvar "PROJMODE"))
- (setvar "projmode" 0)
- (setq E1 (vlax-ename->vla-object
- (car (setq EE1 (entsel "\n选基线:")))
- )
- E2 (vlax-ename->vla-object
- (car (setq EE2 (entsel "\n选產生线:")))
- )
- EE1PT (vlax-curve-getstartpoint E1)
- EE2PT (osnap (cadr EE2) "NEA")
- ;|
- N (getint "\n等分数: ")
- D1 (/ (vlax-curve-getdistatparam E1 (vlax-curve-getendparam E1))
- N
- )|;
- D1 (getdist EE1PT "\n等距偏移: ")
- N (fix
- (/ (vlax-curve-getdistatparam E1 (vlax-curve-getendparam E1))
- D1
- )
- )
- )
- (setq ANG (angle '(0 0 0)
- (vlax-curve-getfirstderiv
- E1
- (vlax-curve-getparamatpoint E1 EE1PT)
- )
- )
- )
- (if (= (VECTOR-SIDE EE1PT (polar EE1PT ANG 0.1) EE2PT) 1)
- (setq ANG1 (* 0.5 pi))
- (setq ANG1 (* 1.5 pi))
- )
- (while (not (minusp N))
- (setq ANG (angle '(0 0 0)
- (vlax-curve-getfirstderiv
- E1
- (vlax-curve-getparamatdist E1 (* D1 N))
- )
- )
- )
- (command "_.LINE"
- (setq PT (vlax-curve-getpointatdist E1 (* D1 N)))
- (setq PT (polar PT (+ ANG ANG1) 0.1))
- ""
- )
- (command "_.EXTEND" EE2 "" (list (entlast) PT) "")
- (setq N (- N 1))
- )
- (setvar "projmode" HOLDPROJ)
- (setvar "edgemode" HOLDEDGE)
- (setvar "OSMODE" HOLDOSMODE)
- (command "_.UNDO" "END")
- (setvar "CMDECHO" HOLDECHO)
- (princ)
- )
|