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

Make Layer Filter Lisp ??

15 REPLIES 15
Reply
Message 1 of 16
Anonymous
6701 Views, 15 Replies

Make Layer Filter Lisp ??

I am working with Acad 2005.
Does anyone have a lisp file that will allow you to create New Property Filters ??
I want to have a lisp file that creates a Demo layer filter that filters " *-d" and " *-demo" layers.
I don't know if I am explaining this well so please see the attached jpg file to make more sense.
I have found some posts here but have not be able to modify them to make this work.
Thanks in advance for the help.
15 REPLIES 15
Message 2 of 16
Anonymous
in reply to: Anonymous

Hello Eric,

Here's what I use with Acad 2005. Hope its what you require.

Save attached lsp file to here "C:\PROGRAM FILES\AUTOCAD
2005\SUPPORT"

Create a file called FILTERS.TXT in same directory.
Add the following 2 lines into the TXT file.

("d" "*d")
("demo" "*demo")

Then save and close the file.

Next load the MAKELAYERFILTER.LSP into AutoCAD.
On command line enter "(gatherfilter)" .......notice the parentheses!
Then open the layer dialog and the named filters should be there.

If you open the MAKELAYERFILTER.LSP file you will see that there are 2
options to change
how you load the FILTERS.TXT.
Option 1 finds the TXT file by looking in a defined directory (Default)
Option 2 finds the TXT file by locating the file in the support search
paths.
Just choose which way you prefer by commenting ";;" out the option you don't
want.

Also, you can add as many filters as you like to the FILTERS.TXT file.
The ones i created above are examples for what you requested.
It should be east to follow how they are constructed when you open the layer dialog box.

All the best

--
Shoey
Message 3 of 16
Anonymous
in reply to: Anonymous

Glad to see someone had a use for this.

Make sure to change the location for the FILTERS.TXT file to your directory
location.

wrote in message news:5093836@discussion.autodesk.com...
Hello Eric,

Here's what I use with Acad 2005. Hope its what you require.

Save attached lsp file to here "C:\PROGRAM FILES\AUTOCAD
2005\SUPPORT"

Create a file called FILTERS.TXT in same directory.
Add the following 2 lines into the TXT file.

("d" "*d")
("demo" "*demo")

Then save and close the file.

Next load the MAKELAYERFILTER.LSP into AutoCAD.
On command line enter "(gatherfilter)" .......notice the parentheses!
Then open the layer dialog and the named filters should be there.


If you open the MAKELAYERFILTER.LSP file you will see that there are 2
options to change
how you load the FILTERS.TXT.
Option 1 finds the TXT file by looking in a defined directory (Default)
Option 2 finds the TXT file by locating the file in the support search
paths.
Just choose which way you prefer by commenting ";;" out the option you don't
want.

Also, you can add as many filters as you like to the FILTERS.TXT file.
The ones i created above are examples for what you requested.
It should
be east to follow how they are constructed when you open the layer dialog
box.

All the best

--
Shoey
Message 4 of 16
Anonymous
in reply to: Anonymous

Works like a charm...thanks guys.
I really appreciate the help.
Message 5 of 16
Anonymous
in reply to: Anonymous

Shoey,

This program looks awesome! If only I could get it to run correctly.
I am currently using AutoCAD 2006 and tried to run your program.
In the COMMAND Line I was able to load it, however I received an error message as follows.
" ; error: bad argument type: streamp nil"
I checked your code and could not locate this argument...
I made sure that I changed the file path to the filters.txt file, and it is also located in my search path.
I have also placed the ";;" in front of the method I did not want to use (as directed by your code).
I would really like to get this program up and running.
Right now i'm done wracking my brain. It's time for someone with greater coding experience to take over.
Can anyone help me to fix this issue?
Any help would be much appreciated.
Thank you.
Message 6 of 16
spinalfarm
in reply to: Anonymous

Is there a way to enter a filter option including just the COLOR 203?

Thanks,
-STU
Message 7 of 16
Anonymous
in reply to: Anonymous

What can I do to get the MAKELAYERFILTER.LSP file to work in Autocad 2007?


Command: "(gatherfilter)"
Unknown command ""(GATHERFILTER)"". Press F1 for help.

This is the error message that I get.

Thanks
Message 8 of 16
Anonymous
in reply to: Anonymous

Message 9 of 16
Anonymous
in reply to: Anonymous

Thanks. The error messages are below. I typed the Autolisp command in several different ways using the parenthesis and the quotation marks in different places.

1. Unknown command
2. Error: no function
3. Error: bad function


Command: gatherfilter
Unknown command "GATHERFILTER". Press F1 for help.

Command: "(gatherfilter)"
Unknown command ""(GATHERFILTER)"". Press F1 for help.

Command: (gatherfilter)
; error: no function definition: GATHERFILTER

Command: ("gatherfilter")
; error: bad function: "gatherfilter"

Command: "(gatherfilter)"
Unknown command ""(GATHERFILTER)"". Press F1 for help.


Any help would be greatly appreciated. Thanks.
Message 10 of 16
Anonymous
in reply to: Anonymous

