Bill Tillman Posted February 28, 2020 Posted February 28, 2020 (edited) (defun c:zlay () ;;; zLayerName zColor zLineType zLineWt zPlot (addNewLayer "ArchBldg01" 251 "Continuous" 0.00 1) (addNewLayer "ArchBldg02" 252 "Continuous" 0.00 1) (addNewLayer "Beyond" 251 "Continuous" 0.00 1) (addNewLayer "Bolts" 8 "Continuous" "Default" 1) (addNewLayer "CenterLines" 44 "Center" 0.00 1) (addNewLayer "ConLines" 6 "Phantom" "Default" 0) (addNewLayer "Dim1" 40 "Continuous" "Default" 1) (addNewLayer "Dim2" 40 "Continuous" "Default" 1) (addNewLayer "Grabrails" 7 "Continuous" "Default" 1) (addNewLayer "Handrails" 72 "Continuous" "Default" 1) (addNewLayer "HiddenLines" 44 "Hidden" 0.00 1) (addNewLayer "MiscSteel" 50 "Continuous" "Default" 1) (addNewLayer "Pickets" 72 "Continuous" "Default" 1) (addNewLayer "Stringers" 10 "Continuous" "Default" 1) (addNewLayer "Text1" 40 "Continuous" "Default" 1) (addNewLayer "Text2" 40 "Continuous" "Default" 1) (addNewLayer "Landing Steel" 50 "Continuous" "Default" 1) (addNewLayer "Viewports" 8 "Continuous" "Default" 1) (princ) ) (defun addNewLayer (zLayerName zColor zLineType zLineWt zPlot / aNewLayer) (setq acadobject (vlax-get-Acad-Object)) (setq activedocument (vla-get-activedocument acadobject)) (setq LayerTable (vla-get-layers activedocument)) (setq aNewLayer (vla-add LayerTable zLayerName)) (vla-put-color aNewLayer zColor) (vla-put-LineWeight aNewLayer zLineWt) (if (= zPlot 0) (vla-put-plottable aNewLayer :vlax-false) (vla-put-plottable aNewLayer :vlax-true) ) (vla-put-linetype aNewLayer zLineType) (princ) ) I'm using the above routine to add new layers to a drawing file. It almost works but when I use the word "Default" for setting the line weight I get the following message". When it runs it creates the layer named "Bolts" which uses the key "Default" for the lineweight. But then the next couple of layers fail to get created. A few of the other layers get created but out of the 18 layers I want this code to create I only end up with 7 of them. The layer MiscSteel gets created using the key "Default" for the line weight but then that's all that works. ??? Quote ; error: lisp value has no coercion to VARIANT with this type: "Default" Edited February 28, 2020 by Bill Tillman Quote
dlanorh Posted February 28, 2020 Posted February 28, 2020 Replace "Default" with acLnWtByLwDefault (no quotes as it is an autocad constant) Replace 0.00 with acLnWt000 (again no quotes as it is an autocad constant) Quote
Lee Mac Posted February 28, 2020 Posted February 28, 2020 Read the documentation for the lineweight property. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.