TechDraw API/de

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

Outdated translations are marked like this.
Other languages:
Deutsch • ‎English • ‎français • ‎italiano • ‎română
(November 2018) Diese Information kann unvollständig und veraltet sein. Für die letzte API siehe die (engl.) autogenerierte API-Dokumentation.

Diese Funktionen sind Teil des TechDraw-Arbeitsbereichs und können in Makros oder mit dem Python-Interpreter verwendet werden, sobald der TechDraw-Arbeitsbereich importiert wurde.

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

Siehe die TechDrawGui-API für weitere Funktionen.

Beispiel:

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: Creates wires from edges in input by planar graph traversal. Optionally exclude the OuterWire by setting optional parameter to false.

Returns: List of wires sorted by size (descending)

Method.png findOuterWire(listOfEdges)

Description: Finds the OuterWire (largest) of a list of edges (that form a planar graph).

Returns: Outer wire

Method.png findShapeOutline(TopoShape, scale, direction)

Description: Project shape in direction and find outer wire of result.

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)

DrawViewPart Geometry

[topoShapeEdge] = dvp.getVisibleEdges()

[topoShapeEdge] = dvp.getHiddenEdges()