tarnoki Posted December 17, 2009 Posted December 17, 2009 I have over 300+ drawings that need a standard cad layer set applied. We have developed a cad standard that includes 24 total layers with defined layer name, description, on/off status, colors, and linetypes. The 300+ drawings currently only contain a subset of these 24 layers only where objects reside. (eg some drawings have A-FURN layer while others do not). The end goal is for all 300+ drawings to have the same 24 layer names. I'm not a lisp expert but do have multi-batch installed for other printing routines. Is there a simple routine, lisp or multi-batch command I can run that basically says... - run against these specific 300 drawings file names (eg A1.dwg, B1.dwg) - if layer names 1-24 does not exist in DWG, add layers names 1-24 to each DWG Thanks, Steve Quote
NBC Posted December 17, 2009 Posted December 17, 2009 Can I ask what the point of having layers within all your drawings that do not contain any entities ? Quote
tarnoki Posted December 17, 2009 Author Posted December 17, 2009 There are multiple reasons but the strongest is that we have been directed to have all of our drawings comply 100% with our cad standard regardless of entities existance. Quote
NBC Posted December 17, 2009 Posted December 17, 2009 Fair enough, was just wondering - thanks for the update Quote
tarnoki Posted December 17, 2009 Author Posted December 17, 2009 A "simple" mandate with 300 legs. Quote
Lee Mac Posted December 17, 2009 Posted December 17, 2009 I wrote this a while back, it may help you: (defun c:DoLayers (/ MkLay LtLoad cm) (vl-load-com) (setq cm (getvar "CMDECHO")) (setvar "CMDECHO" 0) (vl-cmdf "_.-purge" "_LA" "*" "_N") (setq *doc* (vla-get-ActiveDocument (vlax-get-acad-object))) (defun MkLay (Nme Col lTyp lWgt Plt / lay) (setq lay (vla-add (vla-get-layers *doc*) Nme)) (and Col (vla-put-Color lay Col)) (and lTyp (lTload lTyp) (vla-put-Linetype lay lTyp)) (and lWgt (vla-put-LineWeight lay (eval (read (strcat "acLnWt" lWgt))))) (and (not Plt) (vla-put-Plottable lay :vlax-false))) (defun lTload (lTyp) (or (tblsearch "LTYPE" lTyp) (vla-load (vla-get-Linetypes *doc*) lTyp "acad.lin")) t) (mapcar 'MkLay '( "CEN" "DIMS" "HAT" "HID" "LOGO" "OBJ" "PAPER" "PHAN" "TITLE" "TXT") ; Name [str] '( 6 1 3 4 176 2 5 6 176 7 ) ; Colours [int] '("CENTER" nil nil "HIDDEN" nil nil "PHANTOM" "PHANTOM" nil nil ) ; LineType [str] '( "018" "018" "018" "015" "009" "040" nil "018" nil nil ) ; LineWeight [str] 0.18 = "018" '( T T T T T T nil T T T )) ; Plottable (T or nil) (setvar "CMDECHO" cm) (princ)) Just alter the "table" as necessary. Quote
otil Posted December 29, 2009 Posted December 29, 2009 I wrote this a while back, it may help you: (defun c:DoLayers (/ MkLay LtLoad cm) (vl-load-com) (setq cm (getvar "CMDECHO")) (setvar "CMDECHO" 0) (vl-cmdf "_.-purge" "_LA" "*" "_N") (setq *doc* (vla-get-ActiveDocument (vlax-get-acad-object))) (defun MkLay (Nme Col lTyp lWgt Plt / lay) (setq lay (vla-add (vla-get-layers *doc*) Nme)) (and Col (vla-put-Color lay Col)) (and lTyp (lTload lTyp) (vla-put-Linetype lay lTyp)) (and lWgt (vla-put-LineWeight lay (eval (read (strcat "acLnWt" lWgt))))) (and (not Plt) (vla-put-Plottable lay :vlax-false))) (defun lTload (lTyp) (or (tblsearch "LTYPE" lTyp) (vla-load (vla-get-Linetypes *doc*) lTyp "acad.lin")) t) (mapcar 'MkLay '( "CEN" "DIMS" "HAT" "HID" "LOGO" "OBJ" "PAPER" "PHAN" "TITLE" "TXT") ; Name [str] '( 6 1 3 4 176 2 5 6 176 7 ) ; Colours [int] '("CENTER" nil nil "HIDDEN" nil nil "PHANTOM" "PHANTOM" nil nil ) ; LineType [str] '( "018" "018" "018" "015" "009" "040" nil "018" nil nil ) ; LineWeight [str] 0.18 = "018" '( T T T T T T nil T T T )) ; Plottable (T or nil) (setvar "CMDECHO" cm) (princ)) Just alter the "table" as necessary. I have the same problem how to copy layer to a multiple drawing just one command, I try to appload Dolayers in my systems but it appeared bad arguments Quote
Lee Mac Posted December 29, 2009 Posted December 29, 2009 I have the same problem how to copy layer to a multiple drawing just one command, I try to appload Dolayers in my systems but it appeared bad arguments It seems to work fine for me. What argument list are you feeding it? Quote
otil Posted December 30, 2009 Posted December 30, 2009 when I apploaded this Do layers error appeara like this "bad argument type: numberp:nil" Quote
Lee Mac Posted December 30, 2009 Posted December 30, 2009 Are you sure you are copying the whole code? Quote
otil Posted December 31, 2009 Posted December 31, 2009 yes! I paste it the lisp defun c:DoLayers (/ MkLay LtLoad cm) (vl-load-com) (setq cm (getvar CMDECHO")) (setvar "CMDECHO" 0) (vl-cmdf "_.-purge" "_LA" "*" "_N") (setq *doc* (vla-get-ActiveDocument (vlax-get-acad-object))) (defun MkLay (Nme Col lTyp lWgt Plt / lay) (setq lay (vla-add (vla-get-layers *doc*) Nme)) (and Col (vla-put-Color lay Col)) (and lTyp (lTload lTyp) (vla-put-Linetype lay lTyp)) (and lWgt (vla-put-LineWeight lay (eval (read (strcat "acLnWt" lWgt)))) (and (not Plt) (vla-put-Plottable lay :vlax-false))) (defun lTload (lTyp) (or (tblsearch "LTYPE" lTyp) (vla-load (vla-get-Linetypes *doc*) lTyp "acad.lin")) t) (mapcar 'MkLay '( "CEN" "DIMS" "HAT" "HID" "LOGO" "OBJ" "PAPER" "PHAN" "TITLE" "TXT") ; Name [str] '( 6 1 3 4 176 2 5 6 176 7 ) ; Colours [int] '("CENTER" nil nil "HIDDEN" nil nil "PHANTOM" "PHANTOM" nil nil ) ; LineType [str] '( "018" "018" "018" "015" "009" "040" nil "018" nil nil ) ; LineWeight [str] 0.18 = "018" '( T T T T T T nil T T T )) ; Plottable (T or nil) (setvar "CMDECHO" cm) (princ)) Quote
Lee Mac Posted December 31, 2009 Posted December 31, 2009 Looks to me like you are missing the first bracket... Quote
otil Posted January 3, 2010 Posted January 3, 2010 Hi Mac lee, We really thanks for you Kindness to response, Thanks God do layers is working now, But it would be great if there an options to work in batch drawings. anyway thank you very very much, Do not be tired to helping me!! Quote
Lee Mac Posted January 3, 2010 Posted January 3, 2010 Hi Mac lee, We really thanks for you Kindness to response,Thanks God do layers is working now, But it would be great if there an options to work in batch drawings. anyway thank you very very much, Do not be tired to helping me!! Not a problem You could call it using a Script - Something like: open "C:/Users/Lee Mac/Documents/Drawing1.dwg" (c:DoLayers) save close open ... Quote
DVDM Posted January 4, 2010 Posted January 4, 2010 Hi Mac lee, We really thanks for you Kindness to response,Thanks God do layers is working now, But it would be great if there an options to work in batch drawings. anyway thank you very very much, Do not be tired to helping me!! Otil, look into a program called Multi Batch: http://www.multi-batch.com/ Makes batch processing autocad files easy. Quote
otil Posted January 6, 2010 Posted January 6, 2010 I try to do it but error appear like Invalid filename Quote
Lee Mac Posted January 6, 2010 Posted January 6, 2010 I try to do it but error appear like Invalid filename I updated my post above, I think I was wrong to use double backslashes. Quote
otil Posted January 7, 2010 Posted January 7, 2010 open "C:/Users/Lee Mac/My Documents/SC-27-A3J-0-00211-0002.dwg" (c:DoLayers) save close open ... I tried again to test this this scr to one drawing (see above script) error message : " cannot find the specified drawing file. Please verify that the file name exists" What was the problem on that script. P Quote
Lee Mac Posted January 7, 2010 Posted January 7, 2010 open "C:/Users/Lee Mac/My Documents/SC-27-A3J-0-00211-0002.dwg" (c:DoLayers) save close open ... What was the problem on that script. Well, take a look at the filepath you are using, and you tell me :wink: Quote
tarnoki Posted January 20, 2010 Author Posted January 20, 2010 I solved this by creating a template dwg file with all the layers I needed. Then I turned on/off the layers I want for final viewing as a layer state and exported it to a file. Then I ran the Multi-Batch software invoking the ootb 'Insert LayerState' routine. Worked great. The routine inserted layers not originally in my files and turned them on/off in each drawing. 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.