Jump to content

Grab an attribute then use it to turn off a layer


BShick5088

Recommended Posts

  • Replies 28
  • Created
  • Last Reply

Top Posters In This Topic

  • Tharwat

    10

  • Railyn

    8

  • BShick5088

    6

  • steven-g

    3

oh wait yes it does! that's great! it asks me to manually click the block though. can you make it automatically pick HEADER_N13?

I have asked you before but you did not reply to me about this point so I posted the codes to allow you to check that out by yourself ;)

 

Replace this part from the program then run the program and let me know;

 

(setq s (ssget "_X" '((0 . "INSERT")(66 . 1)(2 . "HEADER_N13"))))

Link to comment
Share on other sites

yes, I know sorry, I think I was maybe a little unclear when I tried to say that HEADER_N13 was the attributed block name.

I am very new with lisps and I don't know exactly what I am doing but you are very very helpful! I am not sure how ever if I am replacing the right part of the code because it doesn't seem to make any difference.. :(

Sorry for being hopeless! Is it also possible to make it only hide it if both HEADER6 AND HEADER7 is blank? Sorry for changing my mind on that.

Link to comment
Share on other sites

Is it also possibly to remove the warning if no rector layer is found. This lisp will be on auto load and not all drawings will have that layer so it would pop up a lot.

Again thank you so much, you have no idea how much time this will save me!

Link to comment
Share on other sites

Never mind here it is modified completely .

 

(defun c:Test (/ s _t)
 ;; Tharwat 14.03.2016 ;;
 (defun _t (obj / att)
 (if
   (vl-some '(lambda (x)
               (and (eq (strcase (vla-get-tagstring x)) "HEADER6")
                    (setq att x))
               )
            (vlax-invoke obj 'getattributes)
            )
   (vla-put-Layeron (vlax-ename->vla-object (tblobjname "LAYER" "REACTOR LAYER"))
     (if (eq (vla-get-textstring att) "") 0 1))
   )
 )
 (cond (  (not (tblsearch "LAYER" "REACTOR LAYER"))
            (alert "Layer name <REACTOR LAYER> is not found in this drawing !")
          )
       (  (and (princ "\nPick on Attributed Block: ") (setq s (ssget "_X" '((0 . "INSERT")(66 . 1)(2 . "HEADER_N13")))))
            (_t (vlax-ename->vla-object (ssname s 0)))
          )
       (t (princ "\nBlock name <HEADER_N13> is not found !")
          )
     )
(princ)
)(vl-load-com)

Link to comment
Share on other sites

I managed to remove the alert! Thanks! This is really cool! I will have to play around with it a little to see if it does what its supposed to but it looks really promising! Thank you so so much, my hero of the day!

Link to comment
Share on other sites

  • 1 year later...

Sorry to hijack this thread, I found Tharwat lisp very close to my need. I am wondering how to :

 

(defun c:Test (/ s i l lst e n a)
 ;;    Tharwat 12.9.2014    ;;
 (if (setq s (ssget "_X" '((0 . "INSERT") (66 . 1) (2 . "ULTRA INFO"))))
   (repeat (setq i (sslength s))
     (mapcar
       '(lambda (u)
          (if
            (eq (strcase (vla-get-tagstring u)) "CIRCID")
             (setq lst (cons (vla-get-textstring u) lst))
          )
        )
       (vlax-invoke
         (vlax-ename->vla-object (ssname s (setq i (1- i))))
         'getAttributes
       )
     )
   )
 )
 (if lst
   (while (setq a (tblnext "LAYER" (not a)))
     (foreach x lst
       (if (wcmatch (setq n (cdr (assoc 2 a))) (strcat x "*"))
         (entmod
           (subst (cons 62 (- (cdr (assoc 62 a))))
                  (assoc 62 (setq e (entget (tblobjname "LAYER" n))))
                  e
           )
         )
       )
     )
   )
 )
 (princ)
)(vl-load-com)

 

1) apply it on Xref's layer. This routine is only matching att values of active cad file layer.

2) Turn "ON" the layer instead of "OFF"

 

Thanks

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...