2
10
8
初来乍到
使用道具 举报
;; BOM to CSV; A program to create a csv file from a text based table in AutoCAD;; Author: Doug Barnes;; Company: Grantek Systems Integration(defun Cleanup_Text ();; find all the text with no content and erase them(setq nil_text(ssget "x"'((-4 . "<and") (0 . "TEXT") (1 . "") (-4 . "and>"))));; search for text with no content(if nil_text(command "erase" nil_text ""));; erase text with no content);; end cleanup_text defun;;==========================================================================================(defun Gather_Text (/ sel2 ct)(setq Text_SS (ssget "_W" (list 16.8 10.3)(list 18.9 5.0) '((0 . "TEXT"))))(setq sel2 (ssget "_W" (list 16.8 16.6)(list 25.8 11.0) '((0 . "TEXT"))))(setq ct 0);set counter to zero(repeat (sslength sel2);get the number of items in selection set 2;and loop that number of times(ssadd (ssname sel2 ct) Text_SS);get the name of the entity from selection set 2;by using the counter index number and add it to;selection set 1(setq ct (1+ ct));increment the counter by 1);end repeat);; create a selection set for all text selected by the user.;; end Gather_Text defun;;==========================================================================================(defun MakeList_X_Y_Text (Text_SS);; Make a list of x-coords, y-coords and text(setq MakeList_cnt 0)(repeat (sslength Text_SS)(setq X_cord(if (= (cdr (assoc 72 (entget (ssname Text_SS MakeList_cnt))))0);; check for the text's justification(cadr (assoc 10 (entget (ssname Text_SS MakeList_cnt))));; if left justified use first alignment point(cadr (assoc 11 (entget (ssname Text_SS MakeList_cnt))));; else use second alignment point);;end if);;end Setq(setq y_cord(if (= (cdr (assoc 72 (entget (ssname Text_SS MakeList_cnt))))0);; check for the text's justification(caddr (assoc 10 (entget (ssname Text_SS MakeList_cnt))));; if left justified use first alignment point(caddr (assoc 11 (entget (ssname Text_SS MakeList_cnt))));; else use second alignment point);;end if)(setq List_X_Y_Text(appendList_X_Y_Text(list(list(cons "X coord"X_cord)(cons "Y coord" y_cord)(cons "Text"(cdr (assoc 1 (entget (ssname Text_SS MakeList_cnt)))))))));;make assocation list of x, y and text dotted pairs(setq MakeList_cnt (1+ MakeList_cnt));; index to next entity);;repeat);;end MakeList_X_Y_Text defun;;==========================================================================================(defun Sort_by_X (List_X_Y_Text);; re-order list from left to right(setq X_List(vl-sortList_X_Y_Text(FUNCTION (LAMBDA (E1 E2) (< (cdar E1) (cdar E2)))))));; end Sort_by_X defun;;==========================================================================================(defun Sort_by_Y (List_X_Y_Text_Col);; re-order list from top to bottom(setq Y_List(vl-sortList_X_Y_Text_Col(FUNCTION (LAMBDA (E1 E2) (> (cdadr E1) (cdadr E2)))))));; end Sort_by_Y defun;;==========================================================================================(defun Get_Columns (X_List);; determine the number of columns text