Hello,
This routine is what I use to create layers in a certain way.
It works perfectly. There is only one thing that bothers me.
Lets say I open a new drawing: the current layer is "0" and the colour is "bylayer". I manually set the color to "Red".
Then, at any time, whenever I call the createlayer function and there is a layer created, ie. "Test" with colour 33 the coulor is created but not set to 33. It stays "Red" as I set manually...
How to overrule? That whatever layer is set / created: allways set the colour to the disired valu, in this example I want it to be "33".
With Lee's help this routine was created !!
Tnx in advance.
Marco.
By the way: ";; Another Option for Layer Creation to Consider:"
Does it matter to have it as shown? I mean both and not one specific?
Maybe conflict or so?
(defun c:createlayer (/ ltname layname laycol cmdold lay)
(vl-load-com)
(setq ltname (getstring "\nPlease enter the name of the linetype: ")
layname (getstring "\nPlease enter the name of the layer: ")
laycol (getint "\nPlease enter the colour of the layer: ")
layplot (getstring "\nDo you want the layer to be <Plot> or <Non plot>: ")
cmdold (getvar "CMDECHO"))
(setvar "CMDECHO" 0)
;; Loading Linetype ~ Another option to consider:
(if (not (tblsearch "LTYPE" ltname))
(vla-load
(vla-get-Linetypes
(vla-get-ActiveDocument
(vlax-get-acad-object))) ltname "acadiso.lin"))
;; Layer Checking & Creation
(if (not (tblsearch "LAYER" layname))
(command "_.-layer" "_M" layname "_L" ltname layname "_C" laycol layname "_P" layplot "" "")
(setvar "CLAYER" layname))
;; Another Option for Layer Creation to Consider:
(if (not (tblsearch "LAYER" layname))
(progn
(setq lay (vla-add
(vla-get-layers
(vla-get-ActiveDocument
(vlax-get-acad-object))) layname))
(vla-put-color lay laycol)
(vla-put-linetype lay ltname)))
(setvar "CLAYER" layname)
;; Reset CMDECHO
(setvar "CMDECHO" cmdold)
(princ))