Draft API

From FreeCAD Documentation
Revision as of 00:03, 12 July 2010 by Yorik (talk | contribs) (Created page with 'These functions are part of the Draft module and can be used in scripts and macros or from the python interpreter, once the Draft module has been imported: from Draft import * …')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

These functions are part of the Draft module and can be used in scripts and macros or from the python interpreter, once the Draft module has been imported:

from Draft import *
  • makeCircle(radius,[placement,face]) - Creates a circle object with given radius. If placement is given, it is used. If face is False, the circle is shown as a wireframe, otherwise as a face. The current line width and color will be used. Example:
makeCircle(2)
  • makeRectangle(length,width,[placement,face]) - Creates a Rectangle object with length in X direction and height in Y direction. If a placement is given, it is used. If face is False, the rectangle is shown as a wireframe, otherwise as a face. The current line width and color will be used. Example:
makeRectangle(3,4)
  • makeDimension(p1,p2,[p3]) - Creates a Dimension object measuring distance between p1 and p2, optionally with the dimension line passing through p3. The current line width and color will be used. Example:
p1 = FreeCAD.Vector(0,0,0)
p2 = FreeCAD.Vector(2,0,0)
makeDimension(p1,p2)
  • makeWire(pointslist,[closed],[placement]) - Creates a Wire object from the given list of vectors. If closed is True or first and last points are identical, the wire is closed. If face is true (and wire is closed), the wire will appear filled. The current line width and color will be used. If only 2 points are given, the closed value is disregarded, and a simple 2-point line is created. Example:
p1 = FreeCAD.Vector(0,0,0)
p2 = FreeCAD.Vector(2,0,0)
makeWire([p1,p2])
  • makeLine(p1,p2): Creates a line between p1 and p2. This is a simpler version of the makeWire function for 2-points lines only.
  • move(objectslist,vector,[copy]) - Moves the objects contained in objectslist in the direction and distance indicated by the given vector. If copy is True, the actual objects are not moved, but copies are created instead. The given objectslist can be either a list of objects or a single object. Example:
p1 = FreeCAD.Vector(0,0,0)
p2 = FreeCAD.Vector(2,0,0)
obj = makeWire([p1,p2])
delta = FreeCAD.Vector(2,2,0)
move(obj,delta)