I've got a lisp borrowed from Tim Spangler on the Catalyst forums that automagically creates layers from a list, but I can't get it to work (error: bad argument type: VLA-OBJECT nil). I'm not very good at vl at all, so I could just be going about it wrong; maybe someone here can help me.
Thanks a bunch!
Here is the original code:
;;; ------------ LAYER CREATION ROUINE
(defun CREATE_LAYER (Layer Descpition Linetype Thickness Color Plot / VLA-Obj)
;;; ------------ CREATE A LIST FOR ENTMAKE
(entmakex
(list
(cons 0 "LAYER")
(cons 100 "AcDbSymbolTableRecord")
(cons 100 "AcDbLayerTableRecord")
(cons 70 0)
(cons 2 Layer)
(cons 62 (atoi Color))
(cons 6 Linetype)
(cons 370 (atoi Thickness))
(cons 290 (atoi Plot))
)
)
;; Create layer description
(if (>= (atof (getvar "acadver")) 16.1)
(progn
(setq VLA-Obj (vla-Add LayersCol Layer))
(vla-Put-Description VLA-Obj Descpition)
(vlax-release-object VLA-Obj)
)
)
)
With this as the call:
(CREATE_LAYER "purlin" "description" "continuous" "thickness" "color" "plot")
Here's how I've modified it:
;;; Layer Creation Routine
(defun CreateLayers (Layer Descpition Linetype Thickness Color Plot / VLA-Obj)
;;; ------------ CREATE A LIST FOR ENTMAKE
(entmakex
(list
(cons 0 "LAYER")
(cons 100 "AcDbSymbolTableRecord")
(cons 100 "AcDbLayerTableRecord")
(cons 70 0)
(cons 2 Layer)
(cons 62 (atoi Color))
(cons 6 Linetype)
(cons 370 (atoi Thickness))
(cons 290 (atoi Plot))
)
)
;; Create layer description
(if (>= (atof (getvar "acadver")) 16.1)
(progn
(setq VLA-Obj (vla-Add LayersCol Layer))
(vla-Put-Description VLA-Obj Descpition)
(vlax-release-object VLA-Obj)
)
)
)
;;; The call:
;;; (CreateLayers "layer-name" "description" "continuous" "thickness (05=.05,-3 default)" "color" "plot (0/1)")
(CreateLayers "TAGS" "description" "continuous" "-3" "3" "1")
(CreateLayers "COPPER" "description" "continuous" "-3" "30" "1")
(CreateLayers "M-ACCY" "description" "continuous" "-3" "4" "1")
(CreateLayers "M-EQUIP" "description" "continuous" "-3" "6" "1")
(CreateLayers "M-NOTES" "description" "continuous" "-3" "1" "1")
(CreateLayers "M-PIPING" "description" "continuous" "-3" "7" "1")
(CreateLayers "M-PIPING-HG" "description" "continuous" "-3" "2" "1")
(CreateLayers "M-PIPING-HR" "description" "continuous" "-3" "4" "1")
(CreateLayers "M-PIPING-INS-1-0" "description" "TRACKS" "-3" "5" "1")
(CreateLayers "M-PIPING-INS-1-2" "description" "ZIGZAG" "-3" "7" "1")
(CreateLayers "M-PIPING-INS-3-4" "description" "continuous" "-3" "5" "1")
(CreateLayers "M-PIPING-LIQ" "description" "continuous" "-3" "7" "1")
(CreateLayers "M-PIPING-OIL" "description" "continuous" "-3" "2" "1")
(CreateLayers "M-PIPING-SUCT" "description" "continuous" "-3" "5" "1")
(CreateLayers "M-SOW" "description" "DASHED2" "-3" "15" "1")
(CreateLayers "M-SYMB" "description" "continuous" "-3" "81" "1")
(CreateLayers "M-VALVE" "description" "continuous" "-3" "3" "1")