issue #0002972: TechDraw PDF export from Python can only make PDFs of a Page in foreground
Opening thread to generate discussion
[SOLVED]Ticket 0002972: TechDraw PDF export from Python can only make PDFs of a Page in foreground
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
[SOLVED]Ticket 0002972: TechDraw PDF export from Python can only make PDFs of a Page in foreground
Last edited by Kunda1 on Wed May 10, 2017 6:21 pm, edited 1 time in total.
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Re: Ticket 0002972: TechDraw PDF export from Python can only make PDFs of a Page in foreground
@wandererfan do u mind weighing in on this when u have a moment?wandererfan wrote:....
Kunda1 wrote:issue #0002972: TechDraw PDF export from Python can only make PDFs of a Page in foreground
Opening thread to generate discussion
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Re: Ticket 0002972: TechDraw PDF export from Python can only make PDFs of a Page in foreground
FreeCADGui.export is part of the core system and thus doesn't know anything about objects of extension modules. This function gets the object to check which document it is part of and then simply uses the active view of this document and export that as pdf. See https://github.com/FreeCAD/FreeCAD/blob ... y.cpp#L528obj = FreeCAD.ActiveDocument.getObject("Page001")
FreeCADGui.export([obj], u"/tmp/Page001.pdf")
So to achieve what you want there are some alternatives how to realize it:
* add a function to the Py interface of TechDrawGui that accepts a DrawPage object and path name. Inside this function can access the correct mdi page via the view provider and export the content as pdf
* another way could be to implement a specialized Python wrapper for the view provider that offers the needed interface for export
Re: Ticket 0002972: TechDraw PDF export from Python can only make PDFs of a Page in foreground
Implementing a TechDraw-specific PDF export might not be too hard... Something in the same mold as the current SVG export: https://github.com/FreeCAD/FreeCAD/blob ... e.cpp#L556 but that uses a QPrinter instead of the QSvgGenerator, it seems to basically work the same way (paint in it with a QPainter).
http://stackoverflow.com/questions/1609 ... f#16095317
http://www.qtcentre.org/threads/47972-R ... export-PDF
http://stackoverflow.com/questions/1609 ... f#16095317
http://www.qtcentre.org/threads/47972-R ... export-PDF
Re: Ticket 0002972: TechDraw PDF export from Python can only make PDFs of a Page in foreground
For reference the bug report evolved from this thread. https://forum.freecadweb.org/viewtopic.php?f=22&t=21384
"fight the good fight"
- wandererfan
- Veteran
- Posts: 6309
- Joined: Tue Nov 06, 2012 5:42 pm
- Contact:
Re: Ticket 0002972: TechDraw PDF export from Python can only make PDFs of a Page in foreground
Part of the solution is already there:yorik wrote:Implementing a TechDraw-specific PDF export might not be too hard
void MDIViewPage::printPdf();
(pops up a dialog to ask for a file. would need to add a parm for file path.)
- and -
MDIViewPage* ViewProviderPage::getMDIViewPage();
Will try to slide this into the next update.
- wandererfan
- Veteran
- Posts: 6309
- Joined: Tue Nov 06, 2012 5:42 pm
- Contact: