Author Topic: Attribute delete  (Read 3426 times)

0 Members and 1 Guest are viewing this topic.

Shade

  • Guest
Attribute delete
« on: November 26, 2009, 09:43:27 AM »
Does anyone have a lisp that will remove all the attributes from selected blocks.

Our Furniture consultant uses another application that automatically tags all her furniture blocks.
We would like to remove the attribute removed from the blocks, for they show on plotting and are rather large and cluttered the drawings.
Also the attribute I believe is hidden.

Thanks
Shade

Lee Mac

  • Seagull
  • Posts: 12922
  • London, England
Re: Attribute delete
« Reply #1 on: November 26, 2009, 10:22:01 AM »
Hmm... this deletes the attribute in the definition... but not in existing..

Code: [Select]
(defun LM::RemoveAtt (obj / sub)
  (vlax-for sub (vla-item
                  (vla-get-Blocks
                    (vla-get-ActiveDocument
                      (vlax-get-acad-object))) (vla-get-Name obj))
    (and (eq "AcDbAttributeDefinition" (vla-get-Objectname sub))
         (vla-delete sub))))

(defun c:test (/ ent)
  (vl-load-com)
 
  (and (setq ent (car (entsel "\nSelect Block: ")))
       (eq "INSERT" (cdr (assoc 0 (entget ent))))
       (LM::RemoveAtt (vlax-ename->vla-object ent)))

  (princ))


David Bethel

  • Swamp Rat
  • Posts: 656
Re: Attribute delete
« Reply #2 on: November 26, 2009, 12:07:17 PM »
Kind of a dangerous thing to do but, here's another approach:

Code: [Select]
(defun c:delinsat (/ ss i en ed)
  (and (setq ss (ssget (list (cons 0 "INSERT")
                             (cons 66 1))))
       (setq i (sslength ss))
       (while (not (minusp (setq i (1- i))))
              (setq en (ssname ss i)
                    ed (entget en))
              (entmake (subst '(66 . 0) '(66 . 1) ed))
              (entdel en)))
  (command "_.REGENALL")
  (prin1))

-David
R12 Dos - A2K

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Attribute delete
« Reply #3 on: November 26, 2009, 12:12:02 PM »
Wrote these earlier, but had to help the wife.

Code: [Select]
(defun c:Test (/ e)
  (and (setq e (car (entsel "\nSelect block: ")))
       (setq e (vlax-ename->vla-object e))
       (eq "AcDbBlockReference" (vla-get-objectname e))
       (eq (vla-get-hasattributes e) :vlax-true)
       (mapcar 'vla-delete
               (vlax-safearray->list
                 (vlax-variant-value
                   (vla-getattributes e)
                 ) ;_ vlax-variant-value
               ) ;_ vlax-safearray->list
       ) ;_ mapcar
  ) ;_ and
  (princ)
) ;_ defun



