Offload code from FuseCompound.py for re-use in other modules

This commit is contained in:
DeepSOIC 2015-09-14 00:11:17 +03:00
parent f873ac5466
commit d194155080
2 changed files with 30 additions and 24 deletions

View File

@ -1,34 +1,13 @@
import FreeCAD, Part from latticeCommon import *
if FreeCAD.GuiUp:
import FreeCADGui
from PySide import QtCore, QtGui
__title__="FuseCompound module for FreeCAD" __title__="FuseCompound module for FreeCAD"
__author__ = "DeepSOIC" __author__ = "DeepSOIC"
__url__ = "" __url__ = ""
#-------------------------- translation-related code ----------------------------------------
#Thanks, yorik! (see forum thread "A new Part tool is being born... JoinFeatures!"
#http://forum.freecadweb.org/viewtopic.php?f=22&t=11112&start=30#p90239 )
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
def _fromUtf8(s):
return s
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig)
#--------------------------/translation-related code ----------------------------------------
# -------------------------- common stuff -------------------------------------------------- # -------------------------- common stuff --------------------------------------------------
def getParamRefine():
return FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Part/Boolean").GetBool("RefineModel")
def makeFuseCompound(name): def makeFuseCompound(name):
'''makeFuseCompound(name): makes a FuseCompound object.''' '''makeFuseCompound(name): makes a FuseCompound object.'''
@ -99,8 +78,6 @@ def CreateFuseCompound(name):
FreeCADGui.doCommand("f = None") FreeCADGui.doCommand("f = None")
FreeCAD.ActiveDocument.commitTransaction() FreeCAD.ActiveDocument.commitTransaction()
def getIconPath(icon_dot_svg):
return ":/icons/" + icon_dot_svg
# -------------------------- /common stuff -------------------------------------------------- # -------------------------- /common stuff --------------------------------------------------

29
latticeCommon.py Normal file
View File

@ -0,0 +1,29 @@
import FreeCAD, Part
if FreeCAD.GuiUp:
import FreeCADGui
from PySide import QtCore, QtGui
#-------------------------- translation-related code ----------------------------------------
#Thanks, yorik! (see forum thread "A new Part tool is being born... JoinFeatures!"
#http://forum.freecadweb.org/viewtopic.php?f=22&t=11112&start=30#p90239 )
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
def _fromUtf8(s):
return s
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig)
#--------------------------/translation-related code ----------------------------------------
def getParamRefine():
return FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Part/Boolean").GetBool("RefineModel")
def getIconPath(icon_dot_svg):
return ":/icons/" + icon_dot_svg