For Line entities only, try this [very lightly tested]:
(defun C:Lines45 (/ lines n line ldata ldelta)
(setq lines45 (ssadd)); initially empty
(if (setq lines (ssget "_X" '((0 . "LINE"))))
(repeat (setq n (sslength lines))
(setq
line (ssname lines (setq n (1- n)))
ldata (entget line)
ldelta (mapcar '- (cdr (assoc 10 ldata)) (cdr (assoc 11 ldata)))
); setq
(if
(and
(/= (car ldelta) 0); prevent division by zero [vertical]
(equal (abs (atan (/ (abs (cadr ldelta)) (abs (car ldelta))))) (/ pi 4) 0.01)
; any 45-degree multiple direction within 0.01 radian [about 1/2 degree]
); and
(ssadd line lines45)
); if
); repeat
); if
(sssetfirst nil lines45); select/highlight/grip resulting set
(princ)
); defun
No bells and whistles yet, but see what you think. It leaves the selection in the non-localized 'lines45' variable, to do something with if a variable for that is intended.
Kent Cooper, AIA