smorales02 Posted January 21, 2009 Posted January 21, 2009 Happy Hump Day guys and gals, I have a list of layers that need to be used for one of our projects but are not currently set up in any template file or anything (basically a hard copy of layer names) Is there a way of typing them up in Word or Notepad than importing them into ACAD. Im sure i can right a script that I can run at the beginning of a drawing that will create them, but I was just wondering if anyone knew of any other way of doing it. Quote
Lee Mac Posted January 21, 2009 Posted January 21, 2009 If you would like the Layer names to be read from a text file (created in Notepad) this LISP should do the trick: (defun c:laymake (/ file ofile lay) (if (setq file (getfiled "Select a Text File with Layers" "C:\\" "txt" ) (progn (setvar "cmdecho" 0) (setq ofile (open file "r")) (while (setq lay (read-line ofile)) (command "-layer" "m" lay "")) (close ofile) (setvar "cmdecho" 1)) (princ "\n<!> No File Selected <!> ")) (princ)) Quote
smorales02 Posted January 21, 2009 Author Posted January 21, 2009 Thanks for the Reply... Any specific way the layer names have to been entered into notepad? Quote
Lee Mac Posted January 21, 2009 Posted January 21, 2009 One more thing: If you want to change the default search path for the file prompt, change the highlighted text: (defun c:laymake (/ file ofile lay) (if (setq file (getfiled "Select a Text File with Layers" "[b][color=Red]C:\\[/color][/b]" "txt" ) (progn (setvar "cmdecho" 0) (setq ofile (open file "r")) (while (setq lay (read-line ofile)) (command "-layer" "m" lay "")) (close ofile) (setvar "cmdecho" 1)) (princ "\n<!> No File Selected <!> ")) (princ)) But make sure that you specify the filepath like the following example: "C:\\Users\\Lee Mac\\Folder1\\Folder\\" Using double backslashes and ending with a double backslash when you reach the folder level you require. Quote
BIGAL Posted January 22, 2009 Posted January 22, 2009 You can also add colour and linetype if you want eg layer1 3 dashed layer2 4 dashed2 You need to read a line but now have layer colour linetype variables, the simplest way is to search for 1 space between the answers. I will try and find the code I have it somewhere (command "layer" "n" lay_name "c" lay_colour "l" l_type "") Quote
BIGAL Posted January 22, 2009 Posted January 22, 2009 Found it need to do 3 times for name col Lt (defun lay_name () (setq ans "") (setq char_found "") (while (/= x y) (setq char_found (substr new_line x 1)) (setq x (+ x 1)) ; (if (= char_found (chr 92)) (if (= char_found " ") (setq x y) (setq ans (strcat ans char_found)) ) ) ) (lay_name) (setq lay_name ans) (setq ans nil) (lay_name) (setq lay_col ans) (setq ans nil) (lay_name) (setq lay_Ltype ans) Quote
dbroada Posted January 22, 2009 Posted January 22, 2009 I used to do this sort of thing with a script file created in excel. First type your layer names one row at a time then insert columns and fill down to add the rest of the script. Finally save the excel file as a text. End up with something like... LAYER M NewLayer1 LAYER M NewLayer2 This is all off the top of my head so the syntax is probably wrong but you should get the idea. Obviously not as elegant as the solutions posted by Lee & Al but given as a quick & dirty method of repeating tasks for trivial little problems. Quote
Lee Mac Posted January 22, 2009 Posted January 22, 2009 Nice extension on my orignal post BigAL, I like it. Quote
smorales02 Posted January 22, 2009 Author Posted January 22, 2009 I will be giving these a try and will see how it goes... Thanks for the replies guys Quote
Sam Pawar Posted June 26, 2012 Posted June 26, 2012 Hi, I cant get this lisp to work with AutoCAD Civil 3D 2013, but it works fine on 2012. Is it easy to update this lisp? Thanks:) Sam 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.