Hide Block Attributes

Hide Block Attributes

Anonymous
Not applicable
13,763 Views
11 Replies
Message 1 of 12

Hide Block Attributes

Anonymous
Not applicable

If you create a block, and give it 3 attributes,

Text 1

Text 2

Text 3

Once you insert multiple copies of that block into a drawing, is there a way to selectively hide one attribute at a time, only hiding it for one block instance, and not hiding it for every block in the drawing?

Block 1         Block2       Block 3

Text 1            Text 1        Text 1

                      Text 2        Text 2

                                         Text 3

0 Likes
Accepted solutions (1)
13,764 Views
11 Replies
Replies (11)
Message 2 of 12

coffeejeanpaul
Advocate
Advocate

Good day. 

 

What if you just remove the attribute in the block in the properties pallet ? 

coffeejeanpaul_0-1614218889822.png

This wont update all blocks, but only the individual block you change the property in.

Hope this helps !

0 Likes
Message 3 of 12

Anonymous
Not applicable

Thanks for your reply,

I was trying to keep the data in the block, just hidden in the model.

I took some screen shots of the block I am working with from an older drawing, I copied the block to a new drawing to isolate it. I can't figure out how the attributes are hidden as it is. Everything I see for invisibility is set to false from what I can see. But I am pretty new to Autocad and could easily be over looking something.

 

With attributes ATTDISP set to normal

1.png

With attributes ATTDISP set to show all

2.png

Battman for block

3.png

I attached a dwg file with the block.

0 Likes
Message 4 of 12

ВeekeeCZ
Consultant
Consultant

This routine will hide selected attributes. See HERE in detail about LISP routines if needed.

 

(vl-load-com)

