From 09046c98b1306f408c38f2b3d09b7b28828f3cac Mon Sep 17 00:00:00 2001 From: vocx-fc Date: Sat, 10 Aug 2019 16:24:38 -0500 Subject: [PATCH] Draft: Draft.py, the docstrings need triple quotes and be next to the method or class in order to be picked up by Doxygen or Sphinx; this complies with PEP 257 --- src/Mod/Draft/Draft.py | 299 ++++++++++++++++++++--------------------- 1 file changed, 146 insertions(+), 153 deletions(-) diff --git a/src/Mod/Draft/Draft.py b/src/Mod/Draft/Draft.py index 38792ab8fdd3..9c5768663092 100644 --- a/src/Mod/Draft/Draft.py +++ b/src/Mod/Draft/Draft.py @@ -45,7 +45,7 @@ # # @{ -'''The Draft module offers a range of tools to create and manipulate basic 2D objects''' +"""The Draft module offers a range of tools to create and manipulate basic 2D objects""" import FreeCAD, math, sys, os, DraftVecUtils, WorkingPlane from FreeCAD import Vector @@ -93,7 +93,7 @@ def stringencodecoin(ustr): return ustr.encode('latin1') def typecheck (args_and_types, name="?"): - "typecheck([arg1,type),(arg2,type),...]): checks arguments types" + """typecheck([arg1,type),(arg2,type),...]): checks arguments types""" for v,t in args_and_types: if not isinstance (v,t): w = "typecheck[" + str(name) + "]: " @@ -125,7 +125,7 @@ def getParamType(param): return None def getParam(param,default=None): - "getParam(parameterName): returns a Draft parameter value from the current config" + """getParam(parameterName): returns a Draft parameter value from the current config""" p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Draft") t = getParamType(param) #print("getting param ",param, " of type ",t, " default: ",str(default)) @@ -157,7 +157,7 @@ def getParam(param,default=None): return None def setParam(param,value): - "setParam(parameterName,value): sets a Draft parameter with the given value" + """setParam(parameterName,value): sets a Draft parameter with the given value""" p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Draft") t = getParamType(param) if t == "int": @@ -178,11 +178,11 @@ def setParam(param,value): p.SetUnsigned(param,value) def precision(): - "precision(): returns the precision value from Draft user settings" + """precision(): returns the precision value from Draft user settings""" return getParam("precision",6) def tolerance(): - "tolerance(): returns the tolerance value from Draft user settings" + """tolerance(): returns the tolerance value from Draft user settings""" return getParam("tolerance",0.05) def epsilon(): @@ -191,14 +191,14 @@ def epsilon(): return (1.0/(10.0**tolerance())) def getRealName(name): - "getRealName(string): strips the trailing numbers from a string name" + """getRealName(string): strips the trailing numbers from a string name""" for i in range(1,len(name)): if not name[-i] in '1234567890': return name[:len(name)-(i-1)] return name def getType(obj): - "getType(object): returns the Draft type of the given object" + """getType(object): returns the Draft type of the given object""" import Part if not obj: return None @@ -237,7 +237,7 @@ def getObjectsOfType(objectslist,typ): return objs def get3DView(): - "get3DView(): returns the current view if it is 3D, or the first 3D view found, or None" + """get3DView(): returns the current view if it is 3D, or the first 3D view found, or None""" if FreeCAD.GuiUp: import FreeCADGui v = FreeCADGui.ActiveDocument.ActiveView @@ -267,7 +267,7 @@ def isClone(obj,objtype,recursive=False): return False def getGroupNames(): - "returns a list of existing groups in the document" + """returns a list of existing groups in the document""" glist = [] doc = FreeCAD.ActiveDocument for obj in doc.Objects: @@ -276,7 +276,7 @@ def getGroupNames(): return glist def ungroup(obj): - "removes the current object from any group it belongs to" + """removes the current object from any group it belongs to""" for g in getGroupNames(): grp = FreeCAD.ActiveDocument.getObject(g) if obj in grp.Group: @@ -285,7 +285,7 @@ def ungroup(obj): grp.Group = g def autogroup(obj): - "adds a given object to the autogroup, if applicable" + """adds a given object to the autogroup, if applicable""" if FreeCAD.GuiUp: if hasattr(FreeCADGui,"draftToolBar"): if hasattr(FreeCADGui.draftToolBar,"autogroup") and (not FreeCADGui.draftToolBar.isConstructionMode()): @@ -307,7 +307,7 @@ def autogroup(obj): a.addObject(obj) def dimSymbol(symbol=None,invert=False): - "returns the current dim symbol from the preferences as a pivy SoMarkerSet" + """returns the current dim symbol from the preferences as a pivy SoMarkerSet""" if symbol == None: symbol = getParam("dimsymbol",0) from pivy import coin @@ -346,9 +346,9 @@ def dimSymbol(symbol=None,invert=False): return coin.SoSphere() def dimDash(p1, p2): - '''dimDash(p1, p2): returns pivy SoSeparator. + """dimDash(p1, p2): returns pivy SoSeparator. Used for making Tick-2, DimOvershoot, ExtOvershoot dashes. - ''' + """ from pivy import coin dash = coin.SoSeparator() v = coin.SoVertexProperty() @@ -360,8 +360,8 @@ def dimDash(p1, p2): return dash def shapify(obj): - '''shapify(object): transforms a parametric shape object into - non-parametric and returns the new object''' + """shapify(object): transforms a parametric shape object into + non-parametric and returns the new object""" if not (obj.isDerivedFrom("Part::Feature")): return None if not "Shape" in obj.PropertiesList: return None shape = obj.Shape @@ -390,10 +390,10 @@ def shapify(obj): return newobj def getGroupContents(objectslist,walls=False,addgroups=False,spaces=False,noarchchild=False): - '''getGroupContents(objectlist,[walls,addgroups]): if any object of the given list + """getGroupContents(objectlist,[walls,addgroups]): if any object of the given list is a group, its content is appended to the list, which is returned. If walls is True, walls and structures are also scanned for included windows or rebars. If addgroups - is true, the group itself is also included in the list.''' + is true, the group itself is also included in the list.""" def getWindows(obj): l = [] if getType(obj) in ["Wall","Structure"]: @@ -475,7 +475,7 @@ def printShape(shape): print(" ",v.Point) def compareObjects(obj1,obj2): - "Prints the differences between 2 objects" + """Prints the differences between 2 objects""" if obj1.TypeId != obj2.TypeId: print(obj1.Name + " and " + obj2.Name + " are of different types") @@ -496,13 +496,13 @@ def compareObjects(obj1,obj2): print("Property " + p + " doesn't exist in one of the objects") def formatObject(target,origin=None): - ''' + """ formatObject(targetObject,[originObject]): This function applies to the given target object the current properties set on the toolbar (line color and line width), or copies the properties of another object if given as origin. It also places the object in construction group if needed. - ''' + """ if not target: return obrep = target.ViewObject @@ -554,19 +554,19 @@ def formatObject(target,origin=None): obrep.DiffuseColor = matchrep.DiffuseColor def getSelection(): - "getSelection(): returns the current FreeCAD selection" + """getSelection(): returns the current FreeCAD selection""" if gui: return FreeCADGui.Selection.getSelection() return None def getSelectionEx(): - "getSelectionEx(): returns the current FreeCAD selection (with subobjects)" + """getSelectionEx(): returns the current FreeCAD selection (with subobjects)""" if gui: return FreeCADGui.Selection.getSelectionEx() return None def select(objs=None): - "select(object): deselects everything and selects only the passed object or list" + """select(object): deselects everything and selects only the passed object or list""" if gui: FreeCADGui.Selection.clearSelection() if objs: @@ -577,7 +577,7 @@ def select(objs=None): FreeCADGui.Selection.addSelection(obj) def loadSvgPatterns(): - "loads the default Draft SVG patterns and custom patters if available" + """loads the default Draft SVG patterns and custom patters if available""" import importSVG from PySide import QtCore FreeCAD.svgpatterns = {} @@ -693,9 +693,9 @@ def loadTexture(filename,size=None): return None def getMovableChildren(objectslist,recursive=True): - '''getMovableChildren(objectslist,[recursive]): extends the given list of objects + """getMovableChildren(objectslist,[recursive]): extends the given list of objects with all child objects that have a "MoveWithHost" property set to True. If - recursive is True, all descendents are considered, otherwise only direct children.''' + recursive is True, all descendents are considered, otherwise only direct children.""" added = [] if not isinstance(objectslist,list): objectslist = [objectslist] @@ -724,13 +724,13 @@ def getMovableChildren(objectslist,recursive=True): return added def makeCircle(radius, placement=None, face=None, startangle=None, endangle=None, support=None): - '''makeCircle(radius,[placement,face,startangle,endangle]) + """makeCircle(radius,[placement,face,startangle,endangle]) or makeCircle(edge,[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. If startangle AND endangle are given (in degrees), they are used and the object appears as an arc. If an edge - is passed, its Curve must be a Part.Circle''' + is passed, its Curve must be a Part.Circle""" if not FreeCAD.ActiveDocument: FreeCAD.Console.PrintError("No active document. Aborting\n") return @@ -780,10 +780,10 @@ def makeCircle(radius, placement=None, face=None, startangle=None, endangle=None return obj def makeRectangle(length, height, placement=None, face=None, support=None): - '''makeRectangle(length,width,[placement],[face]): Creates a Rectangle + """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.''' + rectangle is shown as a wireframe, otherwise as a face.""" if not FreeCAD.ActiveDocument: FreeCAD.Console.PrintError("No active document. Aborting\n") return @@ -805,7 +805,7 @@ def makeRectangle(length, height, placement=None, face=None, support=None): return obj def makeDimension(p1,p2,p3=None,p4=None): - '''makeDimension(p1,p2,[p3]) or makeDimension(object,i1,i2,p3) + """makeDimension(p1,p2,[p3]) or makeDimension(object,i1,i2,p3) or makeDimension(objlist,indices,p3): Creates a Dimension object with the dimension line passign through p3.The current line width and color will be used. There are multiple ways to create a dimension, depending on @@ -816,7 +816,7 @@ def makeDimension(p1,p2,p3=None,p4=None): - (object,i1,mode,p3): creates a linked dimension to the given object, i1 is the index of the (curved) edge to measure, and mode is either "radius" or "diameter". - ''' + """ if not FreeCAD.ActiveDocument: FreeCAD.Console.PrintError("No active document. Aborting\n") return @@ -878,9 +878,9 @@ def makeDimension(p1,p2,p3=None,p4=None): return obj def makeAngularDimension(center,angles,p3,normal=None): - '''makeAngularDimension(center,angle1,angle2,p3,[normal]): creates an angular Dimension + """makeAngularDimension(center,angle1,angle2,p3,[normal]): creates an angular Dimension from the given center, with the given list of angles, passing through p3. - ''' + """ if not FreeCAD.ActiveDocument: FreeCAD.Console.PrintError("No active document. Aborting\n") return @@ -912,11 +912,11 @@ def makeAngularDimension(center,angles,p3,normal=None): return obj def makeWire(pointslist,closed=False,placement=None,face=None,support=None): - '''makeWire(pointslist,[closed],[placement]): Creates a Wire object + """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. Instead of - a pointslist, you can also pass a Part Wire.''' + a pointslist, you can also pass a Part Wire.""" if not FreeCAD.ActiveDocument: FreeCAD.Console.PrintError("No active document. Aborting\n") return @@ -956,12 +956,12 @@ def makeWire(pointslist,closed=False,placement=None,face=None,support=None): return obj def makePolygon(nfaces,radius=1,inscribed=True,placement=None,face=None,support=None): - '''makePolgon(nfaces,[radius],[inscribed],[placement],[face]): Creates a + """makePolgon(nfaces,[radius],[inscribed],[placement],[face]): Creates a polygon object with the given number of faces and the radius. if inscribed is False, the polygon is circumscribed around a circle with the given radius, otherwise it is inscribed. If face is True, the resulting shape is displayed as a face, otherwise as a wireframe. - ''' + """ if not FreeCAD.ActiveDocument: FreeCAD.Console.PrintError("No active document. Aborting\n") return @@ -986,9 +986,9 @@ def makePolygon(nfaces,radius=1,inscribed=True,placement=None,face=None,support= return obj def makeLine(p1,p2=None): - '''makeLine(p1,p2): Creates a line between p1 and p2. + """makeLine(p1,p2): Creates a line between p1 and p2. makeLine(LineSegment): Creates a line from a Part.LineSegment - makeLine(Shape): Creates a line from first vertex to last vertex of the given shape''' + makeLine(Shape): Creates a line from first vertex to last vertex of the given shape""" if not p2: if hasattr(p1,"StartPoint") and hasattr(p1,"EndPoint"): p2 = p1.EndPoint @@ -1003,11 +1003,11 @@ def makeLine(p1,p2=None): return obj def makeBSpline(pointslist,closed=False,placement=None,face=None,support=None): - '''makeBSpline(pointslist,[closed],[placement]): Creates a B-Spline object + """makeBSpline(pointslist,[closed],[placement]): Creates a B-Spline 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. Instead of - a pointslist, you can also pass a Part Wire.''' + a pointslist, you can also pass a Part Wire.""" if not FreeCAD.ActiveDocument: FreeCAD.Console.PrintError("No active document. Aborting\n") return @@ -1047,8 +1047,8 @@ def makeBSpline(pointslist,closed=False,placement=None,face=None,support=None): return obj def makeBezCurve(pointslist,closed=False,placement=None,face=None,support=None,Degree=None): - '''makeBezCurve(pointslist,[closed],[placement]): Creates a Bezier Curve object - from the given list of vectors. Instead of a pointslist, you can also pass a Part Wire.''' + """makeBezCurve(pointslist,[closed],[placement]): Creates a Bezier Curve object + from the given list of vectors. Instead of a pointslist, you can also pass a Part Wire.""" if not FreeCAD.ActiveDocument: FreeCAD.Console.PrintError("No active document. Aborting\n") return @@ -1085,11 +1085,11 @@ def makeBezCurve(pointslist,closed=False,placement=None,face=None,support=None,D return obj def makeText(stringslist,point=Vector(0,0,0),screen=False): - '''makeText(strings,[point],[screen]): Creates a Text object at the given point, + """makeText(strings,[point],[screen]): Creates a Text object at the given point, containing the strings given in the strings list, one string by line (strings can also be one single string). The current color and text height and font specified in preferences are used. - If screen is True, the text always faces the view direction.''' + If screen is True, the text always faces the view direction.""" if not FreeCAD.ActiveDocument: FreeCAD.Console.PrintError("No active document. Aborting\n") return @@ -1114,7 +1114,7 @@ def makeText(stringslist,point=Vector(0,0,0),screen=False): return obj def makeCopy(obj,force=None,reparent=False): - '''makeCopy(object): returns an exact copy of an object''' + """makeCopy(object): returns an exact copy of an object""" if not FreeCAD.ActiveDocument: FreeCAD.Console.PrintError("No active document. Aborting\n") return @@ -1223,7 +1223,7 @@ def makeCopy(obj,force=None,reparent=False): return newobj def makeBlock(objectslist): - '''makeBlock(objectslist): Creates a Draft Block from the given objects''' + """makeBlock(objectslist): Creates a Draft Block from the given objects""" if not FreeCAD.ActiveDocument: FreeCAD.Console.PrintError("No active document. Aborting\n") return @@ -1238,7 +1238,7 @@ def makeBlock(objectslist): return obj def makeArray(baseobject,arg1,arg2,arg3,arg4=None,arg5=None,arg6=None,name="Array"): - '''makeArray(object,xvector,yvector,xnum,ynum,[name]) for rectangular array, or + """makeArray(object,xvector,yvector,xnum,ynum,[name]) for rectangular array, or makeArray(object,xvector,yvector,zvector,xnum,ynum,znum,[name]) for rectangular array, or makeArray(object,center,totalangle,totalnum,[name]) for polar array: Creates an array of the given object @@ -1246,7 +1246,7 @@ def makeArray(baseobject,arg1,arg2,arg3,arg4=None,arg5=None,arg6=None,name="Arra at xvector distance between iterations, same for y direction with yvector and ynum, same for z direction with zvector and znum. In case of polar array, center is a vector, totalangle is the angle to cover (in degrees) and totalnum is the number of objects, - including the original. The result is a parametric Draft Array.''' + including the original. The result is a parametric Draft Array.""" if not FreeCAD.ActiveDocument: FreeCAD.Console.PrintError("No active document. Aborting\n") return @@ -1282,11 +1282,11 @@ def makeArray(baseobject,arg1,arg2,arg3,arg4=None,arg5=None,arg6=None,name="Arra return obj def makePathArray(baseobject,pathobject,count,xlate=None,align=False,pathobjsubs=[]): - '''makePathArray(docobj,path,count,xlate,align,pathobjsubs): distribute + """makePathArray(docobj,path,count,xlate,align,pathobjsubs): distribute count copies of a document baseobject along a pathobject or subobjects of a pathobject. Optionally translates each copy by FreeCAD.Vector xlate direction and distance to adjust for difference in shape centre vs shape reference point. - Optionally aligns baseobject to tangent/normal/binormal of path.''' + Optionally aligns baseobject to tangent/normal/binormal of path.""" if not FreeCAD.ActiveDocument: FreeCAD.Console.PrintError("No active document. Aborting\n") return @@ -1314,7 +1314,7 @@ def makePathArray(baseobject,pathobject,count,xlate=None,align=False,pathobjsubs return obj def makePointArray(base, ptlst): - '''makePointArray(base,pointlist):''' + """makePointArray(base,pointlist):""" obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython","PointArray") _PointArray(obj, base, ptlst) obj.Base = base @@ -1329,9 +1329,9 @@ def makePointArray(base, ptlst): return obj def makeEllipse(majradius,minradius,placement=None,face=True,support=None): - '''makeEllipse(majradius,minradius,[placement],[face],[support]): makes + """makeEllipse(majradius,minradius,[placement],[face],[support]): makes an ellipse with the given major and minor radius, and optionally - a placement.''' + a placement.""" if not FreeCAD.ActiveDocument: FreeCAD.Console.PrintError("No active document. Aborting\n") return @@ -1354,9 +1354,9 @@ def makeEllipse(majradius,minradius,placement=None,face=True,support=None): return obj def extrude(obj,vector,solid=False): - '''makeExtrusion(object,vector): extrudes the given object + """makeExtrusion(object,vector): extrudes the given object in the direction given by the vector. The original object - gets hidden.''' + gets hidden.""" if not FreeCAD.ActiveDocument: FreeCAD.Console.PrintError("No active document. Aborting\n") return @@ -1372,8 +1372,8 @@ def extrude(obj,vector,solid=False): return newobj def joinWires(wires, joinAttempts = 0): - '''joinWires(objects): merges a set of wires where possible, if any of those - wires have a coincident start and end point''' + """joinWires(objects): merges a set of wires where possible, if any of those + wires have a coincident start and end point""" if joinAttempts > len(wires): return joinAttempts += 1 @@ -1387,8 +1387,8 @@ def joinWires(wires, joinAttempts = 0): joinWires(wires, joinAttempts) def joinTwoWires(wire1, wire2): - '''joinTwoWires(object, object): joins two wires if they share a common - point as a start or an end''' + """joinTwoWires(object, object): joins two wires if they share a common + point as a start or an end""" wire1AbsPoints = [wire1.Placement.multVec(point) for point in wire1.Points] wire2AbsPoints = [wire2.Placement.multVec(point) for point in wire2.Points] if (wire1AbsPoints[0] == wire2AbsPoints[-1] and wire1AbsPoints[-1] == wire2AbsPoints[0]) \ @@ -1445,10 +1445,10 @@ def splitOpenWire(wire, newPoint, edgeIndex): makeWire(wire2Points, placement=wire.Placement) def fuse(object1,object2): - '''fuse(oject1,object2): returns an object made from + """fuse(oject1,object2): returns an object made from the union of the 2 given objects. If the objects are coplanar, a special Draft Wire is used, otherwise we use - a standard Part fuse.''' + a standard Part fuse.""" if not FreeCAD.ActiveDocument: FreeCAD.Console.PrintError("No active document. Aborting\n") return @@ -1484,11 +1484,11 @@ def fuse(object1,object2): return obj def cut(object1,object2): + """cut(oject1,object2): returns a cut object made from + the difference of the 2 given objects.""" if not FreeCAD.ActiveDocument: FreeCAD.Console.PrintError("No active document. Aborting\n") return - '''cut(oject1,object2): returns a cut object made from - the difference of the 2 given objects.''' obj = FreeCAD.ActiveDocument.addObject("Part::Cut","Cut") obj.Base = object1 obj.Tool = object2 @@ -1550,11 +1550,11 @@ def isClosedEdge(edge_index, object): return edge_index + 1 >= len(object.Points) def move(objectslist,vector,copy=False): - '''move(objects,vector,[copy]): Moves the objects contained + """move(objects,vector,[copy]): Moves the objects contained in objects (that can be an object or a list of objects) 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 objects (or their copies) are returned.''' + are created instead. The objects (or their copies) are returned.""" typecheck([(vector,Vector), (copy,bool)], "move") if not isinstance(objectslist,list): objectslist = [objectslist] objectslist.extend(getMovableChildren(objectslist)) @@ -1636,7 +1636,7 @@ def move(objectslist,vector,copy=False): return newobjlist def array(objectslist,arg1,arg2,arg3,arg4=None,arg5=None,arg6=None): - '''array(objectslist,xvector,yvector,xnum,ynum) for rectangular array, + """array(objectslist,xvector,yvector,xnum,ynum) for rectangular array, array(objectslist,xvector,yvector,zvector,xnum,ynum,znum) for rectangular array, or array(objectslist,center,totalangle,totalnum) for polar array: Creates an array of the objects contained in list (that can be an object or a list of objects) @@ -1647,7 +1647,7 @@ def array(objectslist,arg1,arg2,arg3,arg4=None,arg5=None,arg6=None): the original. This function creates an array of independent objects. Use makeArray() to create a - parametric array object.''' + parametric array object.""" def rectArray(objectslist,xvector,yvector,xnum,ynum): typecheck([(xvector,Vector), (yvector,Vector), (xnum,int), (ynum,int)], "rectArray") @@ -1733,12 +1733,12 @@ def rotateEdge(object, edge_index, angle, center, axis): rotateVertex(object, edge_index+1, angle, center, axis) def rotate(objectslist,angle,center=Vector(0,0,0),axis=Vector(0,0,1),copy=False): - '''rotate(objects,angle,[center,axis,copy]): Rotates the objects contained + """rotate(objects,angle,[center,axis,copy]): Rotates the objects contained in objects (that can be a list of objects or an object) of the given angle (in degrees) around the center, using axis as a rotation axis. If axis is omitted, the rotation will be around the vertical Z axis. If copy is True, the actual objects are not moved, but copies - are created instead. The objects (or their copies) are returned.''' + are created instead. The objects (or their copies) are returned.""" import Part typecheck([(copy,bool)], "rotate") if not isinstance(objectslist,list): objectslist = [objectslist] @@ -1840,11 +1840,11 @@ def copyScaledEdge(object, edge_index, scale, center): return makeLine(vertex1, vertex2) def scale(objectslist,scale=Vector(1,1,1),center=Vector(0,0,0),copy=False): - '''scale(objects,vector,[center,copy,legacy]): Scales the objects contained + """scale(objects,vector,[center,copy,legacy]): Scales the objects contained in objects (that can be a list of objects or an object) of the given scale factors defined by the given vector (in X, Y and Z directions) around given center. If copy is True, the actual objects are not moved, but copies - are created instead. The objects (or their copies) are returned.''' + are created instead. The objects (or their copies) are returned.""" if not isinstance(objectslist, list): objectslist = [objectslist] newobjlist = [] @@ -1902,7 +1902,7 @@ def scale(objectslist,scale=Vector(1,1,1),center=Vector(0,0,0),copy=False): return newobjlist def offset(obj,delta,copy=False,bind=False,sym=False,occ=False): - '''offset(object,delta,[copymode],[bind]): offsets the given wire by + """offset(object,delta,[copymode],[bind]): offsets the given wire by applying the given delta Vector to its first vertex. If copymode is True, another object is created, otherwise the same object gets offsetted. If bind is True, and provided the wire is open, the original @@ -1910,7 +1910,7 @@ def offset(obj,delta,copy=False,bind=False,sym=False,occ=False): if sym is True, bind must be true too, and the offset is made on both sides, the total width being the given delta length. If offsetting a BSpline, the delta must not be a Vector but a list of Vectors, one for - each node of the spline.''' + each node of the spline.""" import Part, DraftGeomUtils newwire = None delete = None @@ -1920,7 +1920,7 @@ def offset(obj,delta,copy=False,bind=False,sym=False,occ=False): print("the offset tool is currently unable to offset a non-Draft object directly - Creating a copy") def getRect(p,obj): - "returns length,height,placement" + """returns length,height,placement""" pl = obj.Placement.copy() pl.Base = p[0] diag = p[2].sub(p[0]) @@ -1935,7 +1935,7 @@ def getRect(p,obj): return l,h,pl def getRadius(obj,delta): - "returns a new radius for a regular polygon" + """returns a new radius for a regular polygon""" an = math.pi/obj.FacesNumber nr = DraftVecUtils.rotate(delta,-an) nr.multiply(1/math.cos(an)) @@ -2086,10 +2086,10 @@ def getRadius(obj,delta): return newobj def draftify(objectslist,makeblock=False,delete=True): - '''draftify(objectslist,[makeblock],[delete]): turns each object of the given list + """draftify(objectslist,[makeblock],[delete]): turns each object of the given list (objectslist can also be a single object) into a Draft parametric wire. If makeblock is True, multiple objects will be grouped in a block. - If delete = False, old objects are not deleted''' + If delete = False, old objects are not deleted""" import DraftGeomUtils, Part if not isinstance(objectslist,list): @@ -2122,8 +2122,8 @@ def draftify(objectslist,makeblock=False,delete=True): return newobjlist def getDXF(obj,direction=None): - '''getDXF(object,[direction]): returns a DXF entity from the given - object. If direction is given, the object is projected in 2D.''' + """getDXF(object,[direction]): returns a DXF entity from the given + object. If direction is given, the object is projected in 2D.""" plane = None result = "" if obj.isDerivedFrom("Drawing::View") or obj.isDerivedFrom("TechDraw::DrawView"): @@ -2207,11 +2207,11 @@ def getrgb(color,testbw=True): def makeDrawingView(obj,page,lwmod=None,tmod=None,otherProjection=None): - ''' + """ makeDrawingView(object,page,[lwmod,tmod]) - adds a View of the given object to the given page. lwmod modifies lineweights (in percent), tmod modifies text heights (in percent). The Hint scale, X and Y of the page are used. - ''' + """ if not FreeCAD.ActiveDocument: FreeCAD.Console.PrintError("No active document. Aborting\n") return @@ -2262,11 +2262,11 @@ def makeDrawingView(obj,page,lwmod=None,tmod=None,otherProjection=None): return viewobj def makeShape2DView(baseobj,projectionVector=None,facenumbers=[]): - ''' + """ makeShape2DView(object,[projectionVector,facenumbers]) - adds a 2D shape to the document, which is a 2D projection of the given object. A specific projection vector can also be given. You can also specify a list of face numbers to be considered in individual faces mode. - ''' + """ if not FreeCAD.ActiveDocument: FreeCAD.Console.PrintError("No active document. Aborting\n") return @@ -2285,7 +2285,7 @@ def makeShape2DView(baseobj,projectionVector=None,facenumbers=[]): def makeSketch(objectslist,autoconstraints=False,addTo=None, delete=False,name="Sketch",radiusPrecision=-1): - '''makeSketch(objectslist,[autoconstraints],[addTo],[delete],[name],[radiusPrecision]): + """makeSketch(objectslist,[autoconstraints],[addTo],[delete],[name],[radiusPrecision]): Makes a Sketch objectslist with the given Draft objects. @@ -2307,7 +2307,7 @@ def makeSketch(objectslist,autoconstraints=False,addTo=None, * radiusPrecision(-1): If <0, disable radius constraint. If =0, add indiviaul radius constraint. If >0, the radius will be rounded according to this precision, and 'Equal' constraint will be added to curve with equal - radius within precision.''' + radius within precision.""" if not FreeCAD.ActiveDocument: FreeCAD.Console.PrintError("No active document. Aborting\n") @@ -2569,7 +2569,7 @@ def delObj(obj): return nobj def makePoint(X=0, Y=0, Z=0,color=None,name = "Point", point_size= 5): - ''' makePoint(x,y,z ,[color(r,g,b),point_size]) or + """ makePoint(x,y,z ,[color(r,g,b),point_size]) or makePoint(Vector,color(r,g,b),point_size]) - creates a Point in the current document. example usage: @@ -2580,7 +2580,7 @@ def makePoint(X=0, Y=0, Z=0,color=None,name = "Point", point_size= 5): p1 = makePoint(1,0,0,(1,0,0)) # color = red p1.X = 1 #move it in x p1.ViewObject.PointColor =(0.0,0.0,1.0) #change the color-make sure values are floats - ''' + """ if not FreeCAD.ActiveDocument: FreeCAD.Console.PrintError("No active document. Aborting\n") return @@ -2605,8 +2605,8 @@ def makePoint(X=0, Y=0, Z=0,color=None,name = "Point", point_size= 5): return obj def makeShapeString(String,FontFile,Size = 100,Tracking = 0): - '''ShapeString(Text,FontFile,Height,Track): Turns a text string - into a Compound Shape''' + """ShapeString(Text,FontFile,Height,Track): Turns a text string + into a Compound Shape""" if not FreeCAD.ActiveDocument: FreeCAD.Console.PrintError("No active document. Aborting\n") return @@ -2627,12 +2627,11 @@ def makeShapeString(String,FontFile,Size = 100,Tracking = 0): return obj def clone(obj,delta=None,forcedraft=False): - - '''clone(obj,[delta,forcedraft]): makes a clone of the given object(s). The clone is an exact, + """clone(obj,[delta,forcedraft]): makes a clone of the given object(s). The clone is an exact, linked copy of the given object. If the original object changes, the final object changes too. Optionally, you can give a delta Vector to move the clone from the original position. If forcedraft is True, the resulting object is a Draft clone - even if the input object is an Arch object.''' + even if the input object is an Arch object.""" prefix = getParam("ClonePrefix","") cl = None @@ -2699,9 +2698,9 @@ def clone(obj,delta=None,forcedraft=False): return cl def getCloneBase(obj,strict=False): - '''getCloneBase(obj,[strict]): returns the object cloned by this object, if + """getCloneBase(obj,[strict]): returns the object cloned by this object, if any, or this object if it is no clone. If strict is True, if this object is - not a clone, this function returns False''' + not a clone, this function returns False""" if hasattr(obj,"CloneOf"): if obj.CloneOf: return getCloneBase(obj.CloneOf) @@ -2713,8 +2712,8 @@ def getCloneBase(obj,strict=False): def mirror(objlist,p1,p2): - '''mirror(objlist,p1,p2,[clone]): creates a mirrored version of the given object(s) - along an axis that passes through the two vectors p1 and p2.''' + """mirror(objlist,p1,p2,[clone]): creates a mirrored version of the given object(s) + along an axis that passes through the two vectors p1 and p2.""" if not objlist: FreeCAD.Console.PrintError(translate("draft","No object given")+"\n") @@ -2748,11 +2747,11 @@ def mirror(objlist,p1,p2): def heal(objlist=None,delete=True,reparent=True): - '''heal([objlist],[delete],[reparent]) - recreates Draft objects that are damaged, + """heal([objlist],[delete],[reparent]) - recreates Draft objects that are damaged, for example if created from an earlier version. If delete is True, the damaged objects are deleted (default). If ran without arguments, all the objects in the document will be healed if they are damaged. If reparent is True (default), - new objects go at the very same place in the tree than their original.''' + new objects go at the very same place in the tree than their original.""" auto = False @@ -3461,7 +3460,7 @@ def splitWires(objects): def makeWorkingPlaneProxy(placement): - "creates a Working Plane proxy object in the current document" + """creates a Working Plane proxy object in the current document""" if FreeCAD.ActiveDocument: obj = FreeCAD.ActiveDocument.addObject("App::FeaturePython","WPProxy") WorkingPlaneProxy(obj) @@ -3473,8 +3472,8 @@ def makeWorkingPlaneProxy(placement): return obj def getParameterFromV0(edge, offset): - '''return parameter at distance offset from edge.Vertexes[0]''' - '''sb method in Part.TopoShapeEdge???''' + """return parameter at distance offset from edge.Vertexes[0] + sb method in Part.TopoShapeEdge???""" lpt = edge.valueAt(edge.getParameterByLength(0)) vpt = edge.Vertexes[0].Point @@ -3490,7 +3489,7 @@ def getParameterFromV0(edge, offset): def calculatePlacement(globalRotation, edge, offset, RefPt, xlate, align, normal=None): - '''Orient shape to tangent at parm offset along edge.''' + """Orient shape to tangent at parm offset along edge.""" import functools # http://en.wikipedia.org/wiki/Euler_angles # start with null Placement point so translate goes to right place. @@ -3576,7 +3575,7 @@ def calculatePlacement(globalRotation, edge, offset, RefPt, xlate, align, normal def calculatePlacementsOnPath(shapeRotation, pathwire, count, xlate, align): - '''Calculates the placements of a shape along a given path so that each copy will be distributed evenly''' + """Calculates the placements of a shape along a given path so that each copy will be distributed evenly""" import Part import DraftGeomUtils @@ -3642,7 +3641,7 @@ def calculatePlacementsOnPath(shapeRotation, pathwire, count, xlate, align): #--------------------------------------------------------------------------- class _DraftObject: - "The base class for Draft objects" + """The base class for Draft objects""" def __init__(self,obj,tp="Unknown"): obj.Proxy = self self.Type = tp @@ -3661,7 +3660,7 @@ def onChanged(self, obj, prop): pass class _ViewProviderDraft: - "The base class for Draft Viewproviders" + """The base class for Draft Viewproviders""" def __init__(self, vobj): vobj.Proxy = self @@ -3788,7 +3787,7 @@ def claimChildren(self): return objs class _ViewProviderDraftAlt(_ViewProviderDraft): - "a view provider that doesn't swallow its base object" + """a view provider that doesn't swallow its base object""" def __init__(self,vobj): _ViewProviderDraft.__init__(self,vobj) @@ -3797,7 +3796,7 @@ def claimChildren(self): return [] class _ViewProviderDraftPart(_ViewProviderDraftAlt): - "a view provider that displays a Part icon instead of a Draft icon" + """a view provider that displays a Part icon instead of a Draft icon""" def __init__(self,vobj): _ViewProviderDraftAlt.__init__(self,vobj) @@ -3807,7 +3806,7 @@ def getIcon(self): class _Dimension(_DraftObject): - "The Draft Dimension object" + """The Draft Dimension object""" def __init__(self, obj): _DraftObject.__init__(self,obj,"Dimension") obj.addProperty("App::PropertyVectorDistance","Start","Draft",QT_TRANSLATE_NOOP("App::Property","Startpoint of dimension")) @@ -3890,7 +3889,7 @@ def execute(self, obj): class _ViewProviderDimension(_ViewProviderDraft): - "A View Provider for the Draft Dimension object" + """A View Provider for the Draft Dimension object""" def __init__(self, obj): obj.addProperty("App::PropertyLength","FontSize","Draft",QT_TRANSLATE_NOOP("App::Property","Font size")) obj.addProperty("App::PropertyInteger","Decimals","Draft",QT_TRANSLATE_NOOP("App::Property","The number of decimals to show")) @@ -3923,7 +3922,7 @@ def __init__(self, obj): _ViewProviderDraft.__init__(self,obj) def attach(self, vobj): - "called on object creation" + """called on object creation""" from pivy import coin self.Object = vobj.Object self.color = coin.SoBaseColor() @@ -3988,7 +3987,7 @@ def attach(self, vobj): self.onChanged(vobj,"ExtOvershoot") def updateData(self, obj, prop): - "called when the base object is changed" + """called when the base object is changed""" import DraftGui if prop in ["Start","End","Dimline","Direction"]: @@ -4165,7 +4164,7 @@ def updateData(self, obj, prop): self.line.coordIndex.setValues(0,4,(0,1,2,3)) def onChanged(self, vobj, prop): - "called when a view property has changed" + """called when a view property has changed""" if (prop == "FontSize") and hasattr(vobj,"FontSize"): if hasattr(self,"font"): @@ -4334,7 +4333,7 @@ def __setstate__(self,state): self.setDisplayMode(state) class _AngularDimension(_DraftObject): - "The Draft AngularDimension object" + """The Draft AngularDimension object""" def __init__(self, obj): _DraftObject.__init__(self,obj,"AngularDimension") obj.addProperty("App::PropertyAngle","FirstAngle","Draft",QT_TRANSLATE_NOOP("App::Property","Start angle of the dimension")) @@ -4364,7 +4363,7 @@ def execute(self, fp): fp.ViewObject.update() class _ViewProviderAngularDimension(_ViewProviderDraft): - "A View Provider for the Draft Angular Dimension object" + """A View Provider for the Draft Angular Dimension object""" def __init__(self, obj): obj.addProperty("App::PropertyLength","FontSize","Draft",QT_TRANSLATE_NOOP("App::Property","Font size")) obj.addProperty("App::PropertyInteger","Decimals","Draft",QT_TRANSLATE_NOOP("App::Property","The number of decimals to show")) @@ -4675,7 +4674,7 @@ def __setstate__(self,state): class _Rectangle(_DraftObject): - "The Rectangle object" + """The Rectangle object""" def __init__(self, obj): _DraftObject.__init__(self,obj,"Rectangle") @@ -4767,7 +4766,7 @@ def __init__(self,vobj): vobj.addProperty("App::PropertyFile","TextureImage","Draft",QT_TRANSLATE_NOOP("App::Property","Defines a texture image (overrides hatch patterns)")) class _Circle(_DraftObject): - "The Circle object" + """The Circle object""" def __init__(self, obj): _DraftObject.__init__(self,obj,"Circle") @@ -4796,7 +4795,7 @@ def execute(self, obj): obj.positionBySupport() class _Ellipse(_DraftObject): - "The Circle object" + """The Circle object""" def __init__(self, obj): _DraftObject.__init__(self,obj,"Ellipse") @@ -4836,7 +4835,7 @@ def execute(self, obj): obj.positionBySupport() class _Wire(_DraftObject): - "The Wire object" + """The Wire object""" def __init__(self, obj): _DraftObject.__init__(self,obj,"Wire") @@ -5003,7 +5002,7 @@ def onChanged(self, obj, prop): class _ViewProviderWire(_ViewProviderDraft): - "A View Provider for the Wire object" + """A View Provider for the Wire object""" def __init__(self, obj): _ViewProviderDraft.__init__(self,obj) obj.addProperty("App::PropertyBool","EndArrow","Draft",QT_TRANSLATE_NOOP("App::Property","Displays a Dimension symbol at the end of the wire")) @@ -5100,7 +5099,7 @@ def flatten(self): FreeCAD.Console.PrintMessage(translate("Draft","This Wire is already flat")+"\n") class _Polygon(_DraftObject): - "The Polygon object" + """The Polygon object""" def __init__(self, obj): _DraftObject.__init__(self,obj,"Polygon") @@ -5154,7 +5153,7 @@ def execute(self, obj): class _DrawingView(_DraftObject): - "The Draft DrawingView object" + """The Draft DrawingView object""" def __init__(self, obj): _DraftObject.__init__(self,obj,"DrawingView") obj.addProperty("App::PropertyVector","Direction","Shape View",QT_TRANSLATE_NOOP("App::Property","Projection direction")) @@ -5216,7 +5215,7 @@ def getDXF(self,obj): return getDXF(obj) class _BSpline(_DraftObject): - "The BSpline object" + """The BSpline object""" def __init__(self, obj): _DraftObject.__init__(self,obj,"BSpline") @@ -5296,7 +5295,7 @@ def execute(self, obj): _ViewProviderBSpline = _ViewProviderWire class _BezCurve(_DraftObject): - "The BezCurve object" + """The BezCurve object""" def __init__(self, obj): _DraftObject.__init__(self,obj,"BezCurve") @@ -5426,7 +5425,7 @@ def modifytangentpole(knot,p1,oldp2): _ViewProviderBezCurve = _ViewProviderWire class _Block(_DraftObject): - "The Block object" + """The Block object""" def __init__(self, obj): _DraftObject.__init__(self,obj,"Block") @@ -5445,7 +5444,7 @@ def execute(self, obj): obj.positionBySupport() class _Shape2DView(_DraftObject): - "The Shape2DView object" + """The Shape2DView object""" def __init__(self,obj): obj.addProperty("App::PropertyLink","Base","Draft",QT_TRANSLATE_NOOP("App::Property","The base object this 2D view must represent")) @@ -5622,7 +5621,7 @@ def execute(self,obj): obj.Placement = pl class _Array(_DraftObject): - "The Draft Array object" + """The Draft Array object""" def __init__(self,obj): _DraftObject.__init__(self,obj,"Array") @@ -5723,7 +5722,7 @@ def polarArray(self,shape,center,angle,num,axis,axisvector,fuse=False): class _PathArray(_DraftObject): - "The Draft Path Array object" + """The Draft Path Array object""" def __init__(self,obj): _DraftObject.__init__(self,obj,"PathArray") @@ -5786,7 +5785,7 @@ def pathArray(self,shape,pathwire,count,xlate,align): return (Part.makeCompound(base)) class _PointArray(_DraftObject): - "The Draft Point Array object" + """The Draft Point Array object""" def __init__(self, obj, bobj, ptlst): _DraftObject.__init__(self,obj,"PointArray") obj.addProperty("App::PropertyLink","Base","Draft",QT_TRANSLATE_NOOP("App::Property","Base")).Base = bobj @@ -5836,7 +5835,7 @@ def execute(self, obj): obj.Shape = obj.Base.Shape.copy() class _Point(_DraftObject): - "The Draft Point object" + """The Draft Point object""" def __init__(self, obj,x=0,y=0,z=0): _DraftObject.__init__(self,obj,"Point") obj.addProperty("App::PropertyDistance","X","Draft",QT_TRANSLATE_NOOP("App::Property","X Location")).X = x @@ -5852,7 +5851,7 @@ def execute(self, obj): obj.Placement.Base = FreeCAD.Vector(obj.X.Value,obj.Y.Value,obj.Z.Value) class _ViewProviderPoint(_ViewProviderDraft): - "A viewprovider for the Draft Point object" + """A viewprovider for the Draft Point object""" def __init__(self, obj): _ViewProviderDraft.__init__(self,obj) @@ -5874,7 +5873,7 @@ def getIcon(self): return ":/icons/Draft_Dot.svg" class _Clone(_DraftObject): - "The Clone object" + """The Clone object""" def __init__(self,obj): _DraftObject.__init__(self,obj,"Clone") @@ -5959,7 +5958,7 @@ def getSubVolume(self,obj,placement=None): return None class _ViewProviderClone: - "a view provider that displays a Clone icon instead of a Draft icon" + """a view provider that displays a Clone icon instead of a Draft icon""" def __init__(self,vobj): vobj.Proxy = self @@ -6005,7 +6004,7 @@ def resetColors(self, vobj): vobj.DiffuseColor = colors class _ViewProviderDraftArray(_ViewProviderDraft): - "a view provider that displays a Array icon instead of a Draft icon" + """a view provider that displays a Array icon instead of a Draft icon""" def __init__(self,vobj): _ViewProviderDraft.__init__(self,vobj) @@ -6041,7 +6040,7 @@ def resetColors(self, vobj): vobj.DiffuseColor = colors class _ShapeString(_DraftObject): - "The ShapeString object" + """The ShapeString object""" def __init__(self, obj): _DraftObject.__init__(self,obj,"ShapeString") @@ -6190,7 +6189,7 @@ def makeGlyph(self, facelist): class _Facebinder(_DraftObject): - "The Draft Facebinder object" + """The Draft Facebinder object""" def __init__(self,obj): _DraftObject.__init__(self,obj,"Facebinder") obj.addProperty("App::PropertyLinkSubList","Faces","Draft",QT_TRANSLATE_NOOP("App::Property","Linked faces")) @@ -6252,7 +6251,7 @@ def execute(self,obj): obj.Placement = pl def addSubobjects(self,obj,facelinks): - "adds facelinks to this facebinder" + """adds facelinks to this facebinder""" objs = obj.Faces for o in facelinks: if isinstance(o,tuple) or isinstance(o,list): @@ -6288,8 +6287,7 @@ def unsetEdit(self,vobj,mode): class WorkingPlaneProxy: - - "The Draft working plane proxy object" + """The Draft working plane proxy object""" def __init__(self,obj): obj.Proxy = self @@ -6325,8 +6323,7 @@ def __setstate__(self,state): class ViewProviderWorkingPlaneProxy: - - "A View Provider for working plane proxies" + """A View Provider for working plane proxies""" def __init__(self,vobj): # ViewData: 0,1,2: position; 3,4,5,6: rotation; 7: near dist; 8: far dist, 9:aspect ratio; @@ -6526,8 +6523,7 @@ def makeLabel(targetpoint=None,target=None,direction=None,distance=None,labeltyp class DraftLabel: - - "The Draft Label object" + """The Draft Label object""" def __init__(self,obj): obj.Proxy = self @@ -6609,8 +6605,7 @@ def __setstate__(self,state): class ViewProviderDraftLabel: - - "A View Provider for the Draft Label" + """A View Provider for the Draft Label""" def __init__(self,vobj): vobj.addProperty("App::PropertyLength","TextSize","Base",QT_TRANSLATE_NOOP("App::Property","The size of the text")) @@ -6837,8 +6832,7 @@ def __setstate__(self,state): class DraftText: - - "The Draft Text object" + """The Draft Text object""" def __init__(self,obj): obj.Proxy = self @@ -6851,8 +6845,7 @@ def execute(self,obj): class ViewProviderDraftText: - - "A View Provider for the Draft Label" + """A View Provider for the Draft Label""" def __init__(self,vobj): vobj.addProperty("App::PropertyLength","FontSize","Base",QT_TRANSLATE_NOOP("App::Property","The size of the text")) @@ -6963,7 +6956,7 @@ def __setstate__(self,state): def convertDraftTexts(textslist=[]): - "converts the given Draft texts (or all that are found in the active document) to the new object" + """converts the given Draft texts (or all that are found in the active document) to the new object""" if not isinstance(textslist,list): textslist = [textslist] if not textslist: