;; dxfval.lsp ;; ;; A simple lisp, which prints the dxf properties of elements to the console ;; ;; Created by Peter Gyetvai ;; gyetpet@gmail.com ;; gyetvai-peter.hu (defun C:dxfval (/ i imax il j jmax jl x ss currElem code groupCode sube listauto savefile f savepath en2 enlist2 ) ;variables: (setq i 0);counter to zero (setq imax 1);while variable (setq j 0);counter to zero (setq jmax 1);while variable ;; (vl-load-com) (graphscr) (initget 1 "Pick All") (setq x (getkword "Pick elements or all? [Pick/All]")) (if (= x "Pick") (progn (prompt "\nSelect elements: [All]") (setq ss (ssget));asks for selection ) (setq ss (ssget "_X")) ) (setq il (sslength ss));length of selection (prompt "\nDxf group code: (leave empty for all) ") (setq groupCode (getint)) (initget 1 "Yes No") (setq sube (getkword "List sub entities? [Yes/No]")) ; ------------------------------ output settings ----------------------------- ; (if (< 1 il) (progn (initget 1 "Yes No") (setq listauto (getkword "List all automatically? [Yes/No]")) ) (setq listauto "No") ) (initget 1 "Yes No") (setq savefile (getkword "Save to file? [Yes/No]")) (if (= savefile "Yes") (progn (setq savepath (getfiled "Output path" "" "" 1)) (setq f (open savepath "w")) ) ) ; -------------------------- going through elements -------------------------- ; (while imax ; -------------------- long output only for non auto list -------------------- ; (if (= listauto "No") (progn (print ) (print ) (princ "Checking element ") (princ (1+ i)) (princ "/") (princ il) (print ) ) (progn (print ) (princ (strcat (itoa (1+ i)) ":")) ) ) (setq currElem (entget (ssname ss i) )) (if groupCode ; --------------------- print only groupcode if added --------------------- ; (progn (princ (cdr (assoc groupCode currElem))) (if (= savefile "Yes") (prin1 (cdr (assoc groupCode currElem)) f)) ) ; --------------------- print all if groupcode not added --------------------- ; (progn (setq jl (length currElem)) (while jmax (print (nth j currElem)) (setq j (1+ j));increments i (if (= j jl) (setq jmax nil));finish function if i equals il ) (setq j 0);counter to zero (setq jmax 1);while variable (setq en2(entnext (ssname ss i))) ;- Get the next sub-entity ; ------------------------------- sub entities ------------------------------- ; (if (and en2 (= sube "Yes")) (progn (print ) (princ "Sub entities: ") (setq enlist2(entget en2)) ;- Get the DXF group codes (while (/= (cdr(assoc 0 enlist2)) "SEQEND") ;- Start the while loop and keep ;- looping until SEQEND is found. (princ "\n ") ;-Print a new line (princ enlist2) ;- Print the attribute DXF group codes (setq en2(entnext en2)) (setq enlist2(entget en2)) (print "enlist2 ok") ) ) (progn (if (= sube "Yes") (progn (print ) (princ "No sub entities") ) ) ) );- sub entities end ) ) (if (and (not (or (= il 1)(= (1+ i) il))) (= listauto "No")) (progn (prompt "\nPress any key to continue to the next element: ") (setq code (grread)) ) ) ;while specific: (setq i (1+ i));increments i (if (= i il) (setq imax nil));finish function if i equals il ) (if (= savefile "Yes") (close f)) (setq ss nil) (princ) )