(defun c:AttOff (/ nen tag obj)
  
  (and (setq nen (car (nentsel "\nPick attribute: ")))
       (setq tag (cdr (assoc 2 (entget nen))))
       (setq obj (vlax-ename->vla-object (cdr (assoc 330 (entget nen)))))
       (foreach att (append (vlax-invoke obj 'GetAttributes)
			    (vlax-invoke obj 'GetConstantAttributes))
	 (if (eq tag (vla-get-TagString att))
	   (vla-put-invisible att :vlax-true))))
  (princ)
  )

 

0 Likes
Message 5 of 12

Moshe-A
Mentor
Mentor

@Anonymous hi,

 

how about sending these attributes to a "hidden" layer?

 

Moshe

 

0 Likes
Message 6 of 12

coffeejeanpaul
Advocate
Advocate

As suggested making individual layers for the attribute, I think would be quicker than making a dynamic block.

In turn if you switch the layer of it would be hidden in the block.

 

See attached if it helps

 

coffeejeanpaul_0-1614308872147.png

coffeejeanpaul_1-1614308926147.png

 

Message 7 of 12

Anonymous
Not applicable

These are all good ideas, for future drawings. I assume even if I use the LISP programing to toggle them to invisible, that they should still show as invisible in the BATTMAN utility? I'm mostly confused as to why they are hidden acting like they are invisible, but they don't seem to be marked as invisible in the drawing. Toggling the attribute to visible and doing an ATTSYNC causes the whole drawing to update as visible, but then I loose the ability to individually hide them again. Maybe this is normal, and something just got out of SYNC with the rest of the blocks in the drawing?  I'm trying to learn why it is acting the way it is now, so I can determine if I am missing an option that I don't know about, or were the blocks added with the attribute set as invisible, then someone changed the attribute back to visible, and added more instances of the block, but never SYNCed the blocks previously added to the drawing?

0 Likes
Message 8 of 12

Moshe-A
Mentor
Mentor
Accepted solution

@Anonymous  hi,

 

first you need to understand how AutoCAD attribute block works:-

 

when you create a block on your screen by BLOCK command. the geometric definition store in database drawing (dwg) as Block Definition. to insert a copy (or copies) of that block definition on screen, you use INSERT command and by that you create Blocks Reference (also known as Inserts). by entering to BEDIT command you can modify the Block Definition and on eXit\Save the drawing is regenerated to reflect the block changes to all inserts - up to here are you agree?!

 

Why when we use BLOCK command we end up with a block reference (insert) already inserted in? that's because the block command interface do two tasks in a row (making block + insert) to make it easy for us 😀 this is 'new' in AutoCAD. in earlier versions this was two tasks.

 

Now lets talk attributes:

when you insert an attribute block, the attributes become path of the insert that's why when you modify the attributes in BEDIT they are not update and for that you need BATTMAN Sync or ATTSYNC command and even than, the attributes values is preserved (all other properties are update) the reason for this behavior is to prevent accidentally lose of attributes\values. 

 

on double click on attribute block you directly modifies the attributes on the block reference.

on BEDIT or BATTMAN (with out sync) command you modify the attributes only on the block definition.

 

Does that answers all you question?

 

Moshe

 

 

0 Likes
Message 9 of 12

Anonymous
Not applicable

If I understand what you are saying, if I create a block with three attributes, and insert it with them all being visible, then run the BEDIT command, making one of the attributes invisible, the blocks inserted after the BEDIT will show the change, and the ones that were already inserted will only change after an ATTSYNC command?  

0 Likes
Message 10 of 12

Moshe-A
Mentor
Mentor

Exactly! 

 

And the way to solve your question is layer (see my respond in message #5 )

 

and just to make it more easy for you, here is a nice command SATT2L to send an attribute to hidden layer of your choice. as you can see, the more real challenge here was (askLayer) function. 😀

 

Moshe

 

 

; Send Attribute to Layer
(defun c:satt2l (/ askLayer ; local function 
                   ATTRIB_HIDDEN_LAYER deflay pick sube)

 (defun askLayer (def / chkLayer ; local function
                        flag layer)

  (defun chkLayer (lay / ask)
   (if (not (tblsearch "layer" lay))
    (progn
     (initget "Yes No")
     (setq ask (getkword (strcat "\nLayer \"" lay "\" is not exist, Create it <Y>: ")))
     (if (or (not ask) (eq ask "Yes"))
      (not (command "._layer" "_new" lay "_off" lay "")) ; create the layer and set it to off
     ); if
    ); progn
    (not (command "._layer" "_off" lay ""))   ; make sure layer is off
   ); if
  ); check_create

   
  (while (not flag) 
   (setq layer (getstring (strcat "\nLayer to hide attributes <" def ">: ")))

   (cond
    ((eq layer "")
     (setq flag (chkLayer def))
    ); case 
    ( t
     (setq flag (chkLayer layer))
    )
   ); cond
    
  ); while
   
  layer
 ); askLayer


 (setvar "cmdecho" 0)
 (command "._undo" "_begin")

 (if (eq (getvar "users1") "")
  (setq deflay (getvar "clayer"))
  (setq deflay (getvar "users1"))
 )
  
 (setvar "users1" (setq ATTRIB_HIDDEN_LAYER (askLayer deflay)))
  
 (while (and
          (setq pick (nentsel "\nPick attribute: "))
          (setq sube (entget (car pick)))
          (eq (cdr (assoc '0 sube)) "ATTRIB")
        )  
  (entmod (subst (cons '8 ATTRIB_HIDDEN_LAYER) (assoc '8 sube) sube))
 ); while

 (command "._undo" "_end")
 (setvar "cmdecho" 1)

 (princ) 
)

 

 

Message 11 of 12

Moshe-A
Mentor
Mentor

@Anonymous 

 

fixed a bug + change the command name to HATT 😀

 

 

Message 12 of 12

TourajM
Enthusiast
Enthusiast
Hi, this routine is very good. Is it possible to program not stop till I Esc. I want to keep selecting one by one till I'm done using the Esc—key to stop.
0 Likes