Jump to content

Recommended Posts

Posted

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..:)

Posted

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

Posted

Here's 1 that started writing way way back. It will let you edit DXF codes by filtered selection sets. -David

SSEDIT.ZIP

Posted

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?:?

Posted

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

)

Posted
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.
Posted

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

  • Thanks 1
Posted
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. :oops:
Posted
Awesome. That was rather simple... although I don't know if I would have figured it our myself. :oops:

 

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...!

Posted
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.

  • 2 years later...
Posted

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

  • 11 years later...
Posted
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"????????

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...