Visible/invisible state of a block attribute

Hi Everybody,
If an attibute of a block is initially defined as invisible, is there a way to show it later on in th drawing ? Or is it possible to create it visible and to hide/show it according to drawings requirements ?
Thanks for your help. BR

Comments

  • You can do it with layers. Use a layer that's frozen (or just non-print?) in any insertion where you want the attribute to be invisible.
  • Can't think why you'd want a Block defined as invisible?!
  • The block is visible. 1 attribute of the block is visible (Attribute1). 1 other is not visible (Attribute2). I wish I could show or hide the second attribute after placing the block. Here you will find enclosed a dwg file.
    Layers may be an option or visibility states ?. Thanks for your help.
  • Anthony Apostolaros
    edited June 2022
    It looks like that block is intended for use in drawings at two different scales, with whichever attribute is appropriate to the scale visible. If so, you don't even need to do what I said before. You can just assign each attribute definition to the layer appropriate to the scale. Then it'll be automatic. When you restore the layer state for a scale, only the appropriate attribute will be visible. Likewise in the viewport -- layers not appropriate to the scale will be VP-frozen.
  • I geddit
  • ALANH
    edited June 2022
    Easy

    (setq ent (entget (car (nentsel "\nPick attribute")))
    (entmod (subst (cons 70 1) (assoc 70 ent) ent))

    Re manual 0 on, 1 off, also 2, 4 & 8 see help.

    Haha turn off can not pick so a bit harder to turn on. Would have to go through all atts.
  • Anthony Apostolaros
    edited June 2022
    ALANH said:

    ....
    (setq ent (entget (car (nentsel "\nPick attribute')))
    (entmod (subst (cons 70 1) (assoc 70 ent) ent))
    ....

    An attribute visibility toggle. But I think it needs a double quote instead of a single quote after "\nPick attribute," and another close parenthesis after that, as in the attached file.

    As you say, it's hard to select an invisible attribute so as to toggle it to visible. Maybe someone else can add whatever it takes to cycle through the attributes to find the invisible one. In the sample .dwg file provided there were only two attributes, so maybe that's not so hard. But just being able to turn visibility off would be enough to satisfy the first part of fst's request "to create it visible and to hide/show it according to drawings requirements." Still, I would use layers.
  • Thanks Anthony fixed typo and resaved post.

    Your right to turn on would loop through atts

    Google found this, good starting point for a on / off method.

    ;;; Attribute Visibility Toggle By Alan Thompson
    ;;; make a selection set of blocks with Atts and then hit
    ;;; This will toggle them either on or off
    (defun c:AVT (/ ss i)
    (vl-load-com)
    (if (setq ss (ssget "_:L" '((0 . "INSERT") (66 . 1))))
    (repeat (setq i (sslength ss))
    (foreach a (vlax-invoke (vlax-ename->vla-object (ssname ss (setq i (1- i)))) 'GetAttributes)
    (vlax-put a 'Visible (~ (vlax-get a 'Visible)))
    )
    )
    )
    (princ)
    )
  • For me, AVT toggles the visibility of all the Attributes in the selected block(s) on/off, but only if they were visible before my first use of AVT on the block(s). If an Attribute was originally created invisible, or if it was created visible and I used VIZ to make it invisible, it doesn't seem to be affected by AVT. So I don't think it would help fst, if I'm correct in thinking he or she wants to be able to make one Attribute visible and the other invisible.
  • Thank you all for you help. I agree with Anthony. I wish I could pick up 1 attribute in a list (all attributes of a selected block). If the attribute is already hidden,the selection will make it visible. If the attribute is already visible, it will hide it. I don't know if it is possible in lsp. Thanks again for your posts.BR
  • Anthony Apostolaros
    edited June 2022
    Attached .dwg file shows what I said in my first 2 posts above about doing it with layers instead of attribute visibility.
    You could also use layers & layerstates to have a different size of arrow & circle for each scale.

    Note that a quick & easy way to restore a layerstate is with the pull-down list next to the Lineweight pull-down list.
    And each viewport can have its own layerstate, because restoring a layerstate in a viewport sets VP Freeze.


  • This is like step 1 for On can do off easy as can see attribute, can add a is it this one but needs more coding so will turn any off to on.

    (defun c:attoff ( / ent)
    (setq ent (entget (car (nentsel "\nPick attribute"))))
    (entmod (subst (cons 70 1) (assoc 70 ent) ent))
    (princ)
    )

    (defun c:atton ( / ent)
    (setq ent (car (entsel "\nPick block")))
    (setq obj (vlax-ename->vla-object ent))
    (foreach att (vlax-invoke obj 'getattributes)
    (if (= (vla-get-invisible att) 0)
    (princ)
    (vla-put-invisible att 0)
    )
    )
    (princ)
    )