TechDraw API

From FreeCAD Documentation
Revision as of 21:15, 16 October 2019 by Renatorivo (talk | contribs)
Jump to: navigation, search
Other languages:
Deutsch • ‎English • ‎français • ‎italiano • ‎română
(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)
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)

DrawViewPart Cosmetics

dvp.makeCosmeticVertex(point)

dvp.makeCosmeticLine(start,end,style, weight, pyGreen)

dvp.makeCosmeticCircle(center, radius, style, weight, pyRed)

dvp.makeCosmeticCircleArc(arcCenter, radius, arcStart, arcEnd, style, weight, shadow)