SVG export ignores polyline width

If you are having problems with QCAD, post here. Please report bugs through our Bug Tracker instead.

Always attach your original DXF or DWG file and mentions your QCAD version and the platform you are on.

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Attach drawing files and screenshots.

Post one question per topic.

Post Reply
slcasner
Junior Member
Posts: 21
Joined: Tue May 07, 2019 10:23 pm

SVG export ignores polyline width

Post by slcasner » Tue Aug 06, 2019 9:45 pm

I have exported a schematic diagram from the EAGLE printed circuit CAD program as a DXF file. I want to use QCAD-Pro to make some adjustments to that DXF and then export it as SVG for inclusion in documentation. The import into QCAD works fine. However, each line of the diagram is composed of three polylines, one for the length of the line and two arcs to make rounded ends on the line. The width of the line is controlled by the width parameter of the polyline. This renders correctly in the graphics view of QCAD, but in the SVG output the line is reduced to a simple line with width determined by the linewidth parameter and the arcs look like knobs on the ends of the line. See the attachments lc.dxf and lc.svg which are a single stroke taken from a vector-font character in the schematic scaled up by 100 for easier viewing of the SVG in Firefox. The corresponding screenshots are pro.png and svg.png.

It would be straightforward to achieve correct rendering in SVG by exporting the line segment as a rectangle with the length determined by the line length and the width determined by the polyline width using stroke-width:0 and filling with the polyline's color. Similarly the arcs would be rendered as closed, filled semi-circles. In fact, for this particular construction of lines using a linear polyline and two arc polylines, a further optimization would be to output just one filled shape composed of the two arc and the two sides of the rectangle. That's what I have done by hacking the SVG for this test image, producing lco.svg and hacked.png. But that optimization would not be necessary for correct rendering.

I wanted to try to implement this idea (and also investigate the problems I mentioned in https://qcad.org/rsforum/viewtopic.php? ... 322#p24286) so I updated my local repo from github. Then I came to realize that the community version does not support SVG export at all. In fact, the community version appears to ignore the polyline width parameter completely because it renders the graphics view in the same problematic way as the SVG output from QCAD-Pro, see community.png. Is there any way that I could work on this?
Attachments
community.png
community.png (249.24 KiB) Viewed 7696 times
lco.svg
(460 Bytes) Downloaded 588 times
hacked.png
hacked.png (28.32 KiB) Viewed 7696 times
svg.png
svg.png (27.63 KiB) Viewed 7696 times
pro.png
pro.png (296.75 KiB) Viewed 7696 times
lc.svg
(701 Bytes) Downloaded 567 times
lc.dxf
(103.37 KiB) Downloaded 531 times

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

Re: SVG export ignores polyline width

Post by andrew » Wed Aug 07, 2019 7:10 am

I cannot reproduce this problem.

Please make sure that the option "Preserve Geometry" is disabled in the export options (File > Advanced SVG Export).

With "Preserve Geometry" on, the focus is on getting the geometry / coordinates of the defining data across. With "Preserve Geometry" off, the presentation is preserved.

CVH
Premier Member
Posts: 3418
Joined: Wed Sep 27, 2017 4:17 pm

Re: SVG export ignores polyline width

Post by CVH » Thu Aug 08, 2019 1:05 am

Should be mentioned there are also two unused Blocks with solids centered on the origin.
I do not know if they might interfere but they are of similar size.

I know for sure, Andrew will stricktly stick to the file format definition.
and I totally agree with him on that.
Reading the posts in the forum a lot of these issues pop up.
It is usually not the Host to blame but rather the Target application.
In half of the cases the posting ends in a void.

To represent any line width not limited by dxf there are two solutions.
A hairline contour and a fill, that's a hatch because there isn't a fill option.
A poly with Global Width and two arcs for a pen with a round tip.
As the number of hatches rizes, the performance drops.
The choise is simply made.

The Target application might not like the use of some less common used properties.
There are other candidates:
ByLayer, ByBlock, Default, 0.00
Continuous, Linetype Scale, Polyline Pattern (*set to no! in my case)
Global Width, local's, GlobalZ, local's (*zero!)
See also https://qcad.org/rsforum/viewtopic.php?f=8&t=6467

Regards

slcasner
Junior Member
Posts: 21
Joined: Tue May 07, 2019 10:23 pm

Re: SVG export ignores polyline width

Post by slcasner » Thu Aug 08, 2019 1:26 am

Andrew - You correctly identified the problem; after clearing the "Preserve Geometry" option, the shape is rendered as expected in SVG. I may have set that option when I was trying to fix the poor rendering of a solid-fill hatch between arcs as reported in https://qcad.org/rsforum/viewtopic.php? ... 322#p24286 (but it didn't help). I'll file a separate topic for that problem with a reduced example file.

CHM - The reason for the two unused blocks is that my example file was reduced from a larger diagram incorporating those blocks. They were not the cause of the undesired rendering in SVG.

Also, you say there is not a fill option. Do you mean in SVG? There is a fill option that does solid fill, and it works well. The SVG export from QCAD does use it when "Preserve Geometry" is not set.

slcasner
Junior Member
Posts: 21
Joined: Tue May 07, 2019 10:23 pm

Re: SVG export ignores polyline width

Post by slcasner » Thu Aug 08, 2019 1:28 am

Sorry, I meant CVH, not CHM. I have "CHM" on my mind because I have been at the Computer History Museum a lot recently.

CVH
Premier Member
Posts: 3418
Joined: Wed Sep 27, 2017 4:17 pm

Re: SVG export ignores polyline width

Post by CVH » Thu Aug 08, 2019 1:56 am

from svg, dxf has no fill, that's why the workarround with line widths and pen tips.
To svg, it can be either the bare entities or what they were representing.

Post Reply

Return to “QCAD Troubleshooting and Problems”