Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

script or lisp to create layer filter

7 REPLIES 7
Reply
Message 1 of 8
leilani.gnall-gregory
2472 Views, 7 Replies

script or lisp to create layer filter

I've created the script below that will create a layer filter with one definition. (ie, it filters layers with "lay" in their name).

I'd like to have several layers called (for example all layers containing text, which may be named "*tx*" , "*dm*", and "*rm*")

however, everytime I attempt to "edit" the filter it simply overwrites the last option, rather than adding to it. 

in other words, I can only filter ONE layer at a time, instead of 2 or more in one filter.

any suggestions?  I would also accept a LISP solution. 

thank you,

 

-LAYER
FILTER
NEW
PROPERTY

NAME
;;;   NAME YOUR FILTER
MYFILTER
;;;   EDIT YOUR FILTER
E
;;;   YOUR FILTER NAME
MYFILTER
D
NAME=="*LAY*"
x

7 REPLIES 7
Message 2 of 8

Here is one of my filters as an example:

 

(defun c:LayerFilterXref ()
  
  (command "_.LAYER"
           "_FILTER"
           "_N"
           "_P"
           "All"
           "NAME==\"_.xref*\" OR NAME==\"Layer*\""
           "Xrefs IN")

  (if (> (getvar 'CMDACTIVE) 0) (command ""))  ; this was just in case (i think) if the filter already exists
  (princ)
)
Message 3 of 8
DeeusJayus-ISX
in reply to: ВeekeeCZ


Hey @ВeekeeCZ 
Do you know how to access the On/Off, Freeze/Thaw, Locked/Unlocked properties using this method? the "NAME==" function is working well, but i can't seem to find anything about the other properties. Also, I can't figure out the syntax of the name portion. Any input would be appreciated.
"NAME==\"_.xref*\" OR NAME==\"Layer*\""
@ВeekeeCZ wrote:

Here is one of my filters as an example:

 

(defun c:LayerFilterXref ()
  
  (command "_.LAYER"
           "_FILTER"
           "_N"
           "_P"
           "All"
           "NAME==\"_.xref*\" OR NAME==\"Layer*\""
           "Xrefs IN")

  (if (> (getvar 'CMDACTIVE) 0) (command ""))  ; this was just in case (i think) if the filter already exists
  (princ)
)

 

Message 4 of 8
tnvsb
in reply to: DeeusJayus-ISX

Thanks a lot sir,

Can you please make this code for user input at command prompt for filter name and what type of layers to be filtered with wildcart. Advanced thanks.

Message 5 of 8
ВeekeeCZ
in reply to: DeeusJayus-ISX


@DeeusJayus-ISX wrote:

Hey @ВeekeeCZ 
Do you know how to access the On/Off, Freeze/Thaw, Locked/Unlocked properties using this method? ...

 

Sure, see the example:

"OFF==\"False\" AND FROZEN==\"False\"" 

Message 6 of 8
ВeekeeCZ
in reply to: tnvsb


@tnvsb wrote:

Thanks a lot sir,

Can you please make this code for user input at command prompt for filter name and what type of layers to be filtered with wildcart. Advanced thanks.


 

Try this one. Not sure is you want to the filter also current... if not, comment out the last line. HTH

(defun c:LayerFilter (/ name flt)

  (setq name (getstring T "\nFilter name: "))
  (setq flt (getstring T "\nLayer mask: "))

  (command "_.LAYER" "_FILTER" "_Delete" name "") 							(if (> (getvar 'CMDACTIVE) 0) (command ""))
  (command "_.LAYER" "_FILTER" "_New" "_Property" "All" (strcat "NAME==\"" flt "\"") name) 		(if (> (getvar 'CMDACTIVE) 0) (command ""))
  (command "_.LAYER" "_FILTER"	"_S" "All" "") (command "_.LAYER" "_FILTER" "_Set" name)		(if (> (getvar 'CMDACTIVE) 0) (command ""))
  (princ)
)
Message 7 of 8
tnvsb
in reply to: ВeekeeCZ

Working Amazingly, Thanks a lot sir, for your efforts.

Message 8 of 8
tnvsb
in reply to: ВeekeeCZ

Dear Experts,

 

I used to create layer filters from Excel input to autocad from one lisp program in my past company. But I lost that lisp programme. If you have such type of program, can you please share me. Please have a look on attachments. Advanced thanks.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost