Jump to content

Changing Layer colors for hundreds of drawings


Recommended Posts

Posted

Hi all,

 

I'm just starting to learn how useful AutoLISP can be and I want to ask if what I am trying to do is possible...

I have about 500 separate CAD drawings, all with the same layer names. Layer A, lets say, is currently yellow, I need it to be magenta.

 

I'm thinking I need to write something that will open each drawing, change the layer color, save it, then close the drawing? Is this a good direction to head?

This could just be done with a big long script right?

 

Thanks for the help, I'm going to keep researching about how to create autoLISP routines to edit this large database of drawings since it REALLY seems to beat the idea of editing each of them individually!

  • Replies 30
  • Created
  • Last Reply

Top Posters In This Topic

  • DreadPirateRoberts

    11

  • Lee Mac

    5

  • irneb

    5

  • ReMark

    4

Top Posters In This Topic

Posted Images

Posted

Sounds like a job (batch process a group of drawings) a script could handle.

Posted

Hi there,

 

So here is the script I'm trying to run:

 

-layer color magenta Guidelines  qsave 

 

which changes the layer color of the layer 'Guidelines' to magenta. This works fine with the command 'scr' on an individual drawing that I have open in AutoCAD. I wanted to use ScriptPro 2.0 to select the 500+ drawings I want this to act on but....ScriptPro doesnt seem to do anything.

I run ScriptPro and it opens up a blank AutoCAD program, but the drawings are unchanged.

I tried not using ScriptPro, but I am having trouble writing the script that opens up an existing drawing. It keeps trying to open the file, but a popup window says something like '...please verify the file exists'. Even though I am pretty sure I have the path correct.

 

Any idea what I'm doing wrong?

Posted

That is the extent of your script?

 

No command to open a drawing, or save and close the drawing?

Posted

I don't use ScriptPro so couldn't advise you in that respect, but to offer an alternative, here is an old program of mine that may help you:

 

http://lee-mac.com/scriptwriter.html

 

Excuse the terrible coding, the program needs a major overhaul!

Posted

Yup, that's the extent of my script. I left out the open and close portions because I thought ScriptPro handled those portions. But I can put in the open and close portions like this:

open "Drawing1" -layer color magenta Guidelines  qsave close
open "Drawing2" -layer color red Guidelines  qsave close 

 

But at this point I'm too lazy to copy the file paths for each drawing (LOTS of sub-directories there...) in place of "Drawing#". Which is why ScriptPro sounded so appealing. I'd love to figure this out so I can use it again in other situations. There aren't too many settings to tweak in ScriptPro, so I'm confused why its not working.

 

Lee Mac, I can give your program a try when I get home tonight (they are pretty picky about what I can download here at work).

 

Thanks for the help

Posted
Lee Mac, I can give your program a try when I get home tonight (they are pretty picky about what I can download here at work).

 

Thanks for the help

 

No worries, let me know how you get on :)

Posted

You don't have to copy the file path for each and every drawing. It's a batch file. As long as you point it to the right folder it will batch process the contents of the entire folder.

Posted
You don't have to copy the file path for each and every drawing. It's a batch file. As long as you point it to the right folder it will batch process the contents of the entire folder.

 

However, to my knowledge, the problem with using a Batch file to process drawings is that it will unnecessarily close and re-open the AutoCAD Application for every drawing processed; whereas, using only a Script to process drawings enables much faster processing since drawings can be opened and closed in a single instance of the Application.

Posted

That is a good point Lee. I should have been more precise in what I was saying. Thanks.

Posted

Perhaps you could use STANDARDS and a .dws to make such a simple change?

Posted

Dadgad, I just made a .dws and forced the color from yellow to magenta using the 'Check Standards' option. Worked great. But...it still doesn't solve the problem of having to do this 500+ times right?

Also...Check standards is great!! I've been using a template file to keep constant settings, but I like being able to double check and force changes now.

 

(haven't had a chance to look at scriptwriter yet...)

Posted

I've written this bit of script which works:

open "C:\Users\roberth\Desktop\AC-Outlets-NewColor\HBL5252BK.dwg" -layer color magenta Guidelines  qsave close
open "C:\Users\roberth\Desktop\AC-Outlets-NewColor\LEV5320CP.dwg" -layer color magenta Guidelines  qsave close 
...

At ReMark's suggestion, I tried pointing it to the file where my drawings are: "C:\Users\roberth\Desktop\AC-Outlets-NewColor" hoping it would batch process the entire folder if I save it as .bat

 

But that doesn't work. I double click on the new .bat file and the windows command prompt pops up for half a second and disappears. My files are unchanged. Clearly .bat and .scr files are written a little differently. Any suggestions? I'm going to poke around in previous posts some more.

  • 1 month later...
Posted

Anyone have experience with ScriptPro? I think it could solve my problems, but it doesn't seem to be working for me. I use the wizard to set everything up, my script runs fine if I run it from within AutoCAD.

I load up all the files I want to run the script on, click run, and AutoCAD pops open, then closes, without doing anything to my files.

My script now is:

-layer color magenta Guidelines  qsave close 

Posted

In my experience once you installed the script pro, you will need to input your script and your drawing files then press start. But in the office, you will need an administrator permission for installation, so i recommend the suggestion of Lee using script writer lisp or the suggestion of Remark using a batch file.

Posted

Fortunately I'm an administrator on my computer here at the office, so I at least don't have to worry about that! (I just have to do some extensive persuading before I install/download anything...the interwebs is a dangerous place you know...)

I've started Script Pro, loaded my script and chosen my drawing files, only to have the problem I mentioned before. Also, after I click start/run Script pro freezes and no matter how many times I click 'stop', nothing happens.

Bizarre, I seem to be doing everything right according to their help file too.

Thanks again for the help

Posted

Are you on a 64bit system? I know SriptPro had a requirement to only run on 32bits. I think there's an update somewhere on AutoDesk labs which is supposed to work, though I haven't had much success with it.

 

Also ScriptPro opens a new ACad for each DWG you selected, it could get a bit slow. Perhaps try something called AutoScript, it runs inside ACad itself instead of an external program which calls acad.

 

Make sure your scrip has a newline at the end, and try to rather use Enters (i.e. new lines) instead of spaces. Sometimes ScriptPro / AutoScript goes haywire with the spaces.

 

Alternatively Lee's proggy also works decently, or you can try Tim's one over here: http://www.theswamp.org/index.php?topic=41546.0

He's looking for people to give him some feedback.

Posted

Ah! Yes, I am running a 64bit system...maybe I will switch the spaces to enters too though, see if that helps.

I'll try some of the other methods (hopefully today) you mentioned and let you know how it goes.

Thanks

Posted

Layer Merge is the command you want. LAYMRG

Posted

Looking through some info on Autoscript, and it seems to only work on AutoCAD 2007 and above...I'm stuck with 2004. I think I'm going to try ScriptPro on my home computer (32bit) tomorrow night, and also probably Lee Mac's program as well. I'll let you know my results.

@eyde, I think Layer Merge might also be a new Autocad Command, LAYMRG is an 'Unknown Command' back here in 2004

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