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!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
yorik
Founder
Posts: 13642
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Editable texts in SVG templates

Post by yorik »

I just added editable texts support in SVG templates, use it like this:

- in your SVG templates, add freecad:editable="TextName" attributes to <text> entities, to mark them as editable
- Page objects in FreeCAD have a "EditableTexts" property, that contain strings, 1 for each editable text
- When changing the template of a page, available editable texts are picked and added to the above property automatically
- Edit the property, change the texts, and press recompute, and the texts are updated in the SVG view

I also added editable texts to the default A3_Landscape template, but, for some reason I still didn't find out, you need to edit the Template property, and put the complete path to the A3_Landscape.svg file, just leaving "A3_Landscape.svg" doesn't work. There might still be more bugs, but I think it's in shape for testing already.

Hope you'll like!
User avatar
yorik
Founder
Posts: 13642
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Editable texts in SVG templates

Post by yorik »

already fixed some bugs, it now picks the strings correctly when loading the template the first time... Here is how it works:

Image
User avatar
NormandC
Veteran
Posts: 18589
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: Editable texts in SVG templates

Post by NormandC »

Nice! :)

Can't wait to try that, but at the moment it has not been copied to SVN and the Ubuntu PPA is still based on it. I won't change it for now, since a few people are still working in SVN and Git does not have their commits...
User avatar
yorik
Founder
Posts: 13642
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Editable texts in SVG templates

Post by yorik »

Yes, I think for a couple of weeks we'll be a bit "inbetween"...
User avatar
NormandC
Veteran
Posts: 18589
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: Editable texts in SVG templates

Post by NormandC »

OK, it finally got into the Ubuntu PPA. Cool! :) I can now stop my feeble attempts to produce a python script for that! :lol:
xav83
Posts: 30
Joined: Sun Dec 04, 2011 9:52 pm

Re: Editable texts in SVG templates

Post by xav83 »

greeting,
how to make a macro to fill " editable texts " automatically for instance?
to publish the Name for example .

Thanks
Xavier G.
http://geekuino.fr/ (Traduction Slic3r)
User avatar
yorik
Founder
Posts: 13642
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Editable texts in SVG templates

Post by yorik »

Well, if you always use the same template, it's easy. You must just know the order of the words. For example if you want to change the first word, you use texts[0] below. The second word, texts[1], etc... (Later we can do a better interface for that)

Code: Select all

# this macro must be run with the Page object selected
import FreeCAD, FreeCADGui
page = FreeCADGui.Selection.getSelection()[0]
texts = page.EditableTexts
texts[0] = "My New Name"
texts[1] = "03 Jan 2012"
texts[7] = ""
texts[8] = "My Drawing"
# etc...
page.EditableTexts = texts
FreeCAD.ActiveDocument.recompute()
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: Editable texts in SVG templates

Post by triplus »

Hi!

I just tested this with my custom A4 drawing template that i created in Inkscape and it works great! It's so easy to change information "on the fly" in template now. Thanks!
User avatar
NormandC
Veteran
Posts: 18589
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: Editable texts in SVG templates

Post by NormandC »

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!)
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: Editable texts in SVG templates

Post by triplus »

- in your SVG templates, add freecad:editable="TextName" attributes to <text> entities, to mark them as editable
I did noticed one thing.
"XML Parsing Error: prefix not bound to a namespace"
FireFox seems to be very strict it does not show SVG image and complains.
Locked