QCad dwg2svg Help?

Do you have a question you want to ask an existing QCAD user about QCAD and what you can do with it? Do you want to know if a particular feature exists? This is the place to ask.

Moderator: andrew

Post Reply
brenkuka
Newbie Member
Posts: 7
Joined: Mon Jul 16, 2018 10:14 am

QCad dwg2svg Help?

Post by brenkuka » Mon Jul 16, 2018 10:22 am

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:

User avatar
andrew
Site Admin
Posts: 6085
Joined: Fri Mar 30, 2007 6:07 am

Re: QCad dwg2svg Help?

Post by andrew » Mon Jul 16, 2018 11:10 am

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.

brenkuka
Newbie Member
Posts: 7
Joined: Mon Jul 16, 2018 10:14 am

Re: QCad dwg2svg Help?

Post by brenkuka » 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 :)

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?

User avatar
andrew
Site Admin
Posts: 6085
Joined: Fri Mar 30, 2007 6:07 am

Re: QCad dwg2svg Help?

Post by andrew » Mon Jul 16, 2018 11:31 am

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.

brenkuka
Newbie Member
Posts: 7
Joined: Mon Jul 16, 2018 10:14 am

Re: QCad dwg2svg Help?

Post by brenkuka » Mon Jul 16, 2018 11:38 am

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?

User avatar
andrew
Site Admin
Posts: 6085
Joined: Fri Mar 30, 2007 6:07 am

Re: QCad dwg2svg Help?

Post by andrew » Mon Jul 16, 2018 11:41 am

Yes, please refer to our web site for prices and ordering:
https://www.qcad.org/en/online-shop

brenkuka
Newbie Member
Posts: 7
Joined: Mon Jul 16, 2018 10:14 am

Re: QCad dwg2svg Help?

Post by brenkuka » Mon Jul 16, 2018 11:41 am

Yup, thanks again mate. :)

brenkuka
Newbie Member
Posts: 7
Joined: Mon Jul 16, 2018 10:14 am

Re: QCad dwg2svg Help?

Post by brenkuka » Tue Jul 17, 2018 7:24 am

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 1481 times

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

brenkuka
Newbie Member
Posts: 7
Joined: Mon Jul 16, 2018 10:14 am

Re: QCad dwg2svg Help?

Post by brenkuka » Tue Jul 17, 2018 7:44 am

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

User avatar
andrew
Site Admin
Posts: 6085
Joined: Fri Mar 30, 2007 6:07 am

Re: QCad dwg2svg Help?

Post by andrew » Tue Jul 17, 2018 8:52 am

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

Post Reply

Return to “Pre-sales Questions”