svg export issues
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Re: svg export issues
Looks like it's solved indeed. I'll pull the changes, and add the info to the wiki
Re: svg export issues
Thanks for your help guys,
But it's still not solved from my end. I changed my A template to have this:
And removed these lines from the <sodipodi:namedview> tag:
And my Print preview from FreeCAD still looks like the one I posted.
EDIT: just tried with the revised A4_Landscape.svg template, and the Print Preview is now fine. So I guess there's something wrong with my custom template. Would that be because un-rounded units are not allowed in viewBox?
2nd EDIT: nope, just tried it with viewBox="0 0 279 216", no change. I'm stomped.
But it's still not solved from my end. I changed my A template to have this:
Code: Select all
width="279.4mm"
height="215.9mm"
viewBox="0 0 279.4 215.9"
Code: Select all
inkscape:zoom="2.8723143"
inkscape:cx="198.88572"
inkscape:cy="94.621281"
EDIT: just tried with the revised A4_Landscape.svg template, and the Print Preview is now fine. So I guess there's something wrong with my custom template. Would that be because un-rounded units are not allowed in viewBox?
2nd EDIT: nope, just tried it with viewBox="0 0 279 216", no change. I'm stomped.
Re: svg export issues
I don't understand. If I export my Drawing page to svg and open it in Inkscape, then it recognizes its page size as US letter, and printing is OK.
But in FreeCAD's Print preview, the template still won't scale correctly to the page, while the A_Landscape.svg template revised by shoogen does.
But in FreeCAD's Print preview, the template still won't scale correctly to the page, while the A_Landscape.svg template revised by shoogen does.
Re: svg export issues
In src/Mod/Drawing/App/DrawingExport.cpp the angle of an arc is calculated by
Lines 177 and
To determine the parameters of an arc I need to use 2D trigonometrics in order to get the quadrant/sign of the angle (like arctan2) right (in importSVG.py).
I thought seb_kuzminsky ran into this, but it turned out that i was wrong.
But I'm courius about this.
EDIT
I think that the documentation i found on dotCross is broken. A tripple scalar product doesn't make any sense.
If it does (0,0,1) * (v1 x v2). Than this would not return an angle, but -1,1 for the orientation. (as needed)
Code: Select all
double a = v3.DotCross(v1,v2);
To determine the parameters of an arc I need to use 2D trigonometrics in order to get the quadrant/sign of the angle (like arctan2) right (in importSVG.py).
I thought seb_kuzminsky ran into this, but it turned out that i was wrong.
But I'm courius about this.
EDIT
I think that the documentation i found on dotCross is broken. A tripple scalar product doesn't make any sense.
If it does (0,0,1) * (v1 x v2). Than this would not return an angle, but -1,1 for the orientation. (as needed)
Last edited by shoogen on Sun Feb 12, 2012 6:23 pm, edited 1 time in total.
-
- Posts: 11
- Joined: Thu Feb 09, 2012 5:41 am
Re: svg export issues
Here's a sketch that produces incorrect arcs when exported to svg.
The raw exported svg is here (Sourceforge wouldn't let me attach the svg to this post): http://highlab.com/~seb/apogaea/longitu ... ported.svg
Here's the manually corrected svg: http://highlab.com/~seb/apogaea/longitude-fixed.svg
I think the problem is in Draft.py, line 1082. The exporter just blithely sets the arc flags to "0 1", without consulting the geometry it's exporting.
The raw exported svg is here (Sourceforge wouldn't let me attach the svg to this post): http://highlab.com/~seb/apogaea/longitu ... ported.svg
Here's the manually corrected svg: http://highlab.com/~seb/apogaea/longitude-fixed.svg
I think the problem is in Draft.py, line 1082. The exporter just blithely sets the arc flags to "0 1", without consulting the geometry it's exporting.
- Attachments
-
- longitude.fcstd
- (5.93 KiB) Downloaded 56 times
Re: svg export issues
Nevermind that.normandc wrote:I don't understand. If I export my Drawing page to svg and open it in Inkscape, then it recognizes its page size as US letter, and printing is OK.
But in FreeCAD's Print preview, the template still won't scale correctly to the page, while the A_Landscape.svg template revised by shoogen does.
For a reason I can't understand, in the Print Preview dialog, if I click on the Page configuration button, I see in the new dialog that the page is correctly recognized as US letter; changing nothing and clicking OK closes the dialog, returns to the Preview window, and the content automatically resizes correctly to fit the page. Now I need to print it out to check that the scale is indeed correct.
Thank you shoogen for this fix in the template, it has the added bonus that now the svg shows a lot bigger when opened in Firefox or an image viewer.
@ seb_kuzminsky: in both your svg, most of the profile is outside the document dimensions. I can only view their content in Eye of GNOME, as in Inkscape or Firefox I only see white space.
Re: svg export issues
Yes, that's the "white-on-white" problem I must fix one day...normandc wrote:@ seb_kuzminsky: in both your svg, most of the profile is outside the document dimensions. I can only view their content in Eye of GNOME, as in Inkscape or Firefox I only see white space.
For the arc flags problems we must also make a better code.
Re: svg export issues
yorikvanhavre wrote:For the arc flags problems we must also make a better code.
Code: Select all
edge=...
drawing_plane_normal=FreeCAD.Vector(0,0,1) #be careful when doing (other) projections!
flag_large_arc = ((edge.ParameterRange[1]-edge.ParameterRange[0]) / math.pi) % 2) > 1
flag_sweep = edge.Curve.Axis*drawing_plane_normal < 0
sweepflag <==> arc is travelled clockwise (negative) in FreeCAD coordinate system <==> arc is travelled counter-clockwise (positive) in SVG coordinate system
Re: svg export issues
Normandc - could you post your A sized template please? This change to the template width/height format has introduced a bug to ortho-gui and I'd like to check my fix. I can just rough up a random-sized template but be nice to check it with a real one too!
Re: svg export issues
Thanks for your code Seb Hoogen... I just implemented it, slightly modified (by empirical testing). http://free-cad.git.sourceforge.net/git ... 3b1439ed19
As far as I tested it works great!
As far as I tested it works great!