Hi Every one,
Please share multi types of text sum auto lisp file.
Please see the example drawing.
Regards
Kalandi Paital
Solved! Go to Solution.
Solved by DannyNL. Go to Solution.
Something like this?
Make sure to not select the table as well, as the routine will select all text objects containing '-'.
(defun c:Test (/ T_Selection T_Count T_Text T_Separator T_Type T_TotalItem T_TotalList) (if (setq T_Selection (ssget '((0 . "TEXT")(1 . "*-*")))) (progn (foreach T_Entity (vl-remove-if '(lambda (T_Item)(listp (cadr T_Item))) (ssnamex T_Selection)) (setq T_Count (substr (setq T_Text (cdr (assoc 1 (entget (cadr T_Entity))))) 1 (setq T_Separator (vl-string-search "-" T_Text)))) (setq T_Type (substr T_Text (+ T_Separator 2))) (if (setq T_TotalItem (assoc T_Type T_TotalList)) (setq T_TotalList (subst (cons T_Type (+ (cdr T_TotalItem) (atoi T_Count))) T_TotalItem T_TotalList)) (setq T_TotalList (cons (cons T_Type (atoi T_Count)) T_TotalList)) ) ) (foreach T_Item (vl-sort T_TotalList '(lambda (T_Item1 T_Item2)(< (car T_Item1) (car T_Item2)))) (princ (strcat "\n" (car T_Item) ": " (itoa (cdr T_Item)))) ) ) ) (princ) )
Dear Sir,
This lisp file not working,
Please see the example file.
@Gaganpatel wrote:
Please replay Sir
Apart from the obvious that your expected results are doubled, How is it wrong? oops I mean How is it NOT working?
Dear Sir,
When i select object and want to result, it is not showing.
So please multi types of text how to separate sum total qty.
Please see the Example drawing.
After you select the objects the results are printed in the commandline/textscreen and not a table to be inserted in your drawing. That would require additional coding.
However, the results you are looking for do not match the text that is counted in your example drawing.
- If you count and add the numbers before 'A', the result will be 3, but you show 6
- For 'B' it's 12 but you show 24
- For 'C' it's 8, but you show 16
Considering the above you would say all numbers need to be multiplied by 2 to get the result you are looking for, but......
- For 'F' the result is 13, but you show 46
Where do those numbers come from? What are you counting exactly?
Your example drawing doesn't clarify enough what the relation between the texts (like '3-C') and the results you want are.
'2-B' and '1-B' in your drawing makes a total of 3x 'B', so where does the 6 come from?
Dear Sir,
I want to count and make the sum of it by the help of lisp file. For example in drawing we have
3nos of B
12nos of C
8nos of D
6nos of B
45nos of D
10nos of C
Final result will be
B=9
C=22
D=53
Well, it already did exactly what you asked but as mentioned in my previous post it shows the result in the textscreen and didn't create a text in your drawing. See below.
This modified code will ask you to specify a point and will create separate texts.
(defun c:Test (/ T_Selection T_Count T_Text T_Separator T_Type T_TotalItem T_TotalList T_TextPoint T_VarList T_OldVars) (if (setq T_Selection (ssget '((0 . "TEXT")(1 . "*-*")))) (progn (foreach T_Entity (vl-remove-if '(lambda (T_Item)(listp (cadr T_Item))) (ssnamex T_Selection)) (setq T_Count (substr (setq T_Text (cdr (assoc 1 (entget (cadr T_Entity))))) 1 (setq T_Separator (vl-string-search "-" T_Text)))) (setq T_Type (substr T_Text (+ T_Separator 2))) (if (setq T_TotalItem (assoc T_Type T_TotalList)) (setq T_TotalList (subst (cons T_Type (+ (cdr T_TotalItem) (atoi T_Count))) T_TotalItem T_TotalList)) (setq T_TotalList (cons (cons T_Type (atoi T_Count)) T_TotalList)) ) ) (if (and T_TotalList (setq T_TextPoint (getpoint "\nText location: ")) ) (progn (setq T_VarList '("CMDECHO" "OSMODE" "OSNAPCOORD")) (setq T_OldVars (mapcar 'getvar T_VarList)) (mapcar 'setvar T_VarList '(0 0 1)) (setq T_TotalList (vl-sort T_TotalList '(lambda (T_Item1 T_Item2)(< (car T_Item1) (car T_Item2))))) (command "_TEXT" T_TextPoint "" "" (strcat (car (car T_TotalList)) " - " (itoa (cdr (car T_TotalList))))) (foreach T_Item (cdr T_TotalList) (command "_TEXT" "" (strcat (car T_Item) " - " (itoa (cdr T_Item)))) ) (mapcar 'setvar T_VarList T_OldVars) ) ) ) ) (princ) )
Can't find what you're looking for? Ask the community or share your knowledge.