dwg2svg - Example

Use this forum to ask questions about how to do things in QCAD.

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Attach drawing files and screenshots.

Post one question per topic.

Post Reply
dmericksen
Newbie Member
Posts: 3
Joined: Thu May 09, 2019 5:35 am

dwg2svg - Example

Post by dmericksen » Thu May 09, 2019 5:51 am

Can you provide an example of the strings to pass to set drawing units to inches in the resulting SVG? I'm passing '-g' but the units in the resulting SVG file do not have the correct units.

The documentation does not make this very clear.
https://qcad.org/en/products/qcad-command-line-tools

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

Re: dwg2svg - Example

Post by andrew » Thu May 09, 2019 9:39 am

The SVG output unit is the same as the drawing unit if possible (mm, cm, in).

If the input drawing is unitless or has the wrong unit, you can use the -u in switch to tell dwg2svg to interpret the units as Inches.

If the coordinates are wrong in the input drawing or you want to convert the unit, you can use the -s switch to scale the output.

Let's say you have a drawing in mm that you want to output in Inches, you could convert using:

Code: Select all

dwg2svg -u in -s 1/25.4 -o output.svg input.dxf
This means:
- interpret the coordinates as Inches (and output in Inches)
- scale output by factor 1/25.4

dmericksen
Newbie Member
Posts: 3
Joined: Thu May 09, 2019 5:35 am

Re: dwg2svg - Example

Post by dmericksen » Thu May 09, 2019 1:37 pm

Thanks for the example. I'm still having trouble though. I think because the source file does not have drawing units specified. This output file does not open with the expected size in vector programs like Adobe Illustrator.

Input File:
12.dxf
(99.25 KiB) Downloaded 242 times

Code: Select all

dwg2svg -f -g -u in -s 1/71.94 -o output.svg input.dxf
Output File:
12.svg
(8.45 KiB) Downloaded 311 times

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

Re: dwg2svg - Example

Post by andrew » Thu May 09, 2019 3:06 pm

Which version of QCAD are you using?

If not the latest, does dwg2svg -h report the -u switch? If not, that was added in a later version.
The SVG files you've attached does not specify a unit which means that size would default to pixels (i.e. the SVG is 12 pixels wide).

dmericksen
Newbie Member
Posts: 3
Joined: Thu May 09, 2019 5:35 am

Re: dwg2svg - Example

Post by dmericksen » Sat May 11, 2019 1:33 am

I'm using qcadds-3.20.1.6-pro-linux-x86_64

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

Re: dwg2svg - Example

Post by andrew » Mon May 13, 2019 9:24 am

I'm assuming the expected size is about 12 inches wide (11.5").

Since the drawing unit is also inches, you'd only have to specify the input being inches (i.e. no scale):

Code: Select all

dwg2svg -f -g -u in -o 12.svg 12.dxf
You can see if the SVG is correct by opening it in a text editor. Its header should look like this:

Code: Select all

<svg width="11.5472in" height="2.0409in" ...>
If an application displays it at a different scale or size, the error or configuration error would be with that application.

Post Reply

Return to “QCAD 'How Do I' Questions”