it should be
(gatherfilter)
if this does not work, you have to load the file first
(load "gatherfilter.lsp") if the file wher the function gatherfilter is
defined has this name
and afterwards
(gatherfilter)
should work


spittman@jjkllc.com wrote:
> Thanks. The error messages are below. I typed the Autolisp command in
> several different ways using the parenthesis and the quotation marks in
> different places. 1. Unknown command 2. Error: no function 3. Error: bad
> function Command: gatherfilter Unknown command "GATHERFILTER". Press F1
> for help. Command: "(gatherfilter)" Unknown command ""(GATHERFILTER)"".
> Press F1 for help. Command: (gatherfilter) ; error: no function
> definition: GATHERFILTER Command: ("gatherfilter") ; error: bad
> function: "gatherfilter" Command: "(gatherfilter)" Unknown command
> ""(GATHERFILTER)"". Press F1 for help. Any help would be greatly
> appreciated. Thanks.
Message 11 of 16
Anonymous
in reply to: Anonymous

Thanks.

Now I'm getting the following error message.


; error: malformed string on input



Here are the first 2 lines of the MakeLayerFilters.lsp

-----------------------------
(defun GatherFilter (/ FP FL FILENAME)
;; swap next two lines if absolute location is desired.
(setq FP (open "C:/PROGRAM FILES/AUTOCAD 2007/SUPPORT/FILTERS.TXT" "r") ; <- OPTION 1, CHANGE PATH AND TXT FILE TO YOUR LIKEING!
;; (setq FP (open "FILTERS.TXT" "r") ; <- OPTION 2, CHANGE TXT FILE, USE WITH SUPPORT SEARCH PATHS!
FL nil
FL2 nil)

--------------------------------

I see that the backslash is going the opposite way in the lsp file than than in the url bar at the top of the screen. This may not be an issue.

Thanks for the help.
Message 12 of 16
Anonymous
in reply to: Anonymous

(defun GatherFilter (/ FP FL FILENAME)
(setq FP (open "C:/PROGRAM FILES/AUTOCAD 2007/SUPPORT/FILTERS.TXT" "r"))

spittman@jjkllc.com wrote:
> Thanks. Now I'm getting the following error message. ; error: malformed
> string on input Here are the first 2 lines of the MakeLayerFilters.lsp
> ----------------------------- (defun GatherFilter (/ FP FL FILENAME) ;;
> swap next two lines if absolute location is desired. (setq FP (open
> "C:/PROGRAM FILES/AUTOCAD 2007/SUPPORT/FILTERS.TXT" "r") ; <- OPTION 1,
> CHANGE PATH AND TXT FILE TO YOUR LIKEING! ;; (setq FP (open
> "FILTERS.TXT" "r") ; <- OPTION 2, CHANGE TXT FILE, USE WITH SUPPORT
> SEARCH PATHS! FL nil FL2 nil) -------------------------------- I see
> that the backslash is going the opposite way in the lsp file than than
> in the url bar at the top of the screen. This may not be an issue.
> Thanks for the help.
Message 13 of 16
Anonymous
in reply to: Anonymous

btw
the backlash is no backslash, it is a foreslash 😉
if you want to use backslash in lisp, you have to double them
"c:\\test\\myfile.txt"
is equal to
"c:/test/myfile.txt"
spittman@jjkllc.com wrote:

> Thanks. Now I'm getting the following error message. ; error: malformed
> string on input Here are the first 2 lines of the MakeLayerFilters.lsp
> ----------------------------- (defun GatherFilter (/ FP FL FILENAME) ;;
> swap next two lines if absolute location is desired. (setq FP (open
> "C:/PROGRAM FILES/AUTOCAD 2007/SUPPORT/FILTERS.TXT" "r") ; <- OPTION 1,
> CHANGE PATH AND TXT FILE TO YOUR LIKEING! ;; (setq FP (open
> "FILTERS.TXT" "r") ; <- OPTION 2, CHANGE TXT FILE, USE WITH SUPPORT
> SEARCH PATHS! FL nil FL2 nil) -------------------------------- I see
> that the backslash is going the opposite way in the lsp file than than
> in the url bar at the top of the screen. This may not be an issue.
> Thanks for the help.
Message 14 of 16
Anonymous
in reply to: Anonymous

Thanks.

I copied the 2 lines in your previous post into the MakeFilters.lsp routine. Though the only difference that I see is the lack of 1 parenthesis on the end.

I now get the following error message.

nil

All help is appreciated.
Message 15 of 16
randyspear6624
in reply to: Anonymous

Great routine!

Except i can't get it to run from the palettes.

Normally, If i need to run a lisp from the palettes it would look like this:

^C^C(autoload "Drive:/Filepath/LISP.lsp"'("LISP"));LISP;

In this case i've got:
^C^C(autoload "Drive:/Filepath/MAKELAYERFILTER.lsp"'("(GATHERFILTER)"));(GATHERFILTER);
but i get an error. I think the problem is the portion in parenthesis or maybe because there are 2 defun commands in the routine.

Any help is appreciated.
Message 16 of 16
randyspear6624
in reply to: Anonymous

Also any thoughts on applying a invert filter?

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

Post to forums  

Forma Design Contest


AutoCAD Beta