;; | ---------------------------------------------------------------------------- ;; | GE_LocateVx ;; | ---------------------------------------------------------------------------- ;; | Function : Locate a vertex along a polyline segment list of points ;; | Arguments: ;; | 'SnapPt' - The point to be located, it may be located ;; | exactly on the vertex or anywhere along the polyline ;; | segment list ;; | 'vlist' - Polyline vertex list ;; | Action : Locate a given vertex along a polyline ;; | Returns : The vertex number counted from start as 1 ;; | Updated : February 9, 1999 ;; | e-mail : rakesh.rao@4d-technologies.com ;; | Web : www.4d-technologies.com ;; | ---------------------------------------------------------------------------- (defun GE_LocateVx ( SnapPt vlist / nverts Pt1 Pt2 More Vx tmpPt X _X _Y OS ) (setq OS (getvar "OSMODE")) (setvar "OSMODE" 0) (setq nverts (length vlist) Vx 0 More T ) ;; Check if point is on the polyline (if (setq Vx (member SnapPt vlist)) (setq Vx (1+ (- (length vlist) (length Vx))) More nil )) (if More (progn (setq Vx 1) (while (and (< Vx nverts) More) (setq Pt1 (nth (1- Vx) vlist) Pt2 (nth Vx vlist) Pt1 (list (car Pt1) (cadr Pt1) 0.0) Pt2 (list (car Pt2) (cadr Pt2) 0.0) X (distance Pt1 Pt2) Vx (1+ Vx) ) (if (> X 0.001) (progn (command "._Ucs" "_3Point" Pt1 Pt2 (polar Pt1 (- (angle Pt1 Pt2) #pb2) 1.0)) (setq tmpPt (trans SnapPt 0 1)) (command "._Ucs" "_World") (setq _X (car tmpPt) _Y (cadr tmpPt) ) (if (and (equal (abs _Y) 0.0 0.001) (< (abs _X) X)) ; Modified to solve a bug (setq More nil) ) )) ) (setq Vx (1- Vx)) )) (setvar "OSMODE" OS) (if (not More) Vx nil) )