(defun c:Test (/ ss)
  (and (setq ss (ssget "_:L" '((0 . "INSERT") (66 . 1))))
       (foreach x (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
         (mapcar 'vla-delete
                 (vlax-safearray->list
                   (vlax-variant-value
                     (vla-getattributes
                       (vlax-ename->vla-object x)
                     ) ;_ vla-getattributes
                   ) ;_ vlax-variant-value
                 ) ;_ vlax-safearray->list
         ) ;_ mapcar
       ) ;_ foreach
  ) ;_ and
) ;_ defun
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

Lee Mac

  • Seagull
  • Posts: 12922
  • London, England
Re: Attribute delete
« Reply #4 on: November 26, 2009, 12:15:29 PM »
Oh, of course Alan - not sure why I didn't think of that  :|  :oops:

Lee Mac

  • Seagull
  • Posts: 12922
  • London, England
Re: Attribute delete
« Reply #5 on: November 26, 2009, 12:19:04 PM »
Just a modification of yours Alan, but thought I'd make it shorter  :evil:

Code: [Select]
(defun c:test (/ ss)
  (and (setq ss (ssget "_:L" '((0 . "INSERT") (66 . 1))))
       (foreach x (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
         (mapcar 'vla-delete (vlax-invoke (vlax-ename->vla-object x) 'GetAttributes))))
  (princ))

Lee Mac

  • Seagull
  • Posts: 12922
  • London, England
Re: Attribute delete
« Reply #6 on: November 26, 2009, 12:22:23 PM »
Perhaps another way around it?

Code: [Select]
(defun c:test (/ ss)
  (and (setq ss (ssget "_:L" '((0 . "INSERT") (66 . 1))))
       (foreach x (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
         (mapcar (function (lambda (x) [color=red](vla-put-invisible x :vlax-true)[/color]))
                 (vlax-invoke (vlax-ename->vla-object x) 'GetAttributes))))
  (princ))

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Attribute delete
« Reply #7 on: November 26, 2009, 12:26:13 PM »
Just a modification of yours Alan, but thought I'd make it shorter  :evil:

Code: [Select]
(defun c:test (/ ss)
  (and (setq ss (ssget "_:L" '((0 . "INSERT") (66 . 1))))
       (foreach x (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
         (mapcar 'vla-delete (vlax-invoke (vlax-ename->vla-object x) 'GetAttributes))))
  (princ))

Code: [Select]
[color=red](vlax-invoke (vlax-ename->vla-object x) 'GetAttributes))))[/color]That's the one I was trying to remember!! I'm such a retard.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Attribute delete
« Reply #8 on: November 26, 2009, 12:26:30 PM »
Perhaps another way around it?

Code: [Select]
(defun c:test (/ ss)
  (and (setq ss (ssget "_:L" '((0 . "INSERT") (66 . 1))))
       (foreach x (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
         (mapcar (function (lambda (x) [color=red](vla-put-invisible x :vlax-true)[/color]))
                 (vlax-invoke (vlax-ename->vla-object x) 'GetAttributes))))
  (princ))
Oooo, nice one. :)
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

Lee Mac

  • Seagull
  • Posts: 12922
  • London, England
Re: Attribute delete
« Reply #9 on: November 26, 2009, 12:27:42 PM »
Code: [Select]
[color=red](vlax-invoke (vlax-ename->vla-object x) 'GetAttributes))))[/color]That's the one I was trying to remember!! I'm such a retard.

So am I judging by my first post...  :roll:

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Attribute delete
« Reply #10 on: November 26, 2009, 12:30:25 PM »
Code: [Select]
[color=red](vlax-invoke (vlax-ename->vla-object x) 'GetAttributes))))[/color]That's the one I was trying to remember!! I'm such a retard.

So am I judging by my first post...  :roll:
LoL
It's always nice to laugh at ourselves.  :lol:
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Attribute delete
« Reply #11 on: November 26, 2009, 04:34:06 PM »
Just a modification of yours Alan, but thought I'd make it shorter  :evil:

Code: [Select]
(defun c:test (/ ss)
  (and (setq ss (ssget "_:L" '((0 . "INSERT") (66 . 1))))
       (foreach x (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
         (mapcar 'vla-delete (vlax-invoke (vlax-ename->vla-object x) 'GetAttributes))))
  (princ))
Code: [Select]
(defun c:test ()
  (foreach x (vl-remove-if 'listp (mapcar 'cadr (ssnamex (ssget "_:L" '((0 . "INSERT") (66 . 1))))))
         (mapcar 'vla-delete (vlax-invoke (vlax-ename->vla-object x) 'GetAttributes))))
  (princ))
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Attribute delete
« Reply #12 on: November 26, 2009, 04:42:07 PM »
Just a modification of yours Alan, but thought I'd make it shorter  :evil:

Code: [Select]
(defun c:test (/ ss)
  (and (setq ss (ssget "_:L" '((0 . "INSERT") (66 . 1))))
       (foreach x (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
         (mapcar 'vla-delete (vlax-invoke (vlax-ename->vla-object x) 'GetAttributes))))
  (princ))
Code: [Select]
(defun c:test ()
  (foreach x (vl-remove-if 'listp (mapcar 'cadr (ssnamex (ssget "_:L" '((0 . "INSERT") (66 . 1))))))
         (mapcar 'vla-delete (vlax-invoke (vlax-ename->vla-object x) 'GetAttributes))))
  (princ))

Code: [Select]
Error: bad argument type: lselsetp nil  :lol:

Just nit-picking for not accounting for a nil ssget. :-)
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Attribute delete
« Reply #13 on: November 26, 2009, 07:03:26 PM »
Well shoot. :oops:

 :-P
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Attribute delete
« Reply #14 on: November 26, 2009, 07:09:55 PM »
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox