Code:(if (setq ss (ssget "_x" '((2 . "E")))) (sssetfirst nil ss) )
Registered forum members do not see this ad.
Is there a way to incorporate the bcount command into a lisp to count only blocks named "E" for example. I need to somehow select all the blocks named "E" prior to running the bcount command. Any suggestions? Thanks.
Code:(if (setq ss (ssget "_x" '((2 . "E")))) (sssetfirst nil ss) )
- When aim is being settled in my mind , I have to reach it and get it in hand whatever it costs and wherever it is and will never give up . Tharwat said
Also the built-in commands QSELECT and FILTER will do this for you.
Regards,
Mircea
AutoCAD's happy user equation: FILEDIA + PICKADD² + PICKFIRST = 3




Tharwat I was supprised the code worked with only the one dxf code of 2 theres lots of other objects that use 2 also, would it be better to add the search for blocks only (0 . "insert") as a more general example of using ssget's.
Code:'((0 . "INSERT")(2 . "E"))
A man who never made mistakes never made anything
It is possible, though highly unlikely. Things like AttDefs (2 = TagName), Hatch (2 = Pattern), Shape (2 = Shape Name), Dimensions (2 = Anonymous Block Name - *D-prefix), Table (2 = Anonymous Block Name - *T-prefix), etc. could have similar stuff in the code 2 item. Though to make sure your way would be more complete & unambiguous.
Knowledge is proportional to experience, but wisdom is inversely proportional to ego!
My little bit of "wisdom": Hind-sight is useless, unless used to improve the next forethought!


Registered forum members do not see this ad.
Or maybe : (it works with dynamic block also - quick and dirty with some acet function)
Code:(defun c:bcc (/ table dcl lsblk nm ss tol) ;Ketxu 2012 (vl-load-com) (defun table (s / d r) (while (setq d (tblnext s (null d))) (setq r (cons (cdr (assoc 2 d)) r)) ) ) (defun DCL(Title @ ThongTin lstVal / fl ret) (setq fl (vl-filename-mktemp "mip" nil ".dcl")) (setq ret (open fl "w")) (mapcar '(lambda (x) (write-line x ret)) (list "mip_msg : dialog { " (strcat "label=\"" title "\"; width = 40;fixed_width = true;") ; ":popup_list {label = \"Block : \";key=\"kLst\";}" ": column {" ": row {" " fixed_width = true;" " alignment = centered;" ":button {label = \"\OK\"; is_cancel = true;fixed_width = true;width = 1;}" " : spacer { width = 2; }" ":button {label = \"About\";fixed_width = true;width = 1;key = \"kThongTin\";}" "}" "}" " :text_part {alignment=centered;" (strcat "label=\"" @ "\";") "}}" ) ) ;_ end of mapcar (setq ret (close ret)) (if (and (not (minusp (setq dcl_id (load_dialog fl)))) (new_dialog "mip_msg" dcl_id) ) ;_ end of and (progn (start_list "kLst" 3) (mapcar '(lambda(x)(add_list x)) lstVal) (end_list) (action_tile "kLst" "(setq ret (nth (atoi $value) lstVal))") (start_dialog) ) ;_ end of progn ) ;_ end of if (unload_dialog dcl_id) (vl-file-delete fl) ret ) (setq lstBlk (vl-remove-if '(lambda(x)(wcmatch x "`**"))(acad_strlsort (table "Block")))) (cond ((setq nm (DCL "Select block :" "@Ketxu" "Count choiced block @Ketxu" lstBlk)) (setq ss (ssget (list (cons 0 "INSERT")(cons 2 (strcat nm ",`**")))) tol (length (setq tmp (vl-remove-if-not '(lambda(x)(= (vla-get-EffectiveName (vlax-ename->vla-object x)) nm)) (acet-ss-to-list ss)))) ) )) (cond ((> tol 0) (sssetfirst nil (acet-list-to-ss tmp)) (princ (strcat "Number of block " nm " in selection area : " (itoa tol) )) )(T (princ "Nothing")) ) (princ) )
Bookmarks