TechDraw API

From FreeCAD Documentation
Jump to: navigation, search
This page is a translated version of the page TechDraw API and the translation is 25% complete.

Outdated translations are marked like this.
Other languages:
Deutsch • ‎English • ‎français • ‎italiano • ‎română

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.

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)
Method.png 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)

Method.png findOuterWire(listOfEdges)

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

Returns: Outer wire

Method.png findShapeOutline(TopoShape, scale, direction)

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

Returns: Outline wire

Method.png 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()
Method.png 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()
Method.png writeDXFView(DrawViewPart, FileName)

Description: Save the DrawViewPart in Dxf.

Returns: File

Example:

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

Description: Save the DrawPage in Dxf.

Returns: File

Example:

import TechDraw
TechDraw.writeDXFPage(myPage,myFileName)