I design things, export to STL, revise, export again.
Every time, the export filename is blank.
Please populate the default export filename to be the name of the FreeCAD filename.
Please preset filename for export
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
Be nice to others! Read the FreeCAD code of conduct!
Re: Please preset filename for export
I support this. As a workaround I can - from the second export on - just click on the existing file. This may be OS dependant.
OS: macOS 10.15
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.23258 (Git)
Build type: Release
Branch: master
Hash: 78c6cc1362c39e3f1f778c52ae2a1c82badeec20
Python version: 3.8.6
Qt version: 5.12.5
Coin version: 4.0.0
OCC version: 7.4.0
Locale: C/Default (C)
OS: macOS 10.15
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.23258 (Git)
Build type: Release
Branch: master
Hash: 78c6cc1362c39e3f1f778c52ae2a1c82badeec20
Python version: 3.8.6
Qt version: 5.12.5
Coin version: 4.0.0
OCC version: 7.4.0
Locale: C/Default (C)
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Re: Please preset filename for export
Maybe have a format string - file name, body name, feature if selected, ...
Re: Please preset filename for export
The export name should indeed take the filename (or document name?) by default...
Re: Please preset filename for export
Would you implement this as an optional last parameter to Gui::FileDialog::getSaveFileName()? Or as a static variable set on the FileDialog class? Or something else? getSaveFileName() is called around 40 places in the code (though some of those calls are actually to the QFileDialog, not the wrapper class), so I think we'd want the parameter to be optional.
Re: Please preset filename for export
I think I'd indeed pass it as the last optional argument to Gui::FileDialog::getSaveFileName(). I believe there must be one central place where this is done for all export types, as the individual exporters already get objects list + filename. I would bet on https://github.com/FreeCAD/FreeCAD/blob ... c.cpp#L301chennes wrote: ↑Tue Dec 15, 2020 4:17 pm Would you implement this as an optional last parameter to Gui::FileDialog::getSaveFileName()? Or as a static variable set on the FileDialog class? Or something else? getSaveFileName() is called around 40 places in the code (though some of those calls are actually to the QFileDialog, not the wrapper class), so I think we'd want the parameter to be optional.
This should be easy to implement, but it probably needs some testing to make sure no file is overwritten accidentally, as the file extension doesn't appear in the export dialog.
A further improvement could be to add the file extension and change it when the filetype filter changes..
Re: Please preset filename for export
I did not realize that if the parameter named dir to getSaveFileName() includes not just a directory, but also a filename, then this dialog will already almost do what we want it to. Although the QFileDialog::setDirectory() method discards the filename when it is called, if we are using the native file dialog, that static method does not discard the filename, and will select it as needed. So I believe only a small tweak to the non-native dialog code is needed to also select the file, if there is one. There is no change to the method signature. Finally, the calling code just needs to be modified to include a default filename.
Re: Please preset filename for export
I'm not sure the first implementation will have this, or at least it may not expose it to the end user, but I am giving it some thought. Can you help me generate a list of things that would make sense in the default filename? Some people's workflows are very export-heavy, and a good default filename could be a big time saver. The obvious things I can think of are:
- FCStd filename of the active file (can you select things across files to export?)
- Label of the selected object if there is only one (what if there are multiple?)
- Label of the selected object's parent in the GUI (how far up the tree?)
- Custom text
- Date/Time
Re: Please preset filename for export
I have commented in the developer forum, and I think you made an excellent proposal.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.