Page 1 of 1

QCad dwg2svg Help?

Posted: Mon Jul 16, 2018 10:22 am
by brenkuka
Hello,

I need to convert about 4800 files from dwg to svg. All the files are in random folders and subfolders.

I am willing to buy a license to disable the time limitation, but only if I can get some help with this?

How can I feed the dwg2svg a list of DWG files, and have them output in the same directory they were created?

Example
1 dwg file is located here

Code: Select all

C:\ProjectRoot\ProjectNumber\Subfolder\file1.dwg
Another could be

Code: Select all

C:\ProjectRoot\ProjectNumber456\Subfolder3\file84.dwg
This is throughout MANY directories and subdirectories.

I would then want the output to be in the same folder.
Continuing the example above:

Code: Select all

C:\ProjectRoot\ProjectNumber\Subfolder\file1.svg
C:\ProjectRoot\ProjectNumber456\Subfolder3\file84.svg
Like that. I have a list of files that need this conversion. It's in a format like:

Code: Select all

"C:\ProjectRoot\ProjectNumber\Subfolder\file1.dwg"
"C:\ProjectRoot\ProjectNumber456\Subfolder3\file84.dwg"
In a text file.

Help? Can I do this? I'm overwhelmed. :shock:

Re: QCad dwg2svg Help?

Posted: Mon Jul 16, 2018 11:10 am
by andrew
This is really a Windows command line question, unrelated to QCAD.

The question is:
How can I list all files of a given type in a directory and all its subdirectories and run a command on them?

The answer is the Windows command forfiles.

Here's an example to run QCAD on all your files and convert them to SVG.
- We assume that the data folder with your files and directories is at "C:\Users\User\data".
- We assume that QCAD is installed in "C:\Program Files\QCAD".

Code: Select all

forfiles /p C:\Users\User\data /s /m *.dwg /c "cmd /c C:\Program^ Files\QCAD\qcad.exe -no-gui -autostart scripts\Pro\Tools\Dwg2Svg\Dwg2Svg.js -f @file"
- Note the ^ in "Program Files" to mask the space
- We call qcad.exe directly using the same parameters as used in dwg2svg.bat. Calling dwg2svg.bat would be preferable, but does not work, at least here. @file automatically resolves into the file name of the file to convert.

Re: QCad dwg2svg Help?

Posted: Mon Jul 16, 2018 11:27 am
by brenkuka
I understand this may be outside the scope for Qcad, but it directly involves your software, and is my need as your potential customer :)

I appreciate you taking the time to help me with this. This is all recursive from the first directory (C:\Users\User\data) which you listed?
Then it will make the SVG 'next to' the original files, wherever they are?

Re: QCad dwg2svg Help?

Posted: Mon Jul 16, 2018 11:31 am
by andrew
brenkuka wrote:
Mon Jul 16, 2018 11:27 am
I understand this may be outside the scope for Qcad, but it directly involves your software, and is my need as your potential customer :)
Yes.. we get a lot of "please fix my printer / e-mail / Internet connection" type of requests because we tend to answer...
brenkuka wrote:
Mon Jul 16, 2018 11:27 am
I appreciate you taking the time to help me with this. This is all recursive from the first directory (C:\Users\User\data) which you listed?
Then it will make the SVG 'next to' the original files, wherever they are?
Yes and yes.

Please try first with a smaller example directory to see how it works.

Re: QCad dwg2svg Help?

Posted: Mon Jul 16, 2018 11:38 am
by brenkuka
Thank you for your responses. I don't think it's quuuite so far out of scope as printers and emails ;)

I will test it in our environment this week. If it works, license is.. 33eur?

Re: QCad dwg2svg Help?

Posted: Mon Jul 16, 2018 11:41 am
by andrew
Yes, please refer to our web site for prices and ordering:
https://www.qcad.org/en/online-shop

Re: QCad dwg2svg Help?

Posted: Mon Jul 16, 2018 11:41 am
by brenkuka
Yup, thanks again mate. :)

Re: QCad dwg2svg Help?

Posted: Tue Jul 17, 2018 7:24 am
by brenkuka
Hey Andrew,

So when I try the script you wrote, it comes up with an error, attached.

The exact code I use:

Code: Select all

forfiles /p "F:\Project\DWGConversionTest\Input" /s /m *.dwg /c "cmd /c C:\Program^ Files\QCAD\qcad.exe -no-gui -autostart scripts\Pro\Tools\Dwg2Svg\Dwg2Svg.js -f @file"
2018-07-17 09_22_28-Import Error.png
2018-07-17 09_22_28-Import Error.png (5.37 KiB) Viewed 12118 times

QCad is installed at the default location, "C:\Program Files\QCAD\qcad.exe".

Re: QCad dwg2svg Help?

Posted: Tue Jul 17, 2018 7:44 am
by brenkuka
Weird, it won't work when it's in a batch file, but it works when I run it from the commandline by copy/paste that same string. e_surprised

Thanks

Re: QCad dwg2svg Help?

Posted: Tue Jul 17, 2018 8:52 am
by andrew
Yes.. Windows batch is not straight forward in many cases. You'd have to Google for a solution of these problems (I'd have to do the same).