Line 3:- Check and see if layer "612" exist
It certainly does - but that's all it does. It stands alone as a test condition and is therefore not used for anything. To do something with it, use it as a condition for an IF expression:
(cond ((= ans "Three")
(if (not (tblsearch "layer" "612"))
(command ".layer" "make" "612" "")
(setvar "clayer" "612")
)
(setvar "celtype" "Three"))
)
This code says:
- if ans is equal to "Three" then do this:
- - if layer 612 does not exist then
- - - make layer 612 (create and set active)
- - otherwise
- - - set layer 612 active
- - set current ltype to "Three"
As Daron pointed out, there's no need to test if the layer exists before using "Make", but this is what you'd do if following Se7en's advice. I think in this case where the end result is setting the layer active, that I would follow Daron's advice. Se7en does have a point about the readability and logic of the code, though.
The real effort should be to see if the linetype exists. Because linetypes are dependent on external files and there are no easy way to simply create it (like a layer), there is a very real chance that it will crash if it doesn't exist.