Analog for AutoCAD FILTER command

I did not found analog for AutoCAD FILTER command. For example:

How can I select all entities in the drawing hatched with "Anglle" pattern?

How can I select all entities from layer "0" (and only those) in specified Window?

Comments

  • I've found that the Autocad filter command from Autocad R14 works fine in Bricscad.

    IANAL, but I don't think there's any copyright problem.

    The header of most of the lisps and dcls in the Autocad R14 and 2000 support directory has this header:

    FILTER.LSP  Version 0.5
    ;;;
    ;;; Copyright 1991-1998 by Autodesk, Inc.
    ;;;
    ;;; Permission to use, copy, modify, and distribute this software
    ;;; for any purpose and without fee is hereby granted, provided
    ;;; that the above copyright notice appears in all copies and
    ;;; that both that copyright notice and the limited warranty and
    ;;; restricted rights notice below appear in all supporting
    ;;; documentation.

    This seems clear, that anybody can copy, modify and use this lisp in Bricscad.

    If I am wrong, please correct me.

    I know the whole subject of copying commercial work is delicate, even with permissions like this.

    So if any Bricscad people have warnings or problems with using Autocad lisps in Bricscad  (those that have this header, of course),

    I would be grateful for guidance or advice.

     

    In addition, I was also unsuccesful at using the properties bar to filter a selection set (I don't use the "noun/verb" selection option, that is I have PICKFIRST set to off)

  • In v9, BricsCad introduced Quick Select, a full-featured mouse-oriented selection-filtering system which uses the same space as the Properties Bar. You click on the icon in the upper right to switch between Quick Select and Properties.

    I'm very keyboard-oriented, so I've continued using the various small selection filtering commands that I made with lisp. They're easy to make if you don't worry about error trapping and other such refinements, which I don't think are necessary with these since they don't do anything but select and so they can't get into too much trouble.

    I didn't make one that selects all hatches of a particular pattern, but it would be easy to add one that does that. It would be similar to QN, which selects all insertions of a particular block. Here are all the ones I've got so far:

    ; --- QQ displays a list of filtered selection commands
    (defun c:QQ ()
    (command "TextScr")
    (princ "\n Q__ commands select only: ")
    (princ "\n qL ... objects on a specified Layer")
    (princ "\n qC ... objects of a specified Color")
    (princ "\n q7 ... objects of color 7 (white/black)")
    (princ "\n q1 ... objects of color 1 (red)")
    (princ "\n qCB .. objects with Color = Bylayer")
    (princ "\n qY ... objects of a specified linetYpe")
    (princ "\n qW ... objects of a specified lineWeight")
    (princ "\n qZ ... objects of lineweight Zero")
    (princ "\n qB ... objects with lineweight = Bylayer")
    (princ "\n qT ... objects of a specified entity Type")
    (princ "\n qH ... Hatches")
    (princ "\n qS ... objects of a specified text Style")
    (princ "\n qD ... objects of a specified Dimension style")
    (princ "\n qN ... blocks of a specified Name")
    (princ "\n qNX .. all blocks of a specified Name in the entire file")
    (princ "\n qE ... OLE images")
    (princ "\n qEx .. all the OLE images in the entire file")
    (princ "\n qV ... all the viewports in the file (and not the layout tabs as well)")
    (getstring "\n...press any key to continue...")
    (command "GraphScr")
    ) ;;; -----------------------------------------------------

    ;;; --- QL creates a selection set filtered for a specified layer
    ;;; -----------------------------------------------------
    (defun c:QL ()
    (princ " selects only entities on a specified Layer. Available layer names: ")
    (setq Lyrlist (vla-get-Layers (vla-get-activedocument (vlax-get-acad-object))))
    (vlax-for Lyr1 Lyrlist (princ (vla-get-Name Lyr1)) (princ ", ") )
    (setq LA (getstring "\nEnter layer to select:"))
    (setq PR (cons 8 LA))
    (setq ss1 (ssget (list PR)))
    (if ss1 (command "selgrips" ss1 "")
    (progn (princ "\n ...none found.") (princ)) )
    (command "regen")
    (command "selgrips" "p" "")
    ) ;;; -----------------------------------------------------

    ;;; --- QC creates a selection set filtered for a specified color
    ;;; -----------------------------------------------------
    (defun c:QC ()
    (princ " selects only entities with a specified color number, such as: ")
    (princ "\n1=Red 2=Yellow 3=Green 4=Cyan 5=Blue 6=Magenta 7=White 8=Dark 9=Light 256=ByLayer 0=ByBlock.")
    (setq CO (getint " Enter color to select:"))
    (setq PR (cons 62 CO))
    (setq ss1 (ssget (list PR)))
    (if ss1 (command "selgrips" ss1 "")
    (progn (princ "\n ...none found.") (princ)) )
    (command "regen")
    (command "selgrips" "p" "")
    ) ;;; -----------------------------------------------------

    ;;; --- Q7 creates a selection set filtered for color 7 (white/black)
    ;;; -----------------------------------------------------
    (defun c:Q7 ()
    (princ " selects only entities with color 7 (white/black): ")
    (setq PR (cons 62 7))
    (setq ss1 (ssget (list PR)))
    (if ss1 (command "selgrips" ss1 "")
    (progn (princ "\n ...none found.") (princ)) )
    (command "regen")
    (command "selgrips" "p" "")
    ) ;;; -----------------------------------------------------

    ;;; --- Q1 creates a selection set filtered for color 1 (red)
    ;;; -----------------------------------------------------
    (defun c:Q1 ()
    (princ " selects only entities with color 7 (white/black): ")
    (setq PR (cons 62 1))
    (setq ss1 (ssget (list PR)))
    (if ss1 (command "selgrips" ss1 "")
    (progn (princ "\n ...none found.") (princ)) )
    (command "regen")
    (command "selgrips" "p" "")
    ) ;;; -----------------------------------------------------

    ;;; --- QCB creates a selection set filtered for color = Bylayer
    ;;; -----------------------------------------------------
    (defun c:QCB ()
    (princ " selects only entities with color = Bylayer ")
    (setq PR (cons 62 256))
    (setq ss1 (ssget (list PR)))
    (if ss1 (sssetfirst nil ss1)
    (progn (princ "\n ...none found.") (princ)) )
    (command "regen")
    (command "selgrips" "p" "")
    ) ;;; -----------------------------------------------------

    ;;; --- QY creates a selection set filtered for a specified linetype
    ;;; -----------------------------------------------------
    (defun c:QY ()
    (princ " selects only entities of a specified Linetype. Available linetype names: ")
    (setq Ltypelist (vla-get-Linetypes (vla-get-activedocument (vlax-get-acad-object))))
    (vlax-for Ltype1 Ltypelist (princ (vla-get-Name Ltype1)) (princ ", ") )
    (setq LT (getstring "\nEnter linetype to select:"))
    (setq PR (cons 6 LT))
    (setq ss1 (ssget (list PR)))
    (if ss1 (command "selgrips" ss1 "")
    (progn (princ "\n ...none found.") (princ)) )
    (command "regen")
    (command "selgrips" "p" "")
    ) ;;; -----------------------------------------------------

    ;;; --- QW creates a selection set filtered by lineweight
    ;;; -----------------------------------------------------
    (defun c:QW ()
    (princ " selects only entities of a specified Lineweight (specified in hundredths of a mm). ")
    (setq MM (getint "\nEnter lineweight to select, in mm/100:"))
    (setq PR (cons 370 MM))
    (setq ss1 (ssget (list PR)))
    (if ss1 (command "selgrips" ss1 "")
    (progn (princ "\n ...none found.") (princ)) )
    (command "regen")
    (command "selgrips" "p" "")
    ) ;;; -----------------------------------------------------

    ;;; --- QZ creates a selection set filtered for lineweight = zero
    ;;; (because you can't enter 0 as hundredths of a millimeter in QW)
    ;;; -----------------------------------------------------
    (defun c:QZ ()
    (princ " selects only entities whose lineweight is 0.00 mm. ")
    (setq PR (cons 370 0))
    (setq ss1 (ssget (list PR)))
    (if ss1 (command "selgrips" ss1 "")
    (progn (princ "\n ...none found.") (princ)) )
    (command "regen")
    (command "selgrips" "p" "")
    ) ;;; -----------------------------------------------------

    ;;; --- QB creates a selection set filtered for lineweight = bylayer
    ;;; -----------------------------------------------------
    (defun c:QB ()
    (princ " selects only entities whose lineweight is Bylayer. ")
    (setq PR (cons 370 -1))
    (setq ss1 (ssget (list PR)))
    (if ss1 (command "selgrips" ss1 "")
    (progn (princ "\n ...none found.") (princ)) )
    (command "regen")
    (command "selgrips" "p" "")
    ) ;;; -----------------------------------------------------

    ;;; --- QT creates a selection set filtered for a specified entity Type
    ;;; -----------------------------------------------------
    (defun c:QT ()
    (princ " selects only entities of a specified Type. These abbreviations can be used: ")
    (princ "L=Line, P=lwPolyline, Q=Polyline, A=Arc, C=Circle, E=Ellipse, T=Text, M=Mtext, D=Dimension, J=Leader, I=Insert, H=Hatch, S=Solid")
    (setq ET (getstring "\nEnter Entity Type to select:"))
    (if (= ET "l") (setq ET "L")) (if (= ET "L") (setq ET "LINE"))
    (if (= ET "p") (setq ET "P")) (if (= ET "P") (setq ET "LWPOLYLINE"))
    (if (= ET "q") (setq ET "Q")) (if (= ET "Q") (setq ET "POLYLINE"))
    (if (= ET "a") (setq ET "A")) (if (= ET "A") (setq ET "ARC"))
    (if (= ET "c") (setq ET "C")) (if (= ET "C") (setq ET "CIRCLE"))
    (if (= ET "e") (setq ET "E")) (if (= ET "E") (setq ET "ELLIPSE"))
    (if (= ET "t") (setq ET "T")) (if (= ET "T") (setq ET "TEXT"))
    (if (= ET "m") (setq ET "M")) (if (= ET "M") (setq ET "MTEXT"))
    (if (= ET "d") (setq ET "D")) (if (= ET "D") (setq ET "DIMENSION"))
    (if (= ET "j") (setq ET "J")) (if (= ET "J") (setq ET "LEADER"))
    (if (= ET "i") (setq ET "I")) (if (= ET "I") (setq ET "INSERT"))
    (if (= ET "h") (setq ET "H")) (if (= ET "H") (setq ET "HATCH"))
    (if (= ET "s") (setq ET "S")) (if (= ET "S") (setq ET "SOLID"))
    (setq PR (cons 0 ET))
    (setq ss1 (ssget (list PR)))
    (if ss1 (command "selgrips" ss1 "")
    (progn (princ "\n ...none found.") (princ)) )
    (command "regen")
    (command "selgrips" "p" "")
    ) ;;; -----------------------------------------------------

    ;;; --- QH creates a selection set filtered for Hatches only
    ;;; -----------------------------------------------------
    (defun c:QH ()
    (princ " Select HATCH entities: ")
    (setq PR (cons 0 ET))
    (setq ss1 (ssget '((0 . "HATCH"))))
    (if ss1 (command "selgrips" ss1 "")
    (progn (princ "\n ...none found.") (princ)) )
    (command "regen")
    (command "selgrips" "p" "")
    ) ;;; -----------------------------------------------------


    ;;; --- QS creates a selection set filtered by Text Style
    ;;; -----------------------------------------------------
    (defun c:QS ()
    (princ " selects only entities with a specified Text Style. These are the available styles: ")
    (setq TSlist (vla-get-Textstyles (vla-get-activedocument (vlax-get-acad-object))))
    (vlax-for TS1 TSlist (princ (vla-get-Name TS1)) (princ ", ") )
    (setq ST (getstring "\nEnter Style to select:"))
    (setq PR (cons 7 ST))
    (setq ss1 (ssget (list PR)))
    (if ss1 (command "selgrips" ss1 "")
    (progn (princ "\n ...none found.") (princ)) )
    (command "regen")
    (command "selgrips" "p" "")
    ) ;;; -----------------------------------------------------

    ;;; --- QD creates a selection set filtered for a specified Dimension Style
    ;;; -----------------------------------------------------
    (defun c:QD ()
    (princ " selects only entities with a specified Dimension Style. These are the available styles: ")
    (setq DSlist (vla-get-Dimstyles (vla-get-activedocument (vlax-get-acad-object))))
    (vlax-for DS1 DSlist (princ (vla-get-Name DS1)) (princ ", ") )
    (setq DS (getstring "\nEnter DimStyle to select:"))
    (setq PR (cons 3 DS))
    (setq ss1 (ssget (list PR)))
    (if ss1 (command "selgrips" ss1 "")
    (progn (princ "\n ...none found.") (princ)) )
    (command "regen")
    (command "selgrips" "p" "")
    ) ;;; -----------------------------------------------------

    ;;; --- QN creates a selection set filtered for a specified Block Name
    ;;; -----------------------------------------------------
    (defun c:QN ()
    (princ " selects only blocks, and only of a specified Name. Available names: ")
    (setq BlkList (vla-get-Blocks (vla-get-activedocument (vlax-get-acad-object))))
    (vlax-for Blk1 BlkList (princ (vla-get-Name Blk1)) (princ ", ") )
    (setq BL (getstring "\nEnter block name to select:"))
    (setq PR (cons 2 BL))
    (setq ss1 (ssget (list PR)))
    (if ss1 (command "selgrips" ss1 "")
    (progn (princ "\n ...none found.") (princ)) )
    (command "regen")
    (command "selgrips" "p" "")
    ) ;;; -----------------------------------------------------

    ;;; --- QNX selects all insertions of a specified Block in the entire file
    ;;; -----------------------------------------------------
    (defun c:QNX () (sssetfirst nil nil)
    (princ " selects all blocks of a specified name in the entire file. Available names: ")
    (setq BlkList (vla-get-Blocks (vla-get-activedocument (vlax-get-acad-object))))
    (vlax-for Blk1 BlkList (princ (vla-get-Name Blk1)) (princ ", ") )
    (setq BL (getstring "\nEnter block name to select:"))
    (setq PR (cons 2 BL))
    (setq ss1 (ssget "X" (list PR)))
    (if ss1 (command "selgrips" ss1 "")
    (progn (princ "\n ...none found.") (princ)) )
    ) ;;; -----------------------------------------------------

    ;;; --- QE selects all the OLE images that Acad LT is plagued with
    ;;; -----------------------------------------------------
    (defun c:QE () (sssetfirst nil nil)
    (princ " selects only Ole2frame entities, such as LT's OLE images. ")
    (setq PR (cons 0 "OLE2FRAME"))
    (setq ss1 (ssget (list PR)))
    (command "selgrips" ss1 "")
    ) ;;; -----------------------------------------------------

    ;;; --- QEX selects all the OLE images in the entire file
    ;;; -----------------------------------------------------
    (defun c:QEX () (sssetfirst nil nil)
    (princ " ... Selecting all Ole2frame entities, such as LT's OLE images, in the entire file. ")
    (setq PR (cons 0 "OLE2FRAME"))
    (setq ss1 (ssget "X" (list PR)))
    (command "selgrips" ss1 "")
    ) ;;; -----------------------------------------------------

    ;;; --- QV selects all the viewports in a file (and not the layout tabs as well)
    ;;; -----------------------------------------------------
    (defun c:QV () (sssetfirst nil nil)
    (princ " ... Selecting all Viewports in the entire file. ")
    (setq ss1 (ssget "x" '((0 . "VIEWPORT") (-4 . "/=") (69 . 1))))
    (sssetfirst nil ss1)
    ) ;;; -----------------------------------------------------

  • Thank you very much. Quick Select is good enough for me.

  • There is another lisp. It works fine for me under Bricscad V7 : Copy all that

    in a file called "sss.lsp"

     

    ;TIP1356.LSP: SSS.LSP Select Entities by Properties (c)1997,V. Levin

    (defun c:SSS (/ sst p1 p2 et cr crit crkw e ssl)
    (setvar "cmdecho" 0)
    (graphscr)
    (initget "ALL W C")
    (setq sst (getkword "\n Select type of search - Window/Crossing/<ALL> : ")
    et 1
    )
    (if (= sst "ALL") (setq sst nil))
    (if sst
    (progn
    (initget 1)
    (setq p1 (getpoint "\n First corner: "))
    (initget 1)
    (setq p2 (getcorner p1 "\n Second corner: "))
    )
    )
    (while (= et 1)
    (initget "TEXT,T PLINE,PL LINE,L CIRCLE,C BLOCK,B POINT,P ALL ATTDEF,A")
    (setq et (entsel "\n Search for - Text/Attdef/PLine/Line/Circle/Point/Block/<ALL> - PICK: "))
    (if (not et)
    (if (= (getvar "errno") 7)
    (progn
    (setq et 1)
    (prompt "\n Nothing found. Try again...")
    )
    )
    (if (listp et)
    (setq et (cdr (assoc 0 (entget (car et)))))
    )
    )
    )
    (prompt
    (strcat
    "\n Selected: "
    (if et
    (if (= et "INSERT") "BLOCK" et)
    "ALL"
    )
    )
    )
    (setq et (cond
    ((= et "PLINE") "POLYLINE")
    ((= et "BLOCK") "INSERT")
    ((or (not et)(= et "ALL")) "*")
    (T et)
    )
    cr "\n Search under what critiria - "
    crit "Layer/LType/Color/Elevation/<ALL>: "
    crkw "Layer LType Color Elevation ALL"
    crit (cond
    ((= et "INSERT")
    (initget (strcat crkw " Name"))
    (getkword (strcat cr "Name/" crit))
    )
    ((= et "POLYLINE")
    (initget (strcat crkw " Width"))
    (getkword (strcat cr "Width/" crit))
    )
    ((or (= et "TEXT") (= et "ATTDEF"))
    (initget (strcat crkw " STring Style Height Rotation Width"))
    (getkword (strcat cr "Style/STring/Height/Rotation/Width/" crit))
    )
    (T
    (initget crkw)
    (getkword (strcat cr crit))
    )
    )
    crkw (if crit (strcase crit)) crit nil
    )

    (defun LALTCF (x)
    (setq crit "")
    (while (= crit "")
    (setq crit (strcase (getstring (strcat "\n " x " name / <PICK>: "))))
    (if (= crit "")
    (PICKF)
    (if (not
    (or
    (wcmatch crit "*[?#@*]*")
    (tblsearch crkw crit)
    )
    )
    (progn
    (prompt (strcat "\n " x " [" crit "] does not exist. Try again..."))
    (setq crit "")
    )
    )
    )
    )
    )

    (cond
    ((= crkw "LAYER")
    (setq cr 8)
    (LALTCF "Layer")
    )
    ((= crkw "LTYPE")
    (setq cr 6)
    (LALTCF "Linetype")
    )
    ((= crkw "NAME")
    (setq cr 2)
    (LALTCF "Block")
    )
    ((= crkw "STYLE")
    (setq cr 7)
    (LALTCF "Text style")
    )
    ((= crkw "STRING")
    (setq crit (getstring "\n Text string to match: ")
    crit (strcat "*" crit "*") cr 1
    )
    )
    ((= crkw "COLOR")
    (setq cr 62)
    (while (not crit)
    (setq crit (getint "\n Color number [0...256] / <PICK>: "))
    (if crit
    (if (not (<= 0 crit 256))
    (progn
    (prompt "\n ERROR: Value is out of range. Try again...")
    (setq crit nil)
    )
    )
    (PICKF)
    )
    )
    )
    ((= crkw "WIDTH")
    (setq cr 41)
    (while (not crit)
    (initget 4)
    (setq crit (getdist (strcat "\n " et " width / <PICK>: ")))
    (if (not crit) (PICKF))
    )
    )
    ((= crkw "ELEVATION")
    (setq cr 38)
    (while (not crit)
    (setq crit (getdist "\n Elevation / <PICK>: "))
    (if (not crit) (PICKF))
    )
    )
    ((= crkw "HEIGHT")
    (setq cr 40)
    (while (not crit)
    (initget 4)
    (setq crit (getdist "\n Text height / <PICK> : "))
    (if (not crit) (PICKF))
    )
    )
    ((= crkw "ROTATION")
    (setq cr 50)
    (while (not crit)
    (setq crit (getangle "\n Text rotation angle in degrees / <PICK>: "))
    (if (not crit) (PICKF))
    )
    )
    (T (setq cr 8 crit "*"))
    )
    (setq crkw nil)
    (if (member cr '(38 40 41 50))
    (progn
    (initget "= E /= < > <= >=")
    (setq crkw (getkword "\n Range of values - [/=] / [<] / [>] / [<=] / [>=] / <Equal>: "))
    (if (or (not crkw) (= crkw "E")) (setq crkw "="))
    (setq crkw (cons -4 crkw))
    )
    )
    (setq ssl (list (cons cr crit)))
    (if crkw (setq ssl (cons crkw ssl)))
    (setq ssl (cons (cons 0 et) ssl)
    ss (if sst (ssget sst p1 p2 ssl) (ssget "x" ssl))
    )
    (if ss
    (progn
    (command ".select" ss "")
    (setq ssl (sslength ss))
    (prompt (strcat "\n Variable 'ss' defined - " (itoa ssl) " entit" (if (= ssl 1) "y" "ies") " found."))
    )
    (prompt "\n Nothing found.")
    )
    (princ)
    )

    (defun PICKF ( / e)
    (setq e
    (entsel
    (strcat
    "\n Pick "
    (cond
    ((= cr 2) "Block")
    ((member cr '(6 8 38 62)) "Entity")
    (T et)
    )
    (if (= cr 8) " on" " with")
    " desired " crkw ": "
    )
    )
    )
    (if e
    (progn
    (setq e (entget (car e)))
    (if (or
    (member cr '(6 8 38 62))
    (= (cdr (assoc 0 e)) et)
    )
    (progn
    (setq crit (cdr (assoc cr e)))
    (if (not crit)
    (setq crit
    (cond
    ((= cr 6) "BYLAYER")
    ((= cr 62) 256)
    (T 0)
    )
    )
    )
    (prompt
    (strcat
    "\n Selected: "
    (cond
    ((= cr 62)
    (cond
    ((= crit 0) "BYBLOCK")
    ((= crit 256) "BYLAYER")
    (T (strcat "#" (itoa crit)))
    )
    )
    ((numberp crit) (rtos crit))
    (T crit)
    )
    )
    )
    )
    (prompt
    (strcat
    "\n Selected entity is not a"
    (if (= et "ATTDEF") "n " " ")
    (if (= cr 2) "BLOCK" et)
    ". Try again..."
    )
    )
    )
    )
    (prompt "\n Nothing found. Try again...")
    )
    )

    (prompt "\n SSS - Selects entities by properties.")

    (princ)

  • You can watch a video about how to use Quick Select on the Bricscad pages on the Bricsys website.

  • Hello Oleg,

    We have implemented a FREEWARE utility called GT_FILTER in our GeoTools software which works EXACTLY like the AutoCAD FILTER command, but in Bricscad.

    You can check out GeoTools at this URL:

    http://www.coordsys.com/geotools/

    Regards
    Rakesh Rao
    Coordinate Systems, Bangalore

  • hoi

    i tried the lisp from Richard Stas but it didn´t work.

    i´m using the demo version 10.3.16

    is there any working filter available?

     

    thanks a lot.

  • @ Franz Angerer:

    Have you tried the Quick Select?

    The lisp from Richard Stas works just fine. Perhaps you do not use it correctly. Example:

    : sss
     Select type of search - Window/Crossing/<ALL> :
     Search for - Text/Attdef/PLine/Line/Circle/Point/Block/<ALL> - PICK: c

     Selected: CIRCLE
     Search under what critiria - Layer/LType/Color/Elevation/<ALL>:

     Variable 'ss' defined - 13 entities found.
    : m
    Select entities to move: !ss
    <Selection set: c491d08>
    Select entities to move:
    13 found.
    Entities in set: 13
    Select entities to move:

  • SSS works for me, and I like it very much, particularly the option to pick instead of typing. But I don't like that extra step of typing !SS in order to use the selection set. I think the function should leave it selected and gripped, as a pre-selection for whatever command comes next. That can be done adding this at the end of the (defun c:SS) function:
    (sssetfirst nil SS)

This discussion has been closed.