Jump to content

Running laytrans across multiple (1000ish) .dwg files


Recommended Posts

Posted

Good morning all,

 

Having spent the day yesterday chasing my tail and trying multiple different routes, scripts, lisp coding etc I need help solving my issue.

 

We are updating all our blocks and I was hoping that I could create a script / bat file / lisp routine that would save us having to open each file individually. Currently, I have created the following files;

 

lisp

(defun c:ltrans()
	(command ("acet-laytrans" "c:/users/joe.bloggs/Downloads/Steelwork.dws" 0))
	(princ)
)

 

script

(load "c:/users/joe.bloggs/Downloads/Laytrans.lsp")
ltrans
qsave
close

 

.bat file

FOR %%f IN ("c:\users\joe.bloggs\Downloads\Steelwork\*.dwg") do "C:\Program Files\Autodesk\AutoCAD 2024\accoreconsole.exe" /i "%%f" /s "c:\users\joe.bloggs\Downloads\laytrans.scr"

 

When I run the .bat file I get the following error

image.thumb.png.c77f9131764caaa54f0cf10386473715.png

 

 

The lisp routine works when initiated in CAD, as does the script but when initiated by the .bat file it fails.

 

Any help / ideas / solutions would be most welcome or if there is a better solution to renaming layers within cad files via a routine I am happy to try that, my coding skills are very limited but I am willing to learn.

 

Thanks

Posted (edited)

@Wilkibob you cannot run "acet-laytrans" like an AutoCAD command. It has to be run directly as a function. Try changing:

(command ("acet-laytrans" "c:/users/joe.bloggs/Downloads/Steelwork.dws" 0))

to just:

(acet-laytrans "c:/users/joe.bloggs/Downloads/Steelwork.dws" 0)

 

NOTE - you can run this directly from the script with no need to define it in a defun and load it from a lsp file.

Try this in your script:

(arxload "acetutil.arx")
(acet-laytrans "c:/users/joe.bloggs/Downloads/Steelwork.dws" 0)
qsave
close

 

Ref: AutoCAD 2025 Help | acet-laytrans (AutoLISP) | Autodesk
https://help.autodesk.com/view/ACD/2025/ENU/?guid=GUID-4BD312D1-1850-4DE4-A63D-35367C5F7F5D

Edited by pkenewell
  • Like 1
Posted

Thanks for replying @pkenewell, unfortunately I'm still getting an error when running the bat file, I really want to be able to run it in the background and let it work through all the files without having to open CAD for each one.

image.png.35cd3d81fddd34ad1c53347a71660a7c.png

Posted

You could try my post, October 5th linked below. It might fail completely. This one works by looping through all the files in a directory, open each one and runs the commands in order. Commands might be AutoCAD commands, might be LISP routines - add them in just as you would using the command line (so for example, no need to put (Command "Line" 0,0 10,0), you can just do 'Line' as one line, 0,0 as the next and 10,0 as the next).... I wrote it so know how it works...

 

It opens, changes , saves and closes each drawing, so not as quick as say Scrptwriterpro or Lee Macs scriptwriter, but I find the interface more intuitive for me (which is how I designed it!), and easier than using the core console.

 

I reckon it will plot to PDF about 10 files a minute... 1000 files... about 90 minutes.... so not the quickest.. a lunchtime job?

 

 

 

Next step slower from this is to put the LISP as AutoStarting (so load the LISP and then straight after the line "(C:LTrans)" to get it to run, open the files manually and it should run... but that is a last resort.

 

 

 

 

acet - Express Tools - do you need to load them for each drawing / wait for them to be loaded before you can run the command ? Express Tool are an additional set of tools, loaded after the main CAD program starts, Might be wrong but a .bat file doesn't open each drawing does it? Works with the drawings closed... and so the express Tools aren't loaded and available for use.

  • Like 1
Posted
3 hours ago, pkenewell said:
(arxload "acetutil.arx")

 

 

Not sure if this works with bat files? Not something I really use though  - happy with my slower LISP that lets me put the kettle on while it works at stuff

Posted
5 hours ago, Wilkibob said:

Thanks for replying @pkenewell, unfortunately I'm still getting an error when running the bat file, I really want to be able to run it in the background and let it work through all the files without having to open CAD for each one.

image.png.35cd3d81fddd34ad1c53347a71660a7c.png

@Wilkibob Normally you should be able to run command line lisp statements from a script file, but I don't know when it comes to BATCH (.bat) file. See if adding the code into the lisp file and loading it works? If not - then I don't think your going to be able to use a BATCH file anyway. You can always use a SCRIPT (.scr) file with a 2nd instance of AutoCAD open in the background.

 

Add to ltrans.lsp:

(arxload "acetutil.arx")
(acet-laytrans "c:/users/joe.bloggs/Downloads/Steelwork.dws" 0)

 

Then to script:

(load "c:/users/joe.bloggs/Downloads/Laytrans.lsp")
qsave
close

 

  • Like 1
Posted

Is the (arxload "acetutil.arx") working in your image ARXLOAD failed, you may need a full path use "\\" between directories. Just find acetutil.arx with explorer. Look Program files\Autodesk.

 

Accoreconsole may not support acet functions. It does have limitations. If you can not get past the load will need to use maybe OBDX or an old fashioned script.

 

Make sure with all testing you use a dummy directory of copied files. 

  • Like 2
Posted
3 hours ago, BIGAL said:

Make sure with all testing you use a dummy directory of copied files. 

Absolutely!    :thumbsup:     Very important, as you don't want to throw out

the baby with the bath water.   :beard:

Posted

Thanks all for your suggestions, and yes i have been testing on a dummy directory 🤓.  I've decided to abandon the laytrans route, instead will use a script that renames and updates any other parts of the layer instead - as I'm typing this it is running in the background updating 100files as a test, I think i was trying to be too clever before and when i only have very basic knowledge of lisp creation i was biting off more than i could chew.

 

off to refine the new routine and add more functions to it just because... 😆

  • Like 1
Posted

Glad to here its working, Just having a layold.laynew csv file is probably the simplest way. Can loop through the file very quick can use Excel to make csv file.

  • Like 1

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