Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 05/02/2020 in all areas

  1. Here you have it... Select rectangles, and it should be fine. Just make sure that all the rectangles and texts are visible on the screen prior to pressing Enter. (defun c:rectcsv ( / *error* acadobj activeundo adoc coords csv del dis getcoords i len lst->str opf pth ss txt txtcont wid) (defun *error* ( msg ) (if opf (close opf)) (vla-EndUndoMark adoc) (if (not (wcmatch (strcase msg T) "*break*,*cancel*,*exit*")) (princ (strcat "Error: " msg)) ) ) (defun getcoords (ln) (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget ln)))) (defun lst->str (lst del) (apply 'strcat (append (list (car lst)) (mapcar '(lambda (x) (strcat del x)) (cdr lst))))) (setq acadobj (vlax-get-acad-object) adoc (vla-get-ActiveDocument acadobj) activeundo nil) (if (= 0 (logand 8 (getvar "UNDOCTL"))) (vla-StartUndoMark adoc) (setq activeundo T)) (if (and (setq ss (ssget '((0 . "LWPOLYLINE") (70 . 1) (90 . 4)))) (setq pth (getfiled "Select CSV Output file" "" "csv" 1)) ) (progn (setq del (cond ((vl-registry-read "HKEY_CURRENT_USER\\Control Panel\\International" "sList")) (","))) (repeat (setq i (sslength ss)) (setq coords (getcoords (ssname ss (setq i (1- i)))) dis (mapcar 'distance coords (cdr coords)) wid (apply 'min dis) len (apply 'max dis) txt (ssget "CP" coords '((0 . "TEXT"))) txtcont (if txt (strcat "\"" (lst->str (mapcar '(lambda (x) (cdr (assoc 1 (entget x)))) (JH:selset-to-list txt)) ",") "\"") "") csv (cons (strcat (lst->str (mapcar 'rtos (list len wid)) del) del txtcont) csv) ) ) (if (setq opf (open pth "w")) (progn (foreach x (cons "L,W,ID" (reverse csv)) (write-line x opf)) (close opf) ; (startapp "explorer" pth) ; <-- To directly open the CSV file, uncomment this line ) (alert "\nCSV file not successfully created! Please check that the file is closed and try again!") ) ) ) (if activeundo nil (vla-EndUndoMark adoc)) (princ) ) ;; JH:selset-to-list --> Jonathan Handojo ;; Returns a list of entities from a selection set ;; ss - selection set (defun JH:selset-to-list (selset / lst iter) (if selset (repeat (setq iter (sslength selset)) (setq lst (cons (ssname selset (setq iter (1- iter))) lst)) ) ) )
    1 point
×
×
  • Create New...