TechDraw API
These functions are part of the TechDraw Workbench and can be used in macros and from the Python console once the TechDraw
module has been imported.
Good examples of basic TechDraw scripting can be found in the unit test scripts.
See the TechDrawGui API for more functions.
Example:
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)
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)
Description: Finds the OuterWire (largest) of a list of edges (that form a planar graph).
Returns: Outer wire
Description: Project shape in direction and find outer wire of result.
Returns: Outline wire
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()
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()
Example:
import TechDraw TechDraw.writeDXFView(myPart,myFileName)
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()
- Pages: New Default, New Pick
- Views: New View, New Projection Group, New Section, New Detail, New Annotation, New Draft, New Arch, Spreadsheet
- Clips: Clip, ClipPlus, ClipMinus
- Dimensions: New Length, New Horizontal, New Vertical, New Radius, New Diameter, New Angle, New Angle3Pt, New Links, New Balloon
- Decoration: Hatch Area, Geometric Hatch, New Symbol, New Image, Toggle Frames
- Utilities: SaveSVG, SaveDXF
- Additional: Preferences, Import-Export Preferences; Hatching, LineGroup, Templates; TechDraw API, TechDrawGui API