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:

Editable texts in SVG templates

Post by yorik » Fri Dec 30, 2011 12:38 am

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
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 » Fri Dec 30, 2011 1:27 am

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
Posts: 18534
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: Editable texts in SVG templates

Post by NormandC » Fri Dec 30, 2011 5:31 pm

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
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 » Fri Dec 30, 2011 7:48 pm

Yes, I think for a couple of weeks we'll be a bit "inbetween"...
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 » Tue Jan 03, 2012 12:46 am

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 » Tue Jan 03, 2012 9:05 pm

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
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 » Tue Jan 03, 2012 9:37 pm

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
Posts: 9475
Joined: Mon Dec 12, 2011 4:45 pm

Re: Editable texts in SVG templates

Post by triplus » Fri Jan 06, 2012 1:08 am

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
Posts: 18534
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: Editable texts in SVG templates

Post by NormandC » Fri Jan 06, 2012 1:36 am

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
Posts: 9475
Joined: Mon Dec 12, 2011 4:45 pm

Re: Editable texts in SVG templates

Post by triplus » Sun Jan 08, 2012 2:27 pm

- 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

Who is online

Users browsing this forum: No registered users and 2 guests