First off, thanks again to you guys for helping. I'm really trying to understand what is happening in the code being presented here so I can learn more about LISP & vba.
Ronjonp, one thing I noticed in the code you last posted, was that there wasn't a 'switch' (feel free to correct me if I'm using incorrect terms here) for whether or not the layer you created in the C:makelayer list was set to plot. I thought it would be good practice for me to try & add this in order to gain some more knowledge about how all this works.
Doing some research, I found that the DXF code for the plotting flag was 290. (I found this from
HERE). By working my way through your code, I simply added a (cons 290 plotflag) to the list you make in
layercreate. Then, down in the
laylist for c:makelayer, I added either a 1 or a 0 (assuming the plot flag is a binary switch - I couldn't confirm this) to represent whether I wanted the layer to plot or not.
Then, where you are actually creating each layer in the
laylist, I see where you have your car's, cadr's, caddr's and cadddr. And you lost me. I can't seem to find out/figure out how to add the fourth object in the laylist to the layer creation.
Can you give me some hints as to how I might add the fourth (maybe even fifth - lineweights) object type?
Here's where I'm at so far:
;-------------------------------------------------------------------------------------------------
(defun unlockthawlayers (/)
(vlax-map-collection
(vla-get-layers
(vla-get-activedocument (vlax-get-acad-object))
)
'(lambda (x)
(cond ((eq (vla-get-lock x) :vlax-true)
(setq lock (cons x lock))
(vla-put-lock x :vlax-false)
)
)
(cond ((eq (vla-get-freeze x) :vlax-true)
(setq freeze (cons x freeze))
(vla-put-freeze x :vlax-false)
)
)
)
)
(princ)
)
;-------------------------------------------------------------------------------------------------
(defun relockfreezelayers (/)
(if lock
(mapcar '(lambda (x)
(vla-put-lock x :vlax-true)
)
lock
)
)
(if freeze
(mapcar '(lambda (x)
(vl-catch-all-apply 'vla-put-freeze (list x :vlax-true))
)
freeze
)
)
(setq lock nil)
(setq freeze nil)
(princ)
)
;-------------------------------------------------------------------------------------------------
(defun layercreate (layname color linetype desc / lyr)
(if (not (tblobjname "ltype" linetype))
(setq linetype "continuous")
)
(if (tblsearch "layer" layname)
(progn
(setq lyr (vlax-ename->vla-object (tblobjname "layer" layname)))
(vla-put-color lyr color)
(vla-put-linetype lyr linetype)
)
(setq lyr (vlax-ename->vla-object
(entmakex
(list (cons 0 "LAYER")
(cons 100 "AcDbSymbolTableRecord")
(cons 100 "AcDbLayerTableRecord")
(cons 70 0)
(cons 2 layname)
(cons 62 color)
(cons 6 linetype)
(cons 290 plotflag)
)
)
)
)
)
(vla-put-description lyr desc)
(princ)
)
;-------------------------------------------------------------------------------------------------
(defun C:MakeLAYER (/ CCL LAYLIST)
(unlockthawlayers)
(setvar "cmdecho" 0)
(setq ccl (getvar "clayer"))
(setq laylist '(("TEST LAYER 01"
3
"continous"
"TESTING LAYER 01"
1
)
("TEST LAYER 02"
1
"DASHED"
"TEST LAYER 02"
0
)
("TEST LAYER 03"
51
"CENTER"
"Testing layer 03"
0
)
)
)
(foreach lyr laylist
(layercreate (car lyr) (cadr lyr) (caddr lyr) (cadddr lyr) (cadadr lyr))
(princ (strcat "\n Layer - " (car lyr) " created..."))
)
(setvar "clayer" ccl)
(relockfreezelayers)
(princ)
)
;-------------------------------------------------------------------------------------------------