@Gaganpatel wrote:
Dear Sir,
I agree difficult but please solve my post.
Give this a try. Not that difficult 🙂
(defun c:foo (/ _foo a i p r s)
;; RJP » 2023-05-01
(defun _foo (str) (substr str 1 (vl-string-search "-" str)))
(cond
((setq s (ssget "_X" '((0 . "TEXT") (1 . "*-*"))))
(setq s (mapcar 'cadr (ssnamex s)))
(setq s (vl-sort (mapcar 'vla-get-textstring (mapcar 'vlax-ename->vla-object s)) '>))
(while (setq a (car s))
(setq p (substr a (setq i (+ 2 (vl-string-search "-" a)))))
(setq a (vl-remove-if-not '(lambda (x) (wcmatch x (strcat "*" p))) s))
(setq r (cons (apply '+ (mapcar 'atoi (mapcar '_foo a))) r))
;; Print results to command line
(princ (strcat "\n" p " - " (vl-princ-to-string (apply '+ (mapcar 'atoi (mapcar '_foo a))))))
(foreach x a (setq s (vl-remove x s)))
)
(princ (strcat "\n" (vl-princ-to-string (apply '+ r))))
(textscr)
)
)
(princ)
)
Result to command line:
Command: FOO
M16x55-16
M16x40-27
M16x45-8
PW16x8-1
PW16x6-1
PW16x5-1
PW16x4-1
PW16x10-1
You do have one callout that will not be tallied because it does not separate the number with a "-".
