Author Topic: DWG Batch Conversion with Lisp ?  (Read 3662 times)

0 Members and 1 Guest are viewing this topic.

57gmc

  • Bull Frog
  • Posts: 365
Re: DWG Batch Conversion with Lisp ?
« Reply #30 on: February 14, 2024, 10:43:31 AM »
I don't understand your question.
If you don't want my help,
then just please say so.

I don't understand your last answer...

I just asked if it is possible to use LISP
to write ANYTHING in SCR files...
or if there are LIMITATIONS...

I never used ACCORECONSOLE
and SCR files ...
...
So i am simply trying
to understand something
...

that's all !

The only limitation I can think of is that you don't want to use dialogs or anything that requires user interaction. Also, your lisp solution is what ScriptPro does. It's a nice GUI for batch processing. The only problem is that you have to restart AutoCAD for each dwg processed, but it does it automatically. AcCoreConsole is much faster though. If you just want an easy solution, ScriptPro is user friendly. But if you have tasks that take a lot of processing time, AcCoreConsole is a better choice.

domenicomaria

  • Swamp Rat
  • Posts: 724
Re: DWG Batch Conversion with Lisp ?
« Reply #31 on: February 14, 2024, 11:03:34 AM »
The only limitation I can think of is that you don't want to use dialogs or anything that requires user interaction. Also, your lisp solution is what ScriptPro does. It's a nice GUI for batch processing. The only problem is that you have to restart AutoCAD for each dwg processed, but it does it automatically. AcCoreConsole is much faster though. If you just want an easy solution, ScriptPro is user friendly. But if you have tasks that take a lot of processing time, AcCoreConsole is a better choice.

and if I only want the content (excluding dialogues and interactions)
of the ACADDOC.LSP file (and the inside defun S::STARTUP) ...
to be executed ...

do you think that ACCORECONSOLE does it?
...

And if I only want this,
what is the command I have to put in the SCR file?

57gmc

  • Bull Frog
  • Posts: 365
Re: DWG Batch Conversion with Lisp ?
« Reply #32 on: February 14, 2024, 11:09:43 AM »
The only limitation I can think of is that you don't want to use dialogs or anything that requires user interaction. Also, your lisp solution is what ScriptPro does. It's a nice GUI for batch processing. The only problem is that you have to restart AutoCAD for each dwg processed, but it does it automatically. AcCoreConsole is much faster though. If you just want an easy solution, ScriptPro is user friendly. But if you have tasks that take a lot of processing time, AcCoreConsole is a better choice.

and if I only want the content (excluding dialogues and interactions)
of the ACADDOC.LSP file (and the inside defun S::STARTUP) ...
to be executed ...

do you think that ACCORECONSOLE does it?
...

And if I only want this,
what is the command I have to put in the SCR file?
I don't know what you have in startup, but I doubt you would need it when using console. It's like using ObjectDbx, there's no interface. When using console, you can't do anything with the coordinate system, like Zoom extents. You may be able to just change the extension on your lisp file to scr and run it. Give it a try. That's the best way to find out what you can do.

domenicomaria

  • Swamp Rat
  • Posts: 724
Re: DWG Batch Conversion with Lisp ?
« Reply #33 on: February 14, 2024, 11:28:31 AM »
You may be able to just change the extension on your lisp file to scr and run it. Give it a try. That's the best way to find out what you can do.
I tried... but nothing happens!

57gmc

  • Bull Frog
  • Posts: 365
Re: DWG Batch Conversion with Lisp ?
« Reply #34 on: February 14, 2024, 11:34:09 AM »
I don't have an app for 7z. Can you post the scr using code tags? Or as a zip?

domenicomaria

  • Swamp Rat
  • Posts: 724
Re: DWG Batch Conversion with Lisp ?
« Reply #35 on: February 14, 2024, 11:40:48 AM »
7z should be a Zip file...try renaming it...
https://www.7-zip.org/download.html

57gmc

  • Bull Frog
  • Posts: 365
Re: DWG Batch Conversion with Lisp ?
« Reply #36 on: February 14, 2024, 11:43:37 AM »
Renaming doesn't work. I can't use 7z on my work pc.

