;----------------------------------------------------------------------------- ; AutoLISP - Mircea Baduts, Begining Date: 06.06.1996 Last UpDate: 24.07.2002 ; This routine/command return the selected polyline vertexes coordinates ;----------------------------------------------------------------------------- (defun C:EXTRACT() (initget 128) (setq _i (if _i (setq _i (getint "\nFirst point/vertex has the index:")) 0)) (setq _p (entget (setq _v (car (entsel "\nSelect the polyline"))))) (setq _l nil) (if (= (cdr (assoc 0 _p)) "POLYLINE") ;; the PLINETYPE variable set on 0 or 1 establish the polyline kind to POLYLINE (progn (setq _s (substr (strcat "Polyline: " (getstring "\nPolyline identifier : ") " ") 1 19)) (setq _n 0) (while (= (cdadr (setq _p (entget (setq _v (entnext _v))))) "VERTEX") (setq _n (1+ _n)) (setq _e nil) (setq _e (cons (+ _n _i -1) _e)) (setq _e (cons (cadr (assoc 10 _p)) _e)) (setq _e (cons (caddr (assoc 10 _p)) _e)) (setq _e (cons (cadddr (assoc 10 _p)) _e)) (setq _e (reverse _e)) (setq _l (cons _e _l)) ) (setq _l (reverse _l)) (salveaza) (print "OK! The entity POLYLINE processed!") (initget 1 "d n") (if (= "y" (getkword "\n\tDo you want the vertices marking? [y/n] ")) (desenare)) (princ)) (progn (if (= (cdadr _p) "LWPOLYLINE") ;; the PLINETYPE varaible set on 2 establish the polyline kind to LWPOLYLINE ;; Lightweight Polyline (appeared in R14) is planar (but support Z elevation) (progn (setq _s (substr (strcat "Polyline: " (getstring "\nPolyline identifier : ") " ") 1 19)) (setq _n (cdr (assoc 90 _p))) ;; _n represent the polyline vertics number [echiv. (cdr (nth 9 _p)) ] (setq _c 0) (repeat _n (setq _v (cdr (nth (+ 14 (* 4 _c)) _p))) (setq _e nil) (setq _e (cons (+ _c _i) _e)) (setq _e (cons (car _v) _e)) (setq _e (cons (cadr _v) _e)) (setq _e (cons (cdr (assoc 38 _p)) _e)) (setq _e (reverse _e)) (setq _l (cons _e _l)) (setq _c (1+ _c)) ) (setq _l (reverse _l)) (salveaza) (print "OK! The entity LWPOLYLINE processed") (initget 1 "d n") (if (= "y" (getkword "\n\tDo you want the vertices marking? [y/n] ")) (desenare)) (princ)) (progn (alert "The selected entity is not a polyline!") (princ))) ) ) ) ;--------------------------------------------------------------------- (defun SALVEAZA() (setq _f (open "coords.dat" "a")) ;(setq _f (getfiled "Give the name for the destination file" "coords.dat" "" 4) (setq _c 0) (repeat (length _l) (print (strcat _s " -vertex: " (substr (strcat (itoa (car (nth _c _l))) " ") 1 6) (substr (strcat (rtos (cadr (nth _c _l)) 2 2) " ") 1 12) (substr (strcat (rtos (caddr (nth _c _l)) 2 2) " ") 1 12) (substr (strcat (rtos (cadddr (nth _c _l)) 2 2) " ") 1 12) ) _f) (setq _c (1+ _c)) ) (close _f) ) ;--------------------------------------------------------------------- (defun DESENARE() (prompt "\nNow putting the marks/names of the polyline vertexes on drawing") (setq _s (getint "\nWanted scale for plotted drawing: 1/")) (setq _h (/ _s 500.0)) (setvar "PDSIZE" (/ _s 2500.0)) (setvar "PDMODE" 34) (command "layer" "m" "puncte" "") (setq _c 0) (repeat (length _l) (command "point" (list (cadr (nth _c _l)) (caddr (nth _c _l)) (cadddr (nth _c _l)))) (command "text" (list (cadr (nth _c _l)) (caddr (nth _c _l)) (cadddr (nth _c _l))) _h "0" (itoa (car (nth _c _l)))) (setq _c (1+ _c)) ) ) ;--------------------------------------------------------------------- ; The subsequently regeneration of the polyline from this extracted data ; is correct just for those polylines composed only from lines! ;--------------------------------------------------------------------- ; For 3D polyline can exist vetexes with repeated oocurences ; (a vertex can participate at more than one face of 3D object). ;--------------------------------------------------------------------- (prompt "\n\tThe extraction start with the EXTRACT command \t") ;---------------------------------------------------------------------