Turning a layer on triggering by cad file name

Turning a layer on triggering by cad file name

Sabne
Advocate Advocate
880 Views
4 Replies
Message 1 of 5

Turning a layer on triggering by cad file name

Sabne
Advocate
Advocate
I have drawings with naming convention as 2223-LZ-xxxx which xxxx is drawing sequential number. I am interested to have a lisp to turn on a common layer within whole drawing set which can be triggered by my sequential number when open each individual drawing.
For instance, I have 3 blocks a1,a2,a3 inside each drawing on the same layer which are turned off by default. I want to assign block a1 to drawing 1 to be turned on when I open it. I am not sure it can be achieved by lisp to turning on layer or block. Hope it is clear.
Thanks
0 Likes
881 Views
4 Replies
Replies (4)
Message 2 of 5

john.uhden
Mentor
Mentor

I think you are missing a piece of glue...

By "turning on" I think you mean turning on (+ thawing) the layer on which the block insertion resides.  In which case we need the format for the layer name.

Or do you mean for the code to find the layer(s) in which the block is inserted and thaw/on those layers no matter what the layers' names are?

Also, in your dwgname example (2223-LZ-xxxx) are the xs all numbers perhaps ranging from 1 to 9999?  And block A1 goes with 2223-LZ-1 and A2 with 2223-LZ-2?  And there may be a block A9999?

John F. Uhden

0 Likes
Message 3 of 5

Sabne
Advocate
Advocate

Thanks John,

 

I found a code in here (credit to Tharwat) that is very close to my need. In summary, this code searching through block named "ULTRA INFO, looking into tag value of "CIRCID", and then matches its value to the layers name. If found one and they match (layer and att value), it will"Turn OFF" the layer.

 

No I am wondering how to :

 

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

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

 

Thanks

 

 


(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)

 

0 Likes
Message 4 of 5

john.uhden
Mentor
Mentor

I think you are missing a piece of glue...

By "turning on" I think you mean turning on (+ thawing) the layer on which the block insertion resides.  In which case we need the format for the layer name.

Or do you mean for the code to find the layer(s) in which the block is inserted and thaw/on those layers no matter what the layers' names are?

Also, in your dwgname example (2223-LZ-xxxx) are the xs all numbers perhaps ranging from 1 to 9999?  And block A1 goes with 2223-LZ-1 and A2 with 2223-LZ-2?  And there may be a block A9999?

John F. Uhden

0 Likes
Message 5 of 5

Sabne
Advocate
Advocate

Have you pointed out anything John?

0 Likes