Thanks for your help as always gents,
I have ended up here with the code structure:
; Change all hatches, solids, & fills to color 19 and send to back of drawing order
; Special thanks to TheSwamp crew: CAB, T.Willey, ronjonp, GDF, & Lee Mac for their guidance, code, and suggestions.
; http://www.theswamp.org/index.php?topic=20391.0;all
(defun c:HATCH19()
;===========================================================================Turn off command line responses
(command "CMDECHO" 0);DO NOT CHANGE THIS LINE
;===========================================================================
(if (setq AllHatch (ssget "_X" '((0 . "HATCH")))) ; begin if
(progn
(setq order "Back") ;sets opt to "_b" (back)
(setq NumHatch (sslength AllHatch))
(setq Count 0)
(princ "\n Total Hatches found : ")
(princ NumHatch)
(repeat NumHatch ;;this cycles number of items
(setq Ename (ssname AllHatch Count)) ;;get entity name
(setq Edata (entget Ename))
(setq HatchLyr (cdr (assoc 8 Edata))) ;;get hatch layer name
(prompt "\n Hatch found!! Please Wait......") ;amusement
;(command "layer" "c" "19" HatchLyr "") ;;change hatch layer color to 19
(command "chprop" AllHatch "" "COLOR" "19" "")
(command "_.draworder" AllHatch "" order)
(setq Count (+ 1 Count))
(princ "\n Count = [ ")
(princ Count)
(princ " ] sorting next of total: ")
(princ NumHatch)
(command "clayer" "0")
)
(prompt "\n Hatch Draw Order sent to back & Layer Made Color 19 !!!")
) ;then
(prompt "\n No Hatch objects found!") ;else
)
(princ)
;===========================================================================
(if (setq AllFILL (ssget "_X" '((0 . "FILL")))) ; begin if
(progn
(setq order "Back") ;sets opt to "_b" (back)
(setq NumFILL (sslength AllFILL))
(setq Count 0)
(princ "\n Total Fills found : ")
(princ NumFILL)
(repeat NumFILL ;;this cycles number of items
(setq Ename (ssname AllFILL Count)) ;;get entity name
(setq Edata (entget Ename))
(setq FILLLyr (cdr (assoc 8 Edata))) ;;get FILL layer name
(prompt "\n FILL found!! Please Wait......") ;amusement
;(command "layer" "c" "19" FILLLyr "") ;;change FILL layer color to 19
(command "chprop" AllFILL "" "COLOR" "19" "")
(command "_.draworder" AllFILL "" order)
(princ "\n Count = [ ")
(princ Count)
(princ " ] sorting next of total: ")
(princ NumFILL)
(command "clayer" "0")
)
(prompt "\n FILL Draw Order sent to back & Layer Made Color 19 !!!")
) ;then
(prompt "\n No FILL objects found!") ;else
)
(princ)
;===========================================================================
(if (setq AllSOLID (ssget "_X" '((0 . "SOLID")))) ; begin if
(progn
(setq order "Back") ;sets opt to "_b" (back)
(setq NumSOLID (sslength AllSOLID))
(setq Count 0)
(princ "\n Total Solids found : ")
(princ NumSOLID)
(repeat NumSOLID ;;this cycles number of items
(setq Ename (ssname AllSOLID Count)) ;;get entity name
(setq Edata (entget Ename))
(setq SOLIDLyr (cdr (assoc 8 Edata))) ;;get SOLID layer name
(prompt "\n SOLID found!! Please Wait......") ;amusement
;(command "layer" "c" "19" SOLIDLyr "") ;;change SOLID layer color to 19
(command "chprop" AllSOLID "" "COLOR" "19" "")
(command "_.draworder" AllSOLID "" order)
(setq Count (+ 1 Count))
(princ "\n Count = [ ")
(princ Count)
(princ " ] sorting next of total: ")
(princ NumSOLID)
(command "clayer" "0")
)
(prompt "\n SOLID Draw Order sent to back & Layer Made Color 19 !!!")
) ;then
(prompt "\n No SOLID objects found!\n") ;else
)
(princ)
;===========================================================================Turn on command line responses
(setvar "CMDECHO" 1); DO NOT CHANGE THIS LINE
;===========================================================================
;===========================================================================
)