Skip to content

Commit

Permalink
Draft: polygon tool can now use Part::RegularPolygon - fixes #1305
Browse files Browse the repository at this point in the history
  • Loading branch information
yorikvanhavre committed Nov 14, 2013
1 parent 0b6c21c commit 6987a70
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
29 changes: 21 additions & 8 deletions src/Mod/Draft/DraftTools.py
Expand Up @@ -1263,14 +1263,27 @@ def action(self,arg):

def drawPolygon(self):
"actually draws the FreeCAD object"
rot,sup,pts,fil = self.getStrings()
# building command string
self.commit(translate("draft","Create Polygon"),
['import Draft',
'pl=FreeCAD.Placement()',
'pl.Rotation.Q='+rot,
'pl.Base='+DraftVecUtils.toString(self.center),
'Draft.makePolygon('+str(self.ui.numFaces.value())+',radius='+str(self.rad)+',inscribed=True,placement=pl,face='+fil+',support='+sup+')'])
rot,sup,pts,fil = self.getStrings()
if Draft.getParam("UsePartPrimitives",False):
self.commit(translate("draft","Create Polygon"),
['import Part',
'pl=FreeCAD.Placement()',
'pl.Rotation.Q=' + rot,
'pl.Base=' + DraftVecUtils.toString(self.center),
'pol = FreeCAD.ActiveDocument.addObject("Part::RegularPolygon","Polygon")',
'pol.NumberOfSides = ' + str(self.ui.numFaces.value()),
'pol.Radius = ' + str(self.rad),
'pol.Placement = pl',
'FreeCAD.ActiveDocument.recompute()'])
else:
# building command string
self.commit(translate("draft","Create Polygon"),
['import Draft',
'pl=FreeCAD.Placement()',
'pl.Rotation.Q=' + rot,
'pl.Base=' + DraftVecUtils.toString(self.center),
'Draft.makePolygon(' + str(self.ui.numFaces.value()) + ',radius=' + str(self.rad) + ',inscribed=True,placement=pl,face=' + fil + ',support=' + sup + ')'])
FreeCAD.ActiveDocument.recompute()
self.finish(cont=True)

def numericInput(self,numx,numy,numz):
Expand Down
1 change: 1 addition & 0 deletions src/Mod/Draft/DraftTrackers.py
Expand Up @@ -366,6 +366,7 @@ def __init__(self,dotted=False,scolor=None,swidth=None,start=0,end=math.pi*2,nor

def getDeviation(self):
"returns a deviation vector that represents the base of the circle"
import Part
c = Part.makeCircle(1,Vector(0,0,0),self.normal)
return c.Vertexes[0].Point

Expand Down

0 comments on commit 6987a70

Please sign in to comment.