Jump to content

Adding layer standard to multiple drawings


Recommended Posts

Posted

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

Posted

Can I ask what the point of having layers within all your drawings that do not contain any entities ?

Posted

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.

Posted

Fair enough, was just wondering - thanks for the update

Posted

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.

  • 2 weeks later...
Posted
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

Posted
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?

Posted

when I apploaded this Do layers error appeara like this

 

"bad argument type: numberp:nil"

Posted

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))

Posted

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!!

Posted
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 ...

Posted
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.

Posted

I try to do it but error appear like Invalid filename

Posted
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. :oops:

Posted

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

Posted
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:

  • 2 weeks later...
Posted

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.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...