No work around. Needs a code change (use Gui::InputField instead of QLineEdit).
[Improvement] Autofill name and date in template
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
- wandererfan
- Veteran
- Posts: 6317
- Joined: Tue Nov 06, 2012 5:42 pm
- Contact:
Re: [Improvement] Autofill name and date in template
Re: [Improvement] Autofill name and date in template
To clarify, at the moment (March 2019) it's not possible to use Spreadsheet values to populate the editable fields of the Techdraw templates. This is a desired feature that could be added eventually.carbonblueGTS wrote: ↑Sun Jan 20, 2019 5:33 amHow would you go about doing that? I have a spreadsheet with all the information. I was following this template: https://www.freecadweb.org/wiki/Manual: ... readsheets but for it to work, I have to be able to enter an expression. Editable fields don't allow for expressions, so I'm stuck. Thoughts?
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
Re: [Improvement] Autofill name and date in template
It has been opened as issue #3911.wandererfan wrote: ↑Mon Jan 21, 2019 2:24 pm Could somebody make a Feature Request for this so it doesn't get overlooked in v0.19 development?
Yes, I think Date is especially sensitive. You wouldn't want to automatically overwrite an old date in the template, as you'd probably want to see when the drawing was originally created. The user should confirm through a button or interface option whether he or she wants to update the Date and other editable fields. Auto-filling the date makes sense for documents in progress, as the document may be modified over several days. On the other hand, drawings that are "finished" and not subject to further modification should have an option to disable auto-filling so the date and other parameters aren't auto-filled.Author and Company are available in Preferences>General>Document. Date is easy, but it shouldn't update automatically, just when the Page is changed? Page number could be the sequence number of the Page in the Document, but I'm not sure that is necessarily the desired Page number.
Exactly as you say. You can't force people to use the template fields. However, in the wiki, you'd write the necessary documentation and instruct the user to use the standard field names with their own templates, in order for the auto filling to work. This could be mentioned in a tutorial or some clear instructions that describe the creation of custom templates. https://www.freecadweb.org/wiki/TechDraw_TemplateHowToNot sure how we can enforce using the correct names for Template fields. I guess if you don't use the right names in your custom template then you don't get to use the auto-entry feature.
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
Re: [Improvement] Autofill name and date in template
Is it possible right now to fill the fields of the template via a python macro?
If I edit a field, I do not see it in the python console. Maybe a python interface for the template fields should be added as well
If I edit a field, I do not see it in the python console. Maybe a python interface for the template fields should be added as well
Re: [Improvement] Autofill name and date in template
The templates are SVGs, which are text files, so I think it's pretty possible to have an interface to edit them directly. Maybe using sax.xml, which is what importSVG in Draft uses to parse an SVG.
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
- wandererfan
- Veteran
- Posts: 6317
- Joined: Tue Nov 06, 2012 5:42 pm
- Contact:
Re: [Improvement] Autofill name and date in template
No need for the elephant gun!
Sure.
Code: Select all
>>> p = App.ActiveDocument.Page
>>> t = p.Template
>>> et = t.EditableTexts
>>> et["FC-Title"] = "The title of my page"
>>> t.EditableTexts = et
Re: [Improvement] Autofill name and date in template
Nice! I had to create many drawings lately with almost equal settings, that would have saved me some timewandererfan wrote: ↑Sat Sep 21, 2019 5:58 pmCode: Select all
>>> p = App.ActiveDocument.Page >>> t = p.Template >>> et = t.EditableTexts >>> et["FC-Title"] = "The title of my page" >>> t.EditableTexts = et
Re: [Improvement] Autofill name and date in template
Awesome!
As I said, just ask wandererfan, he knows!
As I said, just ask wandererfan, he knows!
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
Re: [Improvement] Autofill name and date in template
Btw are the keys for the EditableText always the same in all templates? Is this defined somewhere in the Wiki?
If there were some standard keys, you could easily use a macro to fill the fields. I wrote something like that yesterday.
The macro itself is very unspectacular, but maybe this is something not everyone knows:
If there were some standard keys, you could easily use a macro to fill the fields. I wrote something like that yesterday.
The macro itself is very unspectacular, but maybe this is something not everyone knows:
Code: Select all
from fractions import Fraction
t = App.ActiveDocument.Template # FIXME this might not always be the case!
page = t.InList[0] # FIXME: is the page always the only one in the InList?
scale = Fraction.from_float(1.0 / page.Scale)
t.EditableTexts['SCALE'] = '{} : {}'.format(scale.numerator, scale.denominator)
- wandererfan
- Veteran
- Posts: 6317
- Joined: Tue Nov 06, 2012 5:42 pm
- Contact:
Re: [Improvement] Autofill name and date in template
I like the macro!
The keys are up to the Template author. I don't know of any way except persuasion to convince people to use standard names.
Then you run into different languages. If a French user wants to use Titre, Auteur, Numero de Piece, etc the macro is not going to find anything.
Having said that, the various standards do define what's supposed to appear in the text block, but they probably don't specify what to call the field.