Strange error in layer make code

Hans Lammerts
edited April 2020 in LISP

Sorry, This works!

(mk_layer (list "Volume"))

;; mk_layer by CAB at TheSwamp.org   (Optionnal Arguments by ymg)             ;                                                                          ;
;; Routine to ENTAKE a LAYER entity.                                          ;                                                                            ;
;; If the layer already exist, it will be: thawed                             ;
;;                                         set on                             ;
;;                                         unlocked                           ;
;;                                         set as the current layer.          ;
;;  

(defun mk_layer (argl / ent lay Color ltype)
  (setq lay (car argl) color (cadr argl) ltype (caddr argl))
  (if (tblsearch "LAYER" lay)
    (progn
      (if color (setq ent (entget (tblobjname "LAYER" lay))
                      ent (subst (cons 62 color) (assoc 62 ent) ent)
                      ent (entmod ent)
                )
      )
      (if ltype (setq ent (entget (tblobjname "LAYER" lay))
                      ent (subst (cons 6 ltype) (assoc 6 ent) ent)
                      ent (entmod ent)
                )
      )
      (vl-cmdf "._Layer" "_Thaw" lay "_On" lay "_UnLock" lay "_Set" lay "")
    )
    (entmakex
      (list (cons 0 "LAYER")
            (cons 100 "AcDbSymbolTableRecord")
            (cons 100 "AcDbLayerTableRecord")
            (cons 2 lay)
            (cons 70 0)
            (cons 62 (if (or (null color) (= Color "")) 7 Color))
            (cons 6 (if (or (null ltype) (= ltype "")) "Continuous" ltype))
            (cons 290 1)
            (cons 370 -3)
      )
    )
  )
  (setvar 'CLAYER lay)
)