+ implement hexagon sketch

This commit is contained in:
wmayer
2014-06-03 14:54:27 +02:00
parent c05801d6ed
commit 5917d21395
6 changed files with 92 additions and 8 deletions

View File

@@ -23,12 +23,16 @@
import FreeCAD, Sketcher
if FreeCAD.GuiUp:
import FreeCADGui,SketcherGui
import FreeCADGui,SketcherGui,os
from PySide import QtCore, QtGui
from PySide.QtCore import Qt
from PySide.QtGui import QApplication, QCursor
from FreeCADGui import PySideUic as uic
#s=os.path.dirname(__file__)
#s=os.path.join(s,"ProfileLib")
#FreeCADGui.addIconPath(s)
__title__="Sketcher profile lib handling"
__author__ = "Juergen Riegel"
__url__ = "http://www.freecadweb.org"
@@ -37,19 +41,33 @@ __url__ = "http://www.freecadweb.org"
def isProfileActive():
return not FreeCAD.ActiveDocument is None
def getSketch():
edit = FreeCADGui.ActiveDocument.getInEdit()
if edit and edit.isDerivedFrom('SketcherGui::ViewProviderSketch'):
return edit.Object
#act = FreeCAD.ActiveDocument.ActiveObject
#if act and act.isDerivedFrom('Sketcher::SketchObject'):
# return act
return None
class _CommandProfileHexagon1:
"The basis hexagon profile command definition"
def GetResources(self):
return {'Pixmap' : 'Sketcher_Hexagon',
'MenuText': QtCore.QT_TRANSLATE_NOOP("Sketcher_ProfilesHexagon1","Creates a hexagon profile"),
'Accel': "",
'CmdType': "ForEdit",
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Sketcher_ProfilesHexagon1","Creates a hexagon profile in the sketch")}
def Activated(self):
FreeCAD.ActiveDocument.openTransaction("Create hexagon profile")
FreeCADGui.addModule("ProfileLib.Hexagon")
FreeCADGui.doCommand("ProfileLib.Hexagon.makeHexagonSimple()")
sketch = getSketch()
if not sketch is None:
FreeCADGui.doCommand("ProfileLib.Hexagon.makeHexagonSimple('%s')" % (sketch.Name))
else:
FreeCADGui.doCommand("ProfileLib.Hexagon.makeHexagonSimple()")
FreeCAD.ActiveDocument.recompute()
def IsActive(self):
return isProfileActive()