As far as readability goes:
(setq cmd (getvar "cmdecho")
clay (getvar "clayer")
ltype (getvar "celtype")
scal (getvar "ltscale")
pwidth (getvar "plinewid")
)
(setvar "cmdecho" 0)
(setvar "clayer" "0")
(setvar "celtype" "bylayer")
(setvar "ltscale" 1.0)
(setvar "plinewid" 0)
That, either with the setq's in place or as I have written, would make it more readable. It won't affect how the function runs though.
I still don't think you need to set the layer if it exists or create it if it doesn't. Let's say someone turned the layer color to 3 and your standards say it should be 6. If you just did (command ".layer" "m" "612" "c" "6" "" ""), you could forgo the if statement, the tablesearch and the setvar. Plus, you'd be able to enforce the color standard you seem to be implying. So really, you're just adding more code and making it less readable.
it draws the line on the correct layer and the correct color but it draws the line on the "BYLAYER".
What are you saying here? Do you want the object color to be different than the layer color? If not, it should be bylayer, if so, you need to set the color property to what you want it to be, but unless you're changing the color of a block, you normally wouldn't do that.