berto Posted February 2, 2015 Posted February 2, 2015 Hi everybody! I know this issue has been raised here more than once. However, so far I haven't been able to find what I need. I work as a translator and lately have been dealing mainly with autocad drawings. Getting correct word count is rather challenging, I've to say. I've tried several lisps posted on this forum but they all have a serious shortcoming rendering them practically useless, i.d. along with the stuff I need they extract a great deal of undesirable trash (by trash I mean things like "\pxql" etc. which seem to pop up pretty often and inflate my stats way beyond plausibility).The lisp posted here http://www.jefferypsanders.com/autolisp_WORDS.html seems to have some kind of filter for this and with its help, I guess, it's possible to extract relatively "lean" texts from the drawings. However, its drawback is that a word is extracted only once, even if it's repeated a hundred times in the drawing. That too is bad since I need to include the repetitions in my stats as well. Could you guys please suggest a solution? Quote
ReMark Posted February 2, 2015 Posted February 2, 2015 Can you use QSELECT? Do you includes attributes in your count? Have you seen this thread? http://www.cadtutor.net/forum/showthread.php?79-Exporting-Text Another option would be to purchase DotSoft's ToolPac. Under Annotation Tools is a feature called Count. Description: Counts occurrences of text strings or words in a selection set of annotation objects. Quote
berto Posted February 2, 2015 Author Posted February 2, 2015 Remark, 1) frankly, no idea how to use the thing; 2) nope,attributes need to be left out; 3) I've and like I said those lisps extract a lot of stuff I don't really need. Here's an example: \pxql;SCMI_CLOUD \pxql;SCMI_COLUMNA \pxql;SCMI_DETALLE \pxqc;A1 \pxqc;A2 \pxqc;A3 \pxqc;A4 An ideal solution would be a somewhat modified version of the lisp found on jefferypsanders.com, one that could filter out all the trash and include the repetitions too. I don't know is such a thing exists though. Quote
ReMark Posted February 2, 2015 Posted February 2, 2015 QSELECT > Text > Layer. Did you or did you not look at the thread I posted the link to? Quote
BrianTFC Posted February 2, 2015 Posted February 2, 2015 Here is a Lisp Routine you can try... ; TXTCNT.lsp - Count how many times each text entity appears. ; Display the results sorted in a dialog box. ; BY jeffery p sanders (defun C:TXTCNT () ;define a sort routine - Usage: (srt list) - Let's not go into this yet! It works. (defun srt (alist / n) (setq lcup nil rcup nil ) (defun cts (a b) (cond ((> a b) t) ((= a b) t) (t nil) ) ) (foreach n alist (while (and rcup (cts n (car rcup))) (setq lcup (cons (car rcup) lcup) rcup (cdr rcup) ) ) (while (and lcup (cts (car lcup) n)) (setq rcup (cons (car lcup) rcup) lcup (cdr lcup) ) ) (setq rcup (cons n rcup)) ) (append (reverse lcup) rcup) ) ;turn the command echo off (setvar "cmdecho" 0) ;setup a variable to hold the data (setq datalist (list)) ;select objects (if (setq eset (ssget)) (progn ;set a counter to the first item in the selection set (setq cntr 0) ;loop through each selected entity (while (< cntr (sslength eset)) ;grab the entity's name (setq en (ssname eset cntr)) ;grab the DXF group codes of the entity (setq enlist (entget en)) ;ignore the entity if it is not a TEXT entity (if (= "TEXT" (cdr (assoc 0 enlist))) (progn ;get the text value from the DXF Group Code (setq str (cdr (assoc 1 enlist))) ;setup a variable to check if the entity exist in the datalist list (setq existing 0) ;loop through the datalist to find out if it is a new entity that needs ;to be added to the list or if it already exist and it's counter needs ;to be incremented (foreach a datalist (if (= (car a) str) (setq existing 1) ) ) ;if the entity is new then (if (= existing 0) ;do this - Add the item to the datalist along with a counter that starts at 1 (setq datalist (append datalist (list (cons str 1)))) ;else it's cntr needs to be incremented (setq datalist (subst (cons str (+ 1 (cdr (assoc str datalist)))) (assoc str datalist) datalist ) ) ) ) ) ;increment the entity counter (setq cntr (+ cntr 1)) ) ) ) ;setup a variable to hold the data again, this time in a different fashion (setq newList (list)) ;rearrange the list (foreach a datalist (setq newList (append newList (list (strcat (substr (strcat (car a) " . . . . . . . . . . . . . . . . . . . . . . . . . . " ) 1 50 ) " - " (itoa (cdr a)) ) ) ) ) ) ;sort the list (setq newList (srt newList)) ;put up the dialog box (setq dcl_id (load_dialog "TXTCNT.dcl")) ;see if it is already loaded (if (not (new_dialog "TXTCNT" dcl_id)) (exit) ) ;add the data to the list in the dialog box (start_list "datalist") (mapcar 'add_list newList) (end_list) ;if an action event occurs, do this function (action_tile "cancel" "(setq ddiag 1)(done_dialog)") (action_tile "insert" "(setq ddiag 2)(done_dialog)") ;display the dialog box (start_dialog) ;if the cancel button was pressed - display message (if (= ddiag 1) (princ "\n \n ...TXTCNT Cancelled. \n ") ) (if(= ddiag 2) (progn (setq pt(getpoint "\n Insertion Point: ")) (foreach a newList (command "-style" "ARIAL" "ARIAL" "" "" "" "" "") (command "text" pt "" "" a) (setq pt(polar pt (* pi 1.5) (* (getvar "textsize") 1.25))) ) ) ) ;unload the dialog box (unload_dialog dcl_id) ;turn the command echo back on (setvar "cmdecho" 1) ;supress the last echo (princ) ) TXTCNT.DCL Quote
Lee Mac Posted February 2, 2015 Posted February 2, 2015 they extract a great deal of undesirable trash (by trash I mean things like "\pxql" etc. which seem to pop up pretty often and inflate my stats way beyond plausibility). FWIW, the 'trash' that you speak of is MText formatting codes present in the text content which arise when formatting overrides are applied through the MText Editor. Quote
BIGAL Posted February 3, 2015 Posted February 3, 2015 A slightly different approach select all text including mtext then explode this will strip the Mtext controls do your word count but not save or a couple of undo's. Quote
BrianTFC Posted February 3, 2015 Posted February 3, 2015 the only bad thing about doing it that is that you will have to weed out all of the numbers if not needed. Quote
Tharwat Posted February 3, 2015 Posted February 3, 2015 BrainTFC This function could be shortened as shown below . (defun cts (a b) (cond ((> a b) t) ((= a b) t) (t nil) ) ) (defun cts (a b) (or (> a b) (= a b) ) ) Quote
Lee Mac Posted February 3, 2015 Posted February 3, 2015 BrainTFC This function could be shortened as shown below . (defun cts (a b) (cond ((> a b) t) ((= a b) t) (t nil) ) ) (defun cts (a b) (or (> a b) (= a b) ) ) Or just (defun cts ( a b ) (>= a b)) Quote
Tharwat Posted February 3, 2015 Posted February 3, 2015 Or just (defun cts ( a b ) (>= a b)) Haha .. that is much more shorter . Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.