jcap91163 Posted August 2, 2010 Posted August 2, 2010 tsel works very fine, thank you for your help Quote
laijumalias Posted August 4, 2010 Posted August 4, 2010 Try this: (defun c:tsel (/ *error* unique BPT CATT CNT DOC ENT I ITM J K LST OBJ OLST SPC SS TBLOBJ TSS UFLAG) ;; by Lee McDonnell (Lee Mac) (vl-load-com) (defun *error* (msg) (and uFlag (vla-EndUndoMark doc)) (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*") (princ (strcat "\n** Error: " msg " **"))) (princ)) (defun unique (lst / result) (reverse (while (setq itm (car lst)) (setq lst (vl-remove itm lst) result (cons itm result))))) (setq doc (vla-get-ActiveDocument (vlax-get-Acad-Object)) spc (if (zerop (vla-get-activespace doc)) (if (= (vla-get-mspace doc) :vlax-true) (vla-get-modelspace doc) (vla-get-paperspace doc)) (vla-get-modelspace doc)) i 2) (cond ( (eq 4 (logand 4 (cdr (assoc 70 (tblsearch "LAYER" (getvar "CLAYER")))))) (princ "\n<< Current Layer Locked >>")) (t (if (and (setq k -1 ss (ssget '((-4 . "<OR") (0 . "TEXT,MTEXT") (-4 . "<AND") (0 . "INSERT") (66 . 1) (-4 . "AND>") (-4 . "OR>")))) (setq bPt (getpoint "\nSelect Point for Table: "))) (progn (setq uFlag (not (vla-StartUndoMark doc))) (while (setq ent (ssname ss (setq k (1+ k)))) (setq obj (vlax-ename->vla-object ent)) (setq lst (append lst (cond ( (eq "AcDbBlockReference" (vla-get-ObjectName Obj)) (mapcar (function vla-get-TextString) (append (vlax-safearray->list (vlax-variant-value (vla-getAttributes Obj))) (if (not (vl-catch-all-error-p (setq cAtt (vl-catch-all-apply 'vlax-safearray->list (list (vlax-variant-value (vla-getConstantAttributes Obj))))))) cAtt)))) (t (list (vla-get-TextString obj))))))) (foreach Str (unique lst) (setq cnt 0) (if (setq j -1 tss (ssget "_X" (list '(-4 . "<OR") '(-4 . "<AND") '(0 . "TEXT,MTEXT") (cons 1 str) '(-4 . "AND>") '(-4 . "<AND") '(0 . "INSERT") '(66 . 1) '(-4 . "AND>") '(-4 . "OR>")))) (while (setq ent (ssname tss (setq j (1+ j)))) (setq Obj (vlax-ename->vla-object ent)) (cond ( (eq "AcDbBlockReference" (vla-get-ObjectName Obj)) (foreach Att (append (vlax-safearray->list (vlax-variant-value (vla-getAttributes Obj))) (if (not (vl-catch-all-error-p (setq cAtt (vl-catch-all-apply 'vlax-safearray->list (list (vlax-variant-value (vla-getConstantAttributes Obj))))))) cAtt)) (if (eq Str (vla-get-TextString Att)) (setq cnt (1+ cnt))))) (t (setq cnt (1+ cnt)))))) (setq oLst (cons (cons str cnt) oLst))) (setq tblObj (vla-addTable spc (vlax-3D-point bPt) (+ 2 (length olst)) 2 (* 1.5 (getvar "DIMTXT")) (* (apply 'max (mapcar 'strlen (append '("String") (apply 'append (mapcar (function (lambda (x) (list (car x) (itoa (cdr x))))) olst))))) 2.0 (getvar "DIMTXT")))) (vla-setText tblObj 0 0 "String Counter") (vla-setText tblObj 1 0 "String") (vla-setText tblObj 1 1 "Count") (foreach x (vl-sort olst (function (lambda (a b) (< (car a) (car b))))) (vla-setText tblObj i 0 (car x)) (vla-setText tblObj i 1 (itoa (cdr x))) (setq i (1+ i))) (setq uflag (vla-EndUndoMark doc)))))) (princ)) Is there a way to count the strings only in the selected objects in other words is it possible to give an option to count in the entire drawing or select the objects from where the count should perform. Quote
laijumalias Posted August 4, 2010 Posted August 4, 2010 Hi Lee, thanks for your response, Can you please provide the modified code. Quote
alanjt Posted August 4, 2010 Posted August 4, 2010 Hi Lee, thanks for your response, Can you please provide the modified code.He just lives to serve. Quote
laijumalias Posted August 5, 2010 Posted August 5, 2010 Hi Lee, Awaiting your support on this code, thanks in advance. Quote
Lee Mac Posted August 6, 2010 Posted August 6, 2010 Hi Lee, Awaiting your support on this code, thanks in advance. I don't have much time, of which, here it is voluntary. Quote
laijumalias Posted September 23, 2010 Posted September 23, 2010 Is there a way to count the strings only in the selected objects in other words is it possible to give an option to count in the entire drawing or select the objects from where the count should perform. Anybody with any help? Quote
rengised Posted September 24, 2010 Posted September 24, 2010 Lee, you are amazing. Thanks for helping us always. :thumbsup: Quote
Lee Mac Posted September 24, 2010 Posted September 24, 2010 Hi guys, Please try my heavily updated code Counts all in a selection. Lee TCount.lsp Quote
Lee Mac Posted October 1, 2010 Posted October 1, 2010 Anybody with any help? Did my code work for you laijumalias? Or was I wasting my time? Quote
Tiger Posted October 4, 2010 Posted October 4, 2010 Thought so. You are too kind Lee, and the kind never get the credits they deserve. You are noted down as Awesomesauce in my book though 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.