TechDrawGui API: Difference between revisions

From FreeCAD Documentation
(Improve code and links)
No edit summary
 
(11 intermediate revisions by 4 users not shown)
Line 2: Line 2:
<translate>
<translate>
<!--T:1-->
<!--T:1-->
{{VeryImportantMessage|(November 2018) This information may be incomplete and outdated. For the latest API, see the [https://www.freecadweb.org/api autogenerated API documentation].}}
These functions are part of the [[TechDraw Workbench]] and can be used in scripts and macros or from the python interpreter, once the <code>TechDrawGui</code> module has been imported.
These functions are part of the [[TechDraw Workbench|TechDraw Workbench]] and can be used in [[macros|macros]] and from the [[Python|Python]] console once the {{incode|TechDrawGui}} module has been imported.


<!--T:5-->
<!--T:5-->
See the [[TechDraw API]] for more functions.
See the [[TechDraw API|TechDraw API]] for more functions.


<!--T:2-->
<!--T:2-->
Line 22: Line 23:
TechDrawGui.exportPageAsSvg(p, f)
TechDrawGui.exportPageAsSvg(p, f)
}}
}}



<translate>
<translate>
Line 28: Line 28:
{{APIFunction|exportPageAsPdf|pageObject, filePath|save a copy of pageObject in PDF format to location filePath|none}}
{{APIFunction|exportPageAsPdf|pageObject, filePath|save a copy of pageObject in PDF format to location filePath|none}}
{{APIFunction|exportPageAsSvg|pageObject, filePath|save a copy of pageObject in SVG format to location filePath|none}}
{{APIFunction|exportPageAsSvg|pageObject, filePath|save a copy of pageObject in SVG format to location filePath|none}}
{{APIFunction|copyActiveViewToSvgFile|document, filePath, (options)|save a copy of the active view for "document" to file "filePath"|double (estimated scale)}}

Options:
<!--T:6-->
* width - float - width of generated svg in mm
Back to the [[TechDraw Workbench]].
* height - float - height of generated svg in mm

* paintBackground - bool - paint/do not paint background
<!--T:4-->
* backgroundColor - tuple - (r,g,b,a)
[[Category:API]]
* lineWidth - float - weight of lines
[[Category:Poweruser Documentation]]
* border - float - empty space around image
* mode - int - rendering mode (AS_IS, WIREFRAME, POINTS, WIREFRAME_OVERLAY, HIDDEN_LINE, BOUNDING_BOX)
<br/>
{{APIFunction|addQGIToView|view, QGraphicsItem|add a QGraphicsItem (created using PySide) to a View|none}}


</translate>
</translate>
{{TechDraw Tools navi{{#translation:}}}}
{{Userdocnavi{{#translation:}}}}
[[Category:API{{#translation:}}]]
[[Category:Poweruser Documentation{{#translation:}}]]
{{clear}}
{{clear}}

Latest revision as of 23:14, 12 March 2020

(November 2018) This information may be incomplete and outdated. For the latest API, see the autogenerated API documentation.

These functions are part of the TechDraw Workbench and can be used in macros and from the Python console once the TechDrawGui module has been imported.

See the TechDraw API for more functions.

Example:

import FreeCAD
import TechDrawGui

p = FreeCAD.ActiveDocument.Page

f = "/home/localuser/myPdfDirectory/savePage.pdf"
TechDrawGui.exportPageAsPdf(p, f)

f = "/home/localuser/mySvgDirectory/savePage.svg"
TechDrawGui.exportPageAsSvg(p, f)
exportPageAsPdf(pageObject, filePath)

Description: save a copy of pageObject in PDF format to location filePath

Returns: none

exportPageAsSvg(pageObject, filePath)

Description: save a copy of pageObject in SVG format to location filePath

Returns: none

copyActiveViewToSvgFile(document, filePath, (options))

Description: save a copy of the active view for "document" to file "filePath"

Returns: double (estimated scale)

Options:

  • width - float - width of generated svg in mm
  • height - float - height of generated svg in mm
  • paintBackground - bool - paint/do not paint background
  • backgroundColor - tuple - (r,g,b,a)
  • lineWidth - float - weight of lines
  • border - float - empty space around image
  • mode - int - rendering mode (AS_IS, WIREFRAME, POINTS, WIREFRAME_OVERLAY, HIDDEN_LINE, BOUNDING_BOX)


addQGIToView(view, QGraphicsItem)

Description: add a QGraphicsItem (created using PySide) to a View

Returns: none