TechDraw API/it: Difference between revisions

From FreeCAD Documentation
(Updating to match new version of source page)
No edit summary
(One intermediate revision by the same user not shown)
Line 1: Line 1:
<languages/>
<languages/>
{{VeryImportantMessage|(Novembre 2018) Queste informazioni potrebbero essere incomplete e obsolete. Per l'ultima API, consultare [https://www.freecadweb.org/api autogenerated API documentation].}}
<div class="mw-translate-fuzzy">
Queste funzioni sono parte del modulo TechDraw e, dopo che il modulo TechDraw è stato importato, possono essere utilizzate negli script e nelle macro o dall'interprete Python.
Queste funzioni fanno parte di [[TechDraw Workbench/it|TechDraw]] e possono essere utilizzate nelle [[macros/it|macro]] e dalla console [[Python/it|Python]] dopo l'importazione del modulo {{incode|TechDraw}}.
</div>


Good examples of basic TechDraw scripting can be found in the [https://github.com/FreeCAD/FreeCAD/tree/master/src/Mod/TechDraw/TDTest unit test scripts].
Good examples of basic TechDraw scripting can be found in the [https://github.com/FreeCAD/FreeCAD/tree/master/src/Mod/TechDraw/TDTest unit test scripts].
Line 72: Line 71:
}}
}}


{{TechDraw Tools navi}}
{{TechDraw Tools navi/it}}


[[Category:API/it]]
[[Category:API/it]]

Revision as of 19:28, 10 September 2019

(Novembre 2018) Queste informazioni potrebbero essere incomplete e obsolete. Per l'ultima API, consultare autogenerated API documentation.

Queste funzioni fanno parte di TechDraw e possono essere utilizzate nelle macro e dalla console Python dopo l'importazione del modulo TechDraw.

Good examples of basic TechDraw scripting can be found in the unit test scripts.

See the TechDrawGui API for more functions.

Esempio:

import FreeCAD
import TechDraw

page = FreeCAD.ActiveDocument.addObject('TechDraw::DrawPage', 'Page')
FreeCAD.ActiveDocument.addObject('TechDraw::DrawSVGTemplate', 'Template')
FreeCAD.ActiveDocument.Template.Template = templateFileSpec
FreeCAD.ActiveDocument.Page.Template = FreeCAD.ActiveDocument.Template
page.ViewObject.show()
view = FreeCAD.ActiveDocument.addObject('TechDraw::DrawViewPart', 'View')
rc = page.addView(view)
EdgeWalker(listOfEdges, [bool])

Description: Crea polilinee dai bordi in ingresso tramite grafici planari trasversali. Opzionalmente si può escludere la OuterWire impostando il parametro opzionale su falso.

Returns: Elenco dei wire ordinati per dimensione (decrescente)

findOuterWire(listOfEdges)

Description: Trova l'OuterWire (più grande) in un elenco di bordi (che formano un grafo planare).

Returns: Outer wire

findShapeOutline(TopoShape, scale, direction)

Description: Proietta la forma nella direzione e trova il wire esterno nel risultato.

Returns: Outline wire

viewPartAsDxf(DrawViewPart)

Description: Return the edges of a DrawViewPart in Dxf format.

Returns: String

Example:

fileSpecDxf = "fcOut.dxf"
v = App.ActiveDocument.View
s = TechDraw.viewPartAsDxf(v)
dxfEnd = "0\nEOF\n"
dxfFile = open(fileSpecDxf, "w")
dxfFile.write(s)
dxfFile.write(dxfEnd)
dxfFile.close()
viewPartAsSvg(DrawViewPart)

Description: Return the edges of a DrawViewPart in Svg format.

Returns: String

Example:

fileSpecSvg = "fcOut.svg"
v = App.ActiveDocument.View
s = TechDraw.viewPartAsSvg(v)
head = '<svg\n' + \
       '	xmlns="http://www.w3.org/2000/svg" version="1.1" \n' + \
       '	xmlns:freecad="http://www.freecadweb.org/wiki/index.php?title=Svg_Namespace">\n'
tail = '\n</svg>'
svgFile = open(fileSpecSvg, "w")
svgFile.write(head)
svgFile.write(s)
svgFile.write(tail)
svgFile.close()
writeDXFView(DrawViewPart, FileName)

Description: Save the DrawViewPart in Dxf.

Returns: File

Example:

import TechDraw
TechDraw.writeDXFView(myPart,myFileName)
writeDXFPage(DrawPage, FileName)

Description: Save the DrawPage in Dxf.

Returns: File

Example:

import TechDraw
TechDraw.writeDXFPage(myPage,myFileName)