Layer creation command not working in Bricscad

The following code isn't working correctly when I attempt to run in Bricscad. Any idea as to why it won't work?

(defun C:LAYERSET ()
(command "redraw")
(SETVAR "REGENMODE" 0)
(COMMAND-S "LAYER""SET""0""")
(COMMAND-S "LAYER""FREEZE""*""")
(prompt "Installing new layers: ")
(terpri)
(prompt " please wait....")
(SAVEMODE
(quote
("CMDECHO" "MENUECHO" "EXPERT")
)
)
(setvar "EXPERT" 0)
(setvar "CMDECHO" 0)
(setvar "MENUECHO" 3)

;********************************************************************************************
(if (= 6 (acet-ui-message "If this is for Prod Layers select YES, Luxury Layers select NO" "Attention" 4))
(setq RFILE (OPEN (strcat lisp "layerset.dat") "r")) ;Opens layerset.dat for read
(setq RFILE (OPEN (strcat lisp "layerset1.dat") "r")) ;Opens layersetluxury.dat for read
)
;********************************************************************************************

(setq LAYER (read-line RFILE))
(setq LINETYPE (read-line RFILE))
(setq COLOR (read-line RFILE))
(while (/= LAYER nil)
(command "LAYER" "m" LAYER "lt" LINETYPE LAYER "c" COLOR LAYER "");if linetype does not exist, then, this will be interrupted in the middle
(command ^C^C)
(setq LAYER (read-line RFILE))
(setq LINETYPE (read-line RFILE))
(setq COLOR (read-line RFILE))
) ;end while
(close RFILE)
(terpri)
(SETVAR "REGENMODE" 1)
(COMMAND "LAYER""THAW""*""")
(RESTMODE)
(prompt "\nAll the Layers, Colors, and Linetypes are installed or have been reinstalled....")
(prin1)
)

Comments

  • What error message do you get?
  • From a readability point of view, when looking for what causes errors.

    (COMMAND-S "LAYER" "SET" "0" "")
    (COMMAND-S "LAYER" "FREEZE" "*" "")

    Maybe avoid using LAYER as variable name use say LAY sometimes using a system name can cause problems. COL LT.

    (command "LAYER" "m" LAYER "lt" LINETYPE LAYER "c" COLOR LAYER "");if linetype does not exist, then, this will be interrupted in the middle
    (command ^C^C)
    A better way is maybe to do a (defun makelayer name col LT / ) so it checks, does layer exits if so do what, does linetype exist if not load or do what. Used this at various times easy copy between code or autoloaded in a master custom defuns for use in any code.