Jump to content

need help to change attribute visibility state.


aridzv

Recommended Posts

Hi.

I have a lisp that update blocks attributes.

I'm  trying to add an option to change the attribute visibility state,

including *U blocks (as usual...) dynamic & parametric blocks - see block No. 4 in the sample drawing.

in this code it makes the attribute to complitly disappear...

(defun c:chatht15-1 ( / ta an bent bent2 pt lay tagname ss bname x att temp YN VSBL )
(vl-load-com)
;;(vlax-put-property x 'visible :vlax-false)

  (setq tagname "ORDER")
  (setq ss (ssget (list (cons 0 "INSERT"))))

  (setq ht (getreal "\nEnter text height<24>: "))
  (if (= ht nil)
    (setq ht 24)
  )

  (setq an (getreal "\nEnter Rotation<0>: "))
    (if (= an nil)
    (setq an 0)
  )

(initget "YES NO")
   (if (null (setq VSBL (getkword "\nVisible [YES/NO] <NO>: ")))
      (vla-put-invisible att :vlax-false)
   )

(princ VSBL)
  (setq tagname (strcase (getstring "\nAttribute tag specification<ORDER>: ")))
   (if (= tagname "")
     (setq tagname "ORDER")
   )

(initget "Yes No")
(if (null (setq YN (getkword "\nClear Attribute Value? [Yes/No] <No>: ")))
    (setq YN "No")
)

  (setq an (/ (* an pi) 180))

  (repeat (setq x (sslength ss))
    (setq obj (vlax-ename->vla-object (ssname SS (setq x (- x 1) ))))
    (if  (= (vla-get-hasattributes obj) :vlax-true)
      (foreach att (vlax-invoke obj 'getattributes)
        (if (= tagname (strcase (vla-get-tagstring att)))
          (progn
              (vla-put-Rotation att an)
              (vla-put-height att ht)
              (if (= (vlax-get-property att 'Backward) :vlax-true)
               (vlax-put-property att 'Backward :vlax-false)
              )
              (if (= (vlax-get-property att 'UpsideDown) :vlax-true)
                (vlax-put-property att 'UpsideDown :vlax-false)
              )

             (if (= YN "Yes")
              (vla-put-textstring att "")
             )

;;             (vlax-put-property att 'visible :vlax-false)

            (if (= VSBL "NO")
             (progn
               (vla-put-invisible att :vlax-false)
               (vla-put-invisible att :vlax-true)
               ;;(vlax-put-property att 'visible :vlax-false)
               ;;(vlax-put-property att 'visible :vlax-true)
             );;close progn
            );;close if
             
          );;close progn
        )
      )
    )
  )

  (princ)
)

 

I also attached a sample drawing.

Thanks,

aridzv.

 

Drawing1.dwg

Edited by aridzv
Link to comment
Share on other sites

  • aridzv changed the title to need help to change attribute visibility state.

You have no att when calling this (vla-put-invisible att :vlax-false) will error. needs to go after this (if (= tagname (strcase (vla-get-tagstring att)))

 

I would look at a DCL as well much easier to have all the questions in front of you. 

 

 

Link to comment
Share on other sites

Hi @BIGAL and thanks for your reply!!

 

thanks for pointing the issue with the redundant (vla-put-invisible att :vlax-false) - fixed it and it led me to find some more issues that was fixed - the revised code attached here below.

DCL is Way beyond my abilities for now...

thanks again,

aridzv.

(defun c:chatht15 ( / ta an bent bent2 pt lay tagname ss bname x att temp YN VSBL )
(vl-load-com)

  (setq ss (ssget (list (cons 0 "INSERT"))))

  (setq ht (getreal "\nEnter text height<24>: "))
  (if (= ht nil)
    (setq ht 24)
  )

  (setq an (getreal "\nEnter Rotation<0>: "))
    (if (= an nil)
    (setq an 0)
  )


  (initget "YES NO")
  (setq VSBL (getkword "\nVisible [YES/NO] <NO>: "))
    (if (= VSBL nil)
          (setq VSBL "NO")
    )


  (setq tagname (strcase (getstring "\nAttribute tag specification<ORDER>: ")))
   (if (= tagname "")
     (setq tagname "ORDER")
   )

(initget "Yes No")
(if (null (setq YN (getkword "\nClear Attribute Value? [Yes/No] <No>: ")))
    (setq YN "No")
)

  (setq an (/ (* an pi) 180))

  (repeat (setq x (sslength ss))
    (setq obj (vlax-ename->vla-object (ssname SS (setq x (- x 1) ))))
    (if  (= (vla-get-hasattributes obj) :vlax-true)
      (foreach att (vlax-invoke obj 'getattributes)
        (if (= tagname (strcase (vla-get-tagstring att)))
          (progn
            (vla-put-Rotation att an)
            (vla-put-height att ht)
            (if (= (vlax-get-property att 'Backward) :vlax-true)
             (vlax-put-property att 'Backward :vlax-false)
            )
            (if (= (vlax-get-property att 'UpsideDown) :vlax-true)
              (vlax-put-property att 'UpsideDown :vlax-false)
            )

           (if (= YN "Yes")
            (vla-put-textstring att "")
           )

             ;;(vlax-put-property att 'visible :vlax-false)


           (if (= VSBL "NO")           
             (vla-put-invisible att :vlax-true)
             (vla-put-invisible att :vlax-false)  
           );;close if

          );;close progn
        );;close if
      );;close foreach
    );;close if
  );;close repeat
  (princ)
)

 

Edited by aridzv
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...