Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/12/2024 in all areas

  1. This creates a selectionset ss for you to use like : (sslength ss) or on command line : erase (eval ss) etc (defun c:test ( / r)(if (vl-consp (setq r (get)))(progn (setq ss (ssadd))(foreach e r (ssadd e ss))))) (defun get ( / s l) (if (setq s (ssget)) (foreach e (mapcar 'cadr (ssnamex s))(if (ggn e)(progn (redraw e 3)(setq l (cons e l)))))) l) (defun ggn (o / m g) (setq g (vla-get-groups (vla-get-activedocument (vlax-get-acad-object)))) (if (= (type o) 'ENAME) (setq o (vlax-ename->vla-object o))) (vlax-for x g (vlax-for y x (if (equal o y)(setq m (cons (vlax-get x 'Name) m))))) m)
    1 point
  2. Try something like this - change the value of the two variables at the top of the code to suit: (defun c:test ( / bln idx lst nla pat ) (setq pat "*block*" nla "NewLayer" pat (strcase pat) ) (if (setq sel (ssget '((0 . "INSERT")))) (repeat (setq idx (sslength sel)) (setq idx (1- idx) bln (cdr (assoc 2 (entget (ssname sel idx)))) ) (if (not (member bln lst)) (progn (setq lst (cons bln lst)) (processblock bln pat nla) ) ) ) ) (princ) ) (defun processblock ( bln str lay / ent ) (if (setq ent (tblobjname "block" bln)) (while (setq ent (entnext ent)) (processobject ent str lay) ) ) ) (defun processobject ( ent str lay / bln enx ) (cond ( (not (setq enx (entget ent)))) ( (/= "INSERT" (cdr (assoc 0 enx)))) ( (not (wcmatch (setq bln (strcase (cdr (assoc 2 enx)))) str)) (processblock bln str lay) ) ( (entmod (subst (cons 8 lay) (assoc 8 enx) enx)) (processblock bln str lay) ) ) ) (princ)
    1 point
×
×
  • Create New...