coombsie11 Posted April 14, 2009 Posted April 14, 2009 Can the filter command run as a lisp? I use the filter command quite a bit and have several saveas filters. If anyone has a sample of how it could work within a LISP. Please add a few idiot notes, as my LISP knowledge is very limited. Thanks all.. Quote
lpseifert Posted April 14, 2009 Posted April 14, 2009 Not sure of your intentions but try looking in Developer Help for the subr SSGET, there are ways to filter using it to create selection sets. Also, look here http://afralisp.net/lispa/lisp19.htm Quote
uddfl Posted April 15, 2009 Posted April 15, 2009 Here are a few quick-and-dirty filter functions I use. Have a look at them and see if they can be of use. I'm sure you can customize them to your own needs. (defun ftdxf (groupcode groupvalue) (setq sset (ssget (list (cons groupcode groupvalue)))) (sssetfirst sset sset) (princ) ) (defun c:ft (); filter by group code value (works with strings only) (setq gcode (getint "\nEnter DXF group code: ")) (textscr) (setq gcodevalue (getstring T "\nEnter code value: ")) (graphscr) (setq sset (ssget (list (cons gcode gcodevalue)))) (sssetfirst sset sset) (princ) ) (defun c:fte (); filter by entity type (setq gcodevalue (cdr (assoc 0 (entget (car (entsel "\nPick entity: ")))))) (setq sset (ssget (list (cons '0 gcodevalue)))) (sssetfirst sset sset) (princ) ) (defun c:ftl (); filter by layer (setq property (cdr (assoc 8 (entget (car (entsel)))))) (if (= property nil) (setq property 256) ) (setq sset (ssget (list (cons 8 property)))) (sssetfirst sset sset) (princ) ) (defun c:ftc (); filter by color (setq property (cdr (assoc 62 (entget (car (entsel)))))) (if (= property nil) (setq property 256) ) (setq sset (ssget (list (cons 62 property)))) (sssetfirst sset sset) (princ) ) (defun c:fbn ( / blockname sset); filter all blocks of same name (setq blockname (cdr (assoc 2 (entget (car (entsel)))))) (setq sset (ssget (list (cons 2 blockname)))) (sssetfirst sset sset) (princ (strcat "\nSelected " (itoa (sslength sset)) " instances of block \"" blockname "\".")) (princ) ) (defun c:fbx ( / blockname sset); filter all blocks of same name with one click (setq blockname (cdr (assoc 2 (entget (car (entsel)))))) (setq sset (ssget "x" (list (cons 2 blockname)))) (sssetfirst sset sset) (princ (strcat "\nSelected " (itoa (sslength sset)) " instances of block \"" blockname "\".")) (princ) ) Quote
David Bethel Posted April 15, 2009 Posted April 15, 2009 Here's 1 that started writing way way back. It will let you edit DXF codes by filtered selection sets. -David SSEDIT.ZIP Quote
coombsie11 Posted April 15, 2009 Author Posted April 15, 2009 Thanks for all of your help & sorry for any delay getting back.. One of the main filters that I use selects text form various layers, but at a consistent height of 0.13. Any ideas? Will SSGET work in this instance? Quote
Arizona Posted April 15, 2009 Posted April 15, 2009 I use this little 'getgrip' command almost every day. I know the most common dxf codes by heart, so for example, if I want all leaders, I enter "0", "leader" (no quotes) and it selects all leaders. Everything on layer NoPlot, "8", "NoPlot". All blocks named Bonzo, "2", "Bonzo". Etc.... I put the code in my ACAD.LSP so it is always available. You might be able to modify this code to suit your needs. (defun C:GETGRIP () (setq A (getint "\n1st Part: ")) (setq B (getstring T "\n2nd Part: ")) (ssget "X" (list (cons A B))) (sssetfirst nil (ssget "_p")) ) Quote
uddfl Posted April 15, 2009 Posted April 15, 2009 I use this little 'getgrip' command almost every day.I know the most common dxf codes by heart, so for example, if I want all leaders, I enter "0", "leader" (no quotes) and it selects all leaders. Everything on layer NoPlot, "8", "NoPlot". All blocks named Bonzo, "2", "Bonzo". Etc.... I put the code in my ACAD.LSP so it is always available. You might be able to modify this code to suit your needs. (defun C:GETGRIP () (setq A (getint "\n1st Part: ")) (setq B (getstring T "\n2nd Part: ")) (ssget "X" (list (cons A B))) (sssetfirst nil (ssget "_p")) ) that's exactly what my c:ft function above does. I intend to upgrade mine so that it accepts arbitrary input in order to support real number input and not just strings. Quote
Lee Mac Posted April 15, 2009 Posted April 15, 2009 Uddfl, would you go about altering the "ft" program in this manner? (defun c:ft (/ gcode gcodevalue) ; filter by group code value (works with strings only) (if (setq gcode (getint "\nEnter DXF group code: ")) (progn (cond ((member gcode '(1 2 3 6 7 8 410)) (setq gcodevalue (getstring T "\nEnter code String: "))) ((member gcode '(39 40 41 48 50 51 60 62 66 70 71 72 73 74)) (setq gcodevalue (getreal "\nEnter Code Number: "))) (T (princ "\nDXF Code not Recognised or I couldn't be bothered to look it up when I made this program"))) (and gcodevalue (sssetfirst nil (ssget (list (cons gcode gcodevalue))))))) (princ)) 1 Quote
uddfl Posted April 16, 2009 Posted April 16, 2009 Uddfl, would you go about altering the "ft" program in this manner? (defun c:ft (/ gcode gcodevalue) ; filter by group code value (works with strings only) (if (setq gcode (getint "\nEnter DXF group code: ")) (progn (cond ((member gcode '(1 2 3 6 7 8 410)) (setq gcodevalue (getstring T "\nEnter code String: "))) ((member gcode '(39 40 41 48 50 51 60 62 66 70 71 72 73 74)) (setq gcodevalue (getreal "\nEnter Code Number: "))) (T (princ "\nDXF Code not Recognised or I couldn't be bothered to look it up when I made this program"))) (and gcodevalue (sssetfirst nil (ssget (list (cons gcode gcodevalue))))))) (princ)) Awesome. That was rather simple... although I don't know if I would have figured it our myself. Quote
Lee Mac Posted April 16, 2009 Posted April 16, 2009 Awesome. That was rather simple... although I don't know if I would have figured it our myself. I don't know all the codes though, and whether they are strings or numbers (or points for that matter). I just wrote in the ones that I did know... and left a message about the ones I didn't...! Quote
uddfl Posted April 16, 2009 Posted April 16, 2009 I don't know all the codes though, and whether they are strings or numbers (or points for that matter). I just wrote in the ones that I did know... and left a message about the ones I didn't...! The ability to filter by radius, scale factor, rotation angle, etc. is plenty good. I will post here any updates that I might add to it if I find anything. Love the message by the way LOL. Quote
Lee Mac Posted April 16, 2009 Posted April 16, 2009 Love the message by the way LOL. Thought you might Quote
BADBOI Posted January 13, 2012 Posted January 13, 2012 I am using autocad 2012 for MAC and tried loading in your Lisp. I am trying to select all the linework in a specific colour regardless of layer, such as red, so I can put them onto a different layer.... Is this possible with your lisp? Autocad MAC doesn't have the Filter command.... thanks Quote
wimal Posted January 14, 2012 Posted January 14, 2012 please use the path attached in next post Quote
wimal Posted January 14, 2012 Posted January 14, 2012 http://www.cadtutor.net/forum/showthread.php?65100-To-select-all-blocks-which-have-same-name-inside-a-selection-windoe see the forum regarding this13 dec. 2011 Quote
asuarez2311 Posted November 17, 2023 Posted November 17, 2023 On 4/15/2009 at 4:00 PM, uddfl said: Here are a few quick-and-dirty filter functions I use. Have a look at them and see if they can be of use. I'm sure you can customize them to your own needs. (defun ftdxf (groupcode groupvalue) (setq sset (ssget (list (cons groupcode groupvalue)))) (sssetfirst sset sset) (princ) ) (defun c:ft (); filter by group code value (works with strings only) (setq gcode (getint "\nEnter DXF group code: ")) (textscr) (setq gcodevalue (getstring T "\nEnter code value: ")) (graphscr) (setq sset (ssget (list (cons gcode gcodevalue)))) (sssetfirst sset sset) (princ) ) (defun c:fte (); filter by entity type (setq gcodevalue (cdr (assoc 0 (entget (car (entsel "\nPick entity: ")))))) (setq sset (ssget (list (cons '0 gcodevalue)))) (sssetfirst sset sset) (princ) ) (defun c:ftl (); filter by layer (setq property (cdr (assoc 8 (entget (car (entsel)))))) (if (= property nil) (setq property 256) ) (setq sset (ssget (list (cons 8 property)))) (sssetfirst sset sset) (princ) ) (defun c:ftc (); filter by color (setq property (cdr (assoc 62 (entget (car (entsel)))))) (if (= property nil) (setq property 256) ) (setq sset (ssget (list (cons 62 property)))) (sssetfirst sset sset) (princ) ) (defun c:fbn ( / blockname sset); filter all blocks of same name (setq blockname (cdr (assoc 2 (entget (car (entsel)))))) (setq sset (ssget (list (cons 2 blockname)))) (sssetfirst sset sset) (princ (strcat "\nSelected " (itoa (sslength sset)) " instances of block \"" blockname "\".")) (princ) ) (defun c:fbx ( / blockname sset); filter all blocks of same name with one click (setq blockname (cdr (assoc 2 (entget (car (entsel)))))) (setq sset (ssget "x" (list (cons 2 blockname)))) (sssetfirst sset sset) (princ (strcat "\nSelected " (itoa (sslength sset)) " instances of block \"" blockname "\".")) (princ) ) Hi!! a question Why when I run FBN function, Autocad showme this "wrong type arg... lselsetp nil"???????? Quote
Recommended Posts
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.