coombsie11 Posted April 14, 2009 Share 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 Link to comment Share on other sites More sharing options...
lpseifert Posted April 14, 2009 Share 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 Link to comment Share on other sites More sharing options...
uddfl Posted April 15, 2009 Share 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 Link to comment Share on other sites More sharing options...
David Bethel Posted April 15, 2009 Share 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 Link to comment Share on other sites More sharing options...
coombsie11 Posted April 15, 2009 Author Share 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 Link to comment Share on other sites More sharing options...
Lee Mac Posted April 15, 2009 Share Posted April 15, 2009 just add (cons 40 0.13) in your filter. Quote Link to comment Share on other sites More sharing options...
Arizona Posted April 15, 2009 Share 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 Link to comment Share on other sites More sharing options...
uddfl Posted April 15, 2009 Share 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 Link to comment Share on other sites More sharing options...
Lee Mac Posted April 15, 2009 Share 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 Link to comment Share on other sites More sharing options...
uddfl Posted April 16, 2009 Share 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 Link to comment Share on other sites More sharing options...
Lee Mac Posted April 16, 2009 Share 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 Link to comment Share on other sites More sharing options...
uddfl Posted April 16, 2009 Share 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 Link to comment Share on other sites More sharing options...
Lee Mac Posted April 16, 2009 Share Posted April 16, 2009 Love the message by the way LOL. Thought you might Quote Link to comment Share on other sites More sharing options...
BADBOI Posted January 13, 2012 Share 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 Link to comment Share on other sites More sharing options...
wimal Posted January 14, 2012 Share Posted January 14, 2012 please use the path attached in next post Quote Link to comment Share on other sites More sharing options...
wimal Posted January 14, 2012 Share 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 Link to comment Share on other sites More sharing options...
asuarez2311 Posted November 17 Share Posted November 17 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 Link to comment Share on other sites More sharing options...
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.