Editable texts in SVG templates
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Editable texts in SVG templates
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!
- 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!
Re: Editable texts in SVG templates
already fixed some bugs, it now picks the strings correctly when loading the template the first time... Here is how it works:
Re: Editable texts in SVG templates
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...
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...
Re: Editable texts in SVG templates
Yes, I think for a couple of weeks we'll be a bit "inbetween"...
Re: Editable texts in SVG templates
OK, it finally got into the Ubuntu PPA. Cool! I can now stop my feeble attempts to produce a python script for that!
Re: Editable texts in SVG templates
greeting,
how to make a macro to fill " editable texts " automatically for instance?
to publish the Name for example .
Thanks
Xavier G.
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)
Re: Editable texts in SVG templates
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()
Re: Editable texts in SVG templates
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!
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!
Re: Editable texts in SVG templates
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!)
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!)
Re: Editable texts in SVG templates
I did noticed one thing.- in your SVG templates, add freecad:editable="TextName" attributes to <text> entities, to mark them as editable
FireFox seems to be very strict it does not show SVG image and complains."XML Parsing Error: prefix not bound to a namespace"