Author Topic: Block attribute visability  (Read 3028 times)

0 Members and 1 Guest are viewing this topic.

caveman

  • Guest
Block attribute visability
« on: November 16, 2008, 08:52:05 AM »
Hey,

I'm trying to create a function to allow me to toggle the attribute visibility on groups of blocks.
Basically - the same result as the visibility toggle in the battman command which i can use with selection sets.

I have been having a play with the attdef entities (70 - Attribute flags: 1 = Attribute is invisible (does not appear)) - from acad help.
but not getting the results I'm after. :cry:

I'm not overly confident with the entity mods side of things so if someone could point me in the right direction I would greatly appreciate

Cheers
M
 

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Block attribute visability
« Reply #1 on: November 16, 2008, 12:00:13 PM »
Check this out.
Code: [Select]
(vla-get-Invisible att)
No time to help but you should find what you need.
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.

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: Block attribute visability
« Reply #2 on: November 16, 2008, 12:07:44 PM »
Hi,

If I don't misunderstand the question, here's a trick.

Code: [Select]
(defun c:test (/ ss n blk att elst vis)
  (and
    (setq ss (ssget '((0 . "INSERT") (66 . 1))))
    (setq n 0)
    (while (setq blk (ssname ss n))
      (setq att (entnext blk)
    n (1+ n)
      )
      (while (and
       att
       (setq elst (entget att))
       (= (cdr (assoc 0 elst)) "ATTRIB")
     )
(setq vis (assoc 70 elst)
      att (entnext att)
)
(entmod (subst (cons 70 (Boole 6 1 (cdr vis))) vis elst))
(entupd blk)
      )
    )
  )
  (princ)
)
« Last Edit: November 16, 2008, 12:18:29 PM by gile »
Speaking English as a French Frog

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Block attribute visability
« Reply #3 on: November 16, 2008, 02:38:46 PM »
Welcome to the Swamp caveman.
Just poped in for this:
Code: [Select]
(defun c:testOFF (/ ss idx ename att)
  (and
    (setq ss (ssget '((0 . "INSERT") (66 . 1))))
    (setq idx -1)
    (while (setq ename (ssname ss (setq idx (1+ idx))))
      (foreach att (vlax-invoke (vlax-ename->vla-object ename) 'getattributes)
        (vla-put-Invisible att :vlax-true)
      )
    )
  )
  (princ)
)


(defun c:testON (/ ss idx ename att)
  (and
    (setq ss (ssget '((0 . "INSERT") (66 . 1))))
    (setq idx -1)
    (while (setq ename (ssname ss (setq idx (1+ idx))))
      (foreach att (vlax-invoke (vlax-ename->vla-object ename) 'getattributes)
        (vla-put-Invisible att :vlax-flase)
      )
    )
  )
  (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.

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Block attribute visability
« Reply #4 on: November 16, 2008, 04:46:10 PM »
And a variant of CAB's code :)

Code: [Select]
(defun c:testToggle (/ ss idx ename att)
  (and
    (setq ss (ssget '((0 . "INSERT") (66 . 1))))
    (setq idx -1)
    (while (setq ename (ssname ss (setq idx (1+ idx))))
      (foreach att (vlax-invoke
     (vlax-ename->vla-object ename)
     'getattributes
   )
(if (= (vla-get-invisible att) :vlax-true)
  (vla-put-Invisible att :vlax-false)
  (vla-put-Invisible att :vlax-true)
)
      )
    )
  )
  (princ)
)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

caveman

  • Guest
Re: Block attribute visability
« Reply #5 on: November 17, 2008, 12:34:08 AM »
You guys are awesome - thats exactly what I was after.
Far better than the way I was trying to go about it  :oops:
Really appreciate everyones help.

Cheers
M

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Block attribute visability
« Reply #6 on: November 17, 2008, 07:52:42 AM »
Good job Gile and Ron. :-)
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.

Pad

  • Bull Frog
  • Posts: 342
Re: Block attribute visability
« Reply #7 on: November 19, 2008, 11:07:57 AM »
This lisp changes all of the attributes of a block invisible.
Is it possible for it to only change certain layer's attributes invisible?

eg.
The attached block has 3 attribs.
Level
Code
&
Number

I'd like to be able to make code and number layers invisible, regardless of the block they are in, but leave the level layer attribute visible.

Thanks
Pad
« Last Edit: November 19, 2008, 12:31:16 PM by Pad »

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Block attribute visability
« Reply #8 on: November 19, 2008, 12:40:35 PM »
Welcome to the Swamp.

Do you need a lisp to do it?
If not type battman at the command line.
Exptresstools must be loaded though.
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.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Block attribute visability
« Reply #9 on: November 19, 2008, 12:48:27 PM »
You can play with this. 8-)
Code: [Select]
(defun c:testOFF (/ ss idx ename att)
  (and
    (setq ss (ssget '((0 . "INSERT") (66 . 1))))
    (setq idx -1)
    (while (setq ename (ssname ss (setq idx (1+ idx))))
      (foreach att (vlax-invoke (vlax-ename->vla-object ename) 'getattributes)
        (if (member (vla-get-tagstring att) '("LEVEL" "CODE"))
          (vla-put-Invisible att :vlax-true)
        )
      )
    )
  )
  (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.

Pad

  • Bull Frog
  • Posts: 342
Re: Block attribute visability
« Reply #10 on: November 19, 2008, 02:03:43 PM »
Thanks Cab

that works a treat.
Yes the lisp is preferable to battman (which until today i didn't know about).

I have a lisp which bursts all my attributed blocks so that the codes and numbers can be deleted and the point is replaced with a cross block for presentation purposes.
Sometimes I think it may be preferable to leave the blocks unexploded so the attributes are still connected to the point, with the code and numbers invisible that sorts the presentation problem.
I may try and integrate the two lisps and have a prompt to choose which option, the burst or the invisible.

Cheers
Pad