(Defun C:FILTER ()
  (Setvar "Cmdecho" 0)
  (Setq ENTITY nil LAYER nil COLOR nil FLTRLIST nil)
  (Menu)
  (Princ)
)

(Defun Menu ()
  (Textscr)
  (Repeat 6 (Terpri))
  (Princ "                 FILTER  MENUE\n")
  (Terpri)
  (Princ "             A = Filter auf Objekttyp\n")
  (Princ "             B = Filter auf Layername\n")
  (Princ "             C = Filter auf Farbnummer\n")
  (Princ "             X = Gewaehlte Objekte bearbeiten\n")
  (Princ "            XX = Ende FILTER\n")
  (Repeat 7 (Terpri))
  (Initget "A B C X XX")
  (Setq LETR (Getkword "\n=======>>Auswahlbuchstaben eingeben: "))
  (Cond
    ((= LETR "A")
      (Initget (strcat "LINE POINT CIRCLE ARC SOLID TEXT "
                       "SHAPE INSERT POLYLINE TRACE 3DFACE DIMENSION"))
      (Setq ENTITY (Getkword "\nObjekttyp eingeben: "))
      (Setq ENTITY (Cons 0 (Eval ENTITY)))
      (Menu)
    )
    ((= LETR "B")
      (Setq LAYER (Strcase (Getstring "\nLayername eingeben: ")))
      (Setq LAYER (Cons 8 (Eval LAYER)))
      (Menu)
    )
    ((= LETR "C")
      (Setq COLOR (Getreal "\nFarbnummer eingeben: "))
      (Setq COLOR (Cons 62 (Eval COLOR)))
      (Menu)
    )
    ((= LETR "XX") (Ender))
    ((= LETR "X") (Build))
    ((/= LETR nil) (Menu))
  )
)

(Defun Ender ()
  (Graphscr)
  (Command)
)

(Defun Build ()
  (If (/= ENTITY nil) (Setq FLTRLIST (List (Eval 'ENTITY))))
  (If
    (And LAYER FLTRLIST)
      (Setq FLTRLIST (Cons LAYER FLTRLIST))
  )
  (If (And (= FLTRLIST nil) LAYER) (Setq FLTRLIST (List (Eval 'LAYER))))
  (If
    (And COLOR FLTRLIST) 
      (Setq FLTRLIST (Cons COLOR FLTRLIST))
  )
  (If (And COLOR (= FLTRLIST nil)) (Setq FLTRLIST (List (Eval 'COLOR))))
  (Action)
)

(Defun Action ()
  (Textscr)
  (Repeat 6 (Terpri))
  (Princ "  Was soll mit den gewaehlten Objekten geschehen? \n")
  (Terpri)
  (Princ "             A = Loeschen\n")
  (Princ "             B = Schieben\n")
  (Princ "             C = Kopieren\n")
  (Princ "             D = Layer aendern\n")
  (Princ "             E = Farbe aendern\n")
  (Princ "             F = Zaehlen\n")
  (Princ "            XX = Lediglich auswaehlen\n")
  (Repeat 6 (Terpri))
  (Initget "A B C D E F XX")
  (Setq LETR (Getkword "\n=======>>Auswahlbuchstaben eingeben: "))
  (If (= LETR "A") (Command "LOESCHEN" (Ssget "X" FLTRLIST)))
  (If (= LETR "B") (Command "SCHIEBEN" (Ssget "X" FLTRLIST)))
  (If (= LETR "C") (Command "KOPIEREN" (Ssget "X" FLTRLIST)))
  (If (= LETR "D") (Command "AENDERN" (Ssget "X" FLTRLIST) "" "EI" "LA"))
  (If (= LETR "E") (Command "AENDERN" (Ssget "X" FLTRLIST) "" "EI" "FA"))
  (If
    (= LETR "F")
      (Progn
        (Princ "\nEs wurden ")
        (Princ (Sslength (Ssget "X" FLTRLIST)))
        (Princ " Objekte ausgewaehlt.")
        (Princ)
      )
  )
  (If (= LETR "XX") (Ssget "X" FLTRLIST))
)

