Editable texts in SVG templates

Info about new community or project announcements, implemented features, classes, modules or APIs. Might get technical!
PLEASE DO NOT POST HELP REQUESTS OR OTHER DISCUSSIONS HERE!
User avatar
yorik
Site Admin
Posts: 12064
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels, Belgium
Contact:

Re: Editable texts in SVG templates

Post by yorik » Sun Jan 08, 2012 3:16 pm

Hmm interesting... It looks like proper XML rules ask that when you use a prefix, you define it first:
http://www.w3schools.com/xml/xml_namespaces.asp

Indeed inkscape defines its inkscape: prefix, at the beginning of inkscape-generated files, there is:

Code: Select all

<svg
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:cc="http://creativecommons.org/ns#"
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:svg="http://www.w3.org/2000/svg"
   xmlns="http://www.w3.org/2000/svg"
   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
So we would just need to add: xmlns:freecad="http://some/url"

I'll setup a page on the wiki on the model of the inkscape page... *EDIT* Ah! the inkscape page doesn't exist :( we can do better...

*EDIT2* Done! the line to insert is:

Code: Select all

xmlns:freecad="http://sourceforge.net/apps/mediawiki/free-cad/index.php?title=Svg_Namespace"
triplus
Posts: 9475
Joined: Mon Dec 12, 2011 4:45 pm

Re: Editable texts in SVG templates

Post by triplus » Sun Jan 08, 2012 4:02 pm

yorikvanhavre wrote:Hmm interesting... It looks like proper XML rules ask that when you use a prefix, you define it first:
http://www.w3schools.com/xml/xml_namespaces.asp

Indeed inkscape defines its inkscape: prefix, at the beginning of inkscape-generated files, there is:

Code: Select all

<svg
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:cc="http://creativecommons.org/ns#"
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:svg="http://www.w3.org/2000/svg"
   xmlns="http://www.w3.org/2000/svg"
   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
So we would just need to add: xmlns:freecad="http://some/url"

I'll setup a page on the wiki on the model of the inkscape page... *EDIT* Ah! the inkscape page doesn't exist :( we can do better...

*EDIT2* Done! the line to insert is:

Code: Select all

xmlns:freecad="http://sourceforge.net/apps/mediawiki/free-cad/index.php?title=Svg_Namespace"
Great and there is one more feature now, before if SVG template was edited in Inkscape and then saved:
- in your SVG templates, add freecad:editable="TextName" attributes to <text> entities, to mark them as editable
This was lost but now it persist if it's saved as Inkscape SVG and not Plain SVG. Without namespace URI this was lost if it was saved as Inkscape SVG too, but now it persists.
User avatar
yorik
Site Admin
Posts: 12064
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels, Belgium
Contact:

Re: Editable texts in SVG templates

Post by yorik » Sun Jan 08, 2012 4:34 pm

triplus wrote:This was lost but now it persist if it's saved as Inkscape SVG and not Plain SVG. Without namespace URI this was lost if it was saved as Inkscape SVG too, but now it persists.
Great! I hadn't noticed that...
User avatar
NormandC
Posts: 18534
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: Editable texts in SVG templates

Post by NormandC » Sun Jan 08, 2012 6:32 pm

The sodipodi link is dead too. Actually, I don't understand why there are Sodipodi:prefix namespaces in Inkscape documents, that software has been dead for almost 8 years, they should had replaced them by Inkscape:prefix... (Sodipodi was the predecessor to Inkscape)
User avatar
jriegel
Site Admin
Posts: 3369
Joined: Sun Feb 15, 2009 5:29 pm
Location: Ulm, Germany
Contact:

Re: Editable texts in SVG templates

Post by jriegel » Sun Jan 08, 2012 8:25 pm

They keep the sodiposi name-space for back wards compatibility.
Stop whining - start coding!
triplus
Posts: 9475
Joined: Mon Dec 12, 2011 4:45 pm

Re: Editable texts in SVG templates

Post by triplus » Mon Jan 09, 2012 3:56 pm

normandc wrote:Hi triplus,

How about sharing your template (if you don't mind)? :)

The Drawing Templates wiki page could use some A4 templates! ;)

(and some A and B too for people in North America, but I'm slowly working on it!)
My drawing templates are very specific and because of that i made two more simple/generic/standard ones for other to use in A4 Portrait and A3 Landscape sizes.

This are the rules i followed:
One pixel = one millimeter
Add proper "namespace URI" inside (at the beginning of) <svg> tag:
Add attributes to <text> entities, to mark them as editable:
freecad:editable="TextName"
Insert just before the last </svg> tag
<!-- DrawingContent -->
Important: If u edit drawing template in for example Inkscape save it as Inkscape SVG and not Plain SVG if u want all FreeCAD specific changes to persist!

Remove (rename file) the .zip extension from the SVG file. SVG file is not compressed i just can't upload it as .svg file.
Attachments
a3_landscape.svg.zip
A3 Landscape Drawing Template
(9.83 KiB) Downloaded 247 times
a4_portrait.svg.zip
A4 Portrait Drawing Template
(9.81 KiB) Downloaded 247 times
triplus
Posts: 9475
Joined: Mon Dec 12, 2011 4:45 pm

Re: Editable texts in SVG templates

Post by triplus » Thu Jun 27, 2013 2:19 am

I assumed 1px = 1mm rule should be used in this templates but i guess i was wrong the template should use mm by default! It does work but exported .SVG must always be resized in Inkscape for example to get correct output size (print).

viewtopic.php?f=10&t=4182&start=10#p32837
User avatar
jriegel
Site Admin
Posts: 3369
Joined: Sun Feb 15, 2009 5:29 pm
Location: Ulm, Germany
Contact:

Re: Editable texts in SVG templates

Post by jriegel » Thu Jun 27, 2013 5:57 am

I'm not able to open the zip files?
Stop whining - start coding!
wmayer
Site Admin
Posts: 16645
Joined: Thu Feb 19, 2009 10:32 am

Re: Editable texts in SVG templates

Post by wmayer » Thu Jun 27, 2013 9:04 am

jriegel wrote:I'm not able to open the zip files?
Remove the ".zip" suffix.
User avatar
jriegel
Site Admin
Posts: 3369
Joined: Sun Feb 15, 2009 5:29 pm
Location: Ulm, Germany
Contact:

Re: Editable texts in SVG templates

Post by jriegel » Thu Jun 27, 2013 4:56 pm

Ups :oops:
Stop whining - start coding!
Locked

Who is online

Users browsing this forum: Bing [Bot] and 1 guest