domenicomaria

  • Swamp Rat
  • Posts: 724
Re: DWG Batch Conversion with Lisp ?
« Reply #37 on: February 14, 2024, 11:57:25 AM »
Renaming doesn't work. I can't use 7z on my work pc.

...

57gmc

  • Bull Frog
  • Posts: 365
Re: DWG Batch Conversion with Lisp ?
« Reply #38 on: February 14, 2024, 12:28:01 PM »
I don't think you are doing it right. Re read John's code in post 17. You have to make a couple of changes to his bat file.

In the code below, is the name of the scr file to run. If you always name your scr file BatchDrawings_Script.scr, then you don't ever need to edit the bat file again.
Code: [Select]
if [%script%]==[] (
        set script="%~dp0\BatchDrawings_Script.scr"
In the line below, change it to the path of your acad.exe.
Code: [Select]
:: UPDATE as necessary.
if [%accoreconsole%]==[] set accoreconsole="C:\Program Files\Autodesk\AutoCAD 2024\accoreconsole.exe"
There's no need to create a bat that names all the dwg files. In Windows, if you drag a file onto a bat file, the bat file will run with the file passed as an argument. So just drag a bunch of dwg files onto the bat file and it will take care of running core console.

As far as your lisp goes, you have to debug it on a single dwg first. Do that by opening a dwg and running the SCRIPT command or dragging the scr file onto AutoCAD.



domenicomaria

  • Swamp Rat
  • Posts: 724
Re: DWG Batch Conversion with Lisp ?
« Reply #39 on: February 14, 2024, 12:59:04 PM »
I don't think you are doing it right.

you suggested me to try renaming the LISP file extension to SCR

And I tried

And it doesn't seem to work

so how do you use Lisp in an SCR file?

There's no need to create a bat that names all the dwg files. In Windows, if you drag a file onto a bat file, the bat file will run with the file passed as an argument. So just drag a bunch of dwg files onto the bat file and it will take care of running core console.

I have a main folder that contains other subfolders that contain other folders ... that contain DWG files ...

First, with Lisp, I find the structure of the folders and sub-folders and for each of these I look for the DWG files contained

So I don't have some file somewhere to drag into the BAT file
but I have many files in different locations...

But this should not be a problem for a BAT file ...

57gmc

  • Bull Frog
  • Posts: 365
Re: DWG Batch Conversion with Lisp ?
« Reply #40 on: February 14, 2024, 01:56:46 PM »
you suggested me to try renaming the LISP file extension to SCR

And I tried

And it doesn't seem to work
Then troubleshoot the scr using the method I told you. Also, I don't know how you are trying to run the script. If you want to code your own method for running AcCoreConsole, then you will have to send each file to the console by loading the script along with it. The syntax is:
"C:\Program Files\Autodesk\AutoCAD 2024\accoreconsole.exe" /i "path\Drawing1.dwg" /s "path\BatchDrawings_Script.scr"

Your code needs to build a bat that has a line like that for each file you want to process.

JohnK

  • Administrator
  • Seagull
  • Posts: 10625
Re: DWG Batch Conversion with Lisp ?
« Reply #41 on: February 14, 2024, 04:02:30 PM »
1. 7z and zip are differnt. Apples and Oranges. You cannot change the extension.

2. Looks like you are using dos_lib in that lisp which I don't think could be run by accoreconsole without trying to load that ARX/dll. I only glanced at the code (very busy at the moment) but I'm pretty sure you don't need that much code to do what you want (seems to be a saveas would be just fine).

3. My script has the ability to be called several differnt ways; a. with a drang-n-drop or b. by another script (see my post #5 for what that list looks like).  This is a list of drawings to run the script on (I set those up when I start setting up my project so I have it ready when I need it).

4. SCR is just another text file with a differnt file extension at the end of the day (Like what you thought 7z and zip were). It just so happens that accoreconsole will only "load files with the extension of .scr" but any lisp within the file are loaded too. This is the same thing as the "script" command in AutoCAD.

5. My script to load a file into accoreconsole is not using a FOR loop. Using a "FOR %%DWG IN ... DO ..." in a bat file would case the DO part to start over and over again (much like how scriptpro starts a new instance of AutoCAD for each iteration). ...my stuff is good, theirs is garbage.

6. Using acccoreconsole will have other limitations but you have to expect that; it is a very light/trimmed down AutoCAD. There isnt a GUI so imagine using only the command line to do things like plot, purge, erase, etc. (the things you would want to do to a lot of files).  You wouldnt use accoreconsole to draw with.

7. If you don't know where drawings are located then how can you possibly know what you need to do to them? Yes, you could recurssivly dig into a folder structure to find files with a BATCH script, but this is sounding more like a job for eTransmit then a batch script.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

domenicomaria

  • Swamp Rat
  • Posts: 724
Re: DWG Batch Conversion with Lisp ?
« Reply #42 on: February 14, 2024, 09:59:18 PM »
Then troubleshoot the scr using the method I told you. Also, I don't know how you are trying to run the script. If you want to code your own method for running AcCoreConsole, then you will have to send each file to the console by loading the script along with it. The syntax is:
"C:\Program Files\Autodesk\AutoCAD 2024\accoreconsole.exe" /i "path\Drawing1.dwg" /s "path\BatchDrawings_Script.scr"

Your code needs to build a bat that has a line like that for each file you want to process.

so this code (by MrSmith) that creates the file Bat is not good ?

 (foreach it outList (setq txt (strcat "\"" it "\"," txt)))
 (setq txt (vl-string-right-trim "," txt))
 (setq txt (strcat "FOR %%G IN (" txt ") DO \"" (findfile "accoreconsole.exe") "\" /i %%G /s \"" scriptFile "\""))

domenicomaria

  • Swamp Rat
  • Posts: 724
Re: DWG Batch Conversion with Lisp ?
« Reply #43 on: February 14, 2024, 10:14:19 PM »
but I'm pretty sure you don't need that much code to do what you want (seems to be a saveas would be just fine).
what I need to do is more complex
the Lisp contained in the SCR file is just a piece of the real Lisp
because I made a (partial) copy and paste (and all very quickly)
For this reason you will have found pieces of code that seemed superfluous


5. My script to load a file into accoreconsole is not using a FOR loop. Using a "FOR %%DWG IN ... DO ..." in a bat file would case the DO part to start over and over again (much like how scriptpro starts a new instance of AutoCAD for each iteration). ...my stuff is good, theirs is garbage.
ok

7. If you don't know where drawings are located then how can you possibly know what you need to do to them? Yes, you could recurssivly dig into a folder structure to find files with a BATCH script, but this is sounding more like a job for eTransmit then a batch script.
I can find all the files in all the subfolders and create a list of all the file names including the entire path
This means that I know where are the files

JohnK

  • Administrator
  • Seagull
  • Posts: 10625
Re: DWG Batch Conversion with Lisp ?
« Reply #44 on: February 14, 2024, 10:36:05 PM »
Then troubleshoot the scr using the method I told you. Also, I don't know how you are trying to run the script. If you want to code your own method for running AcCoreConsole, then you will have to send each file to the console by loading the script along with it. The syntax is:
"C:\Program Files\Autodesk\AutoCAD 2024\accoreconsole.exe" /i "path\Drawing1.dwg" /s "path\BatchDrawings_Script.scr"

Your code needs to build a bat that has a line like that for each file you want to process.

so this code (by MrSmith) that creates the file Bat is not good ?

 (foreach it outList (setq txt (strcat "\"" it "\"," txt)))
 (setq txt (vl-string-right-trim "," txt))
 (setq txt (strcat "FOR %%G IN (" txt ") DO \"" (findfile "accoreconsole.exe") "\" /i %%G /s \"" scriptFile "\""))

No, that code looks like it would create a FOR loop in a batch script. That doesn't look bad to me. I choose not to use a FOR loop in my batch script because I didn't want to restart accoreconsole for each drawing but that doesn't mean MrSmith's code is bad.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org