Tool Library replaces ToolTable Job replaces Project
This commit is contained in:
committed by
Yorik van Havre
parent
0bca05a5f2
commit
cddccdf4c7
@@ -1,43 +1,45 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
#***************************************************************************
|
||||
#* *
|
||||
#* Copyright (c) 2015 Dan Falck <ddfalck@gmail.com> *
|
||||
#* *
|
||||
#* This program is free software; you can redistribute it and/or modify *
|
||||
#* it under the terms of the GNU Lesser General Public License (LGPL) *
|
||||
#* as published by the Free Software Foundation; either version 2 of *
|
||||
#* the License, or (at your option) any later version. *
|
||||
#* for detail see the LICENCE text file. *
|
||||
#* *
|
||||
#* This program is distributed in the hope that it will be useful, *
|
||||
#* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
#* GNU Library General Public License for more details. *
|
||||
#* *
|
||||
#* You should have received a copy of the GNU Library General Public *
|
||||
#* License along with this program; if not, write to the Free Software *
|
||||
#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
|
||||
#* USA *
|
||||
#* *
|
||||
#***************************************************************************
|
||||
# ***************************************************************************
|
||||
# * *
|
||||
# * Copyright (c) 2015 Dan Falck <ddfalck@gmail.com> *
|
||||
# * *
|
||||
# * This program is free software; you can redistribute it and/or modify *
|
||||
# * it under the terms of the GNU Lesser General Public License (LGPL) *
|
||||
# * as published by the Free Software Foundation; either version 2 of *
|
||||
# * the License, or (at your option) any later version. *
|
||||
# * for detail see the LICENCE text file. *
|
||||
# * *
|
||||
# * This program is distributed in the hope that it will be useful, *
|
||||
# * but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
# * GNU Library General Public License for more details. *
|
||||
# * *
|
||||
# * You should have received a copy of the GNU Library General Public *
|
||||
# * License along with this program; if not, write to the Free Software *
|
||||
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
|
||||
# * USA *
|
||||
# * *
|
||||
# ***************************************************************************
|
||||
'''used to create material stock around a machined part- for visualization '''
|
||||
|
||||
import Draft,Part
|
||||
import FreeCAD, FreeCADGui
|
||||
import FreeCAD
|
||||
import FreeCADGui
|
||||
from FreeCAD import Vector
|
||||
from PySide import QtCore, QtGui
|
||||
|
||||
import Part
|
||||
# Qt tanslation handling
|
||||
try:
|
||||
_encoding = QtGui.QApplication.UnicodeUTF8
|
||||
|
||||
def translate(context, text, disambig=None):
|
||||
return QtGui.QApplication.translate(context, text, disambig, _encoding)
|
||||
except AttributeError:
|
||||
def translate(context, text, disambig=None):
|
||||
return QtGui.QApplication.translate(context, text, disambig)
|
||||
|
||||
|
||||
class Stock:
|
||||
|
||||
def __init__(self, obj):
|
||||
"Make stock"
|
||||
obj.addProperty("App::PropertyFloat","Length_Allowance","Stock",QtCore.QT_TRANSLATE_NOOP("App::Property","extra allownace from part width")).Length_Allowance = 1.0
|
||||
@@ -49,7 +51,7 @@ class Stock:
|
||||
def __getstate__(self):
|
||||
return None
|
||||
|
||||
def __setstate__(self,state):
|
||||
def __setstate__(self, state):
|
||||
return None
|
||||
|
||||
def execute(self, obj):
|
||||
@@ -62,45 +64,49 @@ class Stock:
|
||||
self.Zmin = obj.Base.Shape.BoundBox.ZMin
|
||||
self.Zmax = obj.Base.Shape.BoundBox.ZMax
|
||||
|
||||
self.length = self.Xmax -self.Xmin+obj.Length_Allowance*2.0
|
||||
self.width = self.Ymax - self.Ymin+obj.Width_Allowance*2.0
|
||||
self.height = self.Zmax - self.Zmin+obj.Height_Allowance*2.0
|
||||
self.pnt = Vector(self.Xmin-obj.Length_Allowance , self.Ymin-obj.Width_Allowance, self.Zmin-obj.Height_Allowance)
|
||||
self.length = self.Xmax - self.Xmin + obj.Length_Allowance * 2.0
|
||||
self.width = self.Ymax - self.Ymin + obj.Width_Allowance * 2.0
|
||||
self.height = self.Zmax - self.Zmin + obj.Height_Allowance * 2.0
|
||||
self.pnt = Vector(self.Xmin - obj.Length_Allowance, self.Ymin -
|
||||
obj.Width_Allowance, self.Zmin - obj.Height_Allowance)
|
||||
|
||||
obj.Shape = Part.makeBox(
|
||||
self.length, self.width, self.height, self.pnt)
|
||||
|
||||
obj.Shape = Part.makeBox(self.length,self.width,self.height,self.pnt)
|
||||
|
||||
class _ViewProviderStock:
|
||||
|
||||
def __init__(self,obj): #mandatory
|
||||
# obj.addProperty("App::PropertyFloat","SomePropertyName","PropertyGroup","Description of this property")
|
||||
def __init__(self, obj): # mandatory
|
||||
# obj.addProperty("App::PropertyFloat","SomePropertyName","PropertyGroup","Description of this property")
|
||||
obj.Proxy = self
|
||||
|
||||
def __getstate__(self): #mandatory
|
||||
def __getstate__(self): # mandatory
|
||||
return None
|
||||
|
||||
def __setstate__(self,state): #mandatory
|
||||
def __setstate__(self, state): # mandatory
|
||||
return None
|
||||
|
||||
def getIcon(self): #optional
|
||||
def getIcon(self): # optional
|
||||
return ":/icons/Path-Stock.svg"
|
||||
|
||||
def attach(self, vobj): #optional
|
||||
def attach(self, vobj): # optional
|
||||
self.Object = vobj.Object
|
||||
|
||||
|
||||
|
||||
class CommandPathStock:
|
||||
|
||||
def GetResources(self):
|
||||
return {'Pixmap' : 'Path-Stock',
|
||||
'MenuText': QtCore.QT_TRANSLATE_NOOP("PathStock","Stock"),
|
||||
return {'Pixmap': 'Path-Stock',
|
||||
'MenuText': QtCore.QT_TRANSLATE_NOOP("PathStock", "Stock"),
|
||||
'Accel': "P, S",
|
||||
'ToolTip': QtCore.QT_TRANSLATE_NOOP("PathStock","Creates a 3D object to represent raw stock to mill the part out of")}
|
||||
'ToolTip': QtCore.QT_TRANSLATE_NOOP("PathStock", "Creates a 3D object to represent raw stock to mill the part out of")}
|
||||
|
||||
def IsActive(self):
|
||||
return not FreeCAD.ActiveDocument is None
|
||||
return FreeCAD.ActiveDocument is not None
|
||||
|
||||
def Activated(self):
|
||||
FreeCAD.ActiveDocument.openTransaction(translate("PathStock","Creates a 3D object to represent raw stock to mill the part out of"))
|
||||
FreeCAD.ActiveDocument.openTransaction(translate(
|
||||
"PathStock", "Creates a 3D object to represent raw stock to mill the part out of"))
|
||||
FreeCADGui.addModule("PathScripts.PathStock")
|
||||
snippet = '''
|
||||
import FreeCADGui
|
||||
@@ -111,7 +117,7 @@ if len(FreeCADGui.Selection.getSelection())>0:
|
||||
obj =FreeCAD.ActiveDocument.addObject('Part::FeaturePython',sel[0].Name+('_Stock'))
|
||||
PathScripts.PathStock.Stock(obj)
|
||||
PathScripts.PathStock._ViewProviderStock(obj.ViewObject)
|
||||
PathScripts.PathUtils.addToProject(obj)
|
||||
PathScripts.PathUtils.addToJob(obj)
|
||||
baseobj = sel[0]
|
||||
obj.Base = baseobj
|
||||
FreeCADGui.ActiveDocument.getObject(sel[0].Name+("_Stock")).ShapeColor = (0.3333,0.6667,1.0000)
|
||||
@@ -124,9 +130,8 @@ else:
|
||||
'''
|
||||
FreeCADGui.doCommand(snippet)
|
||||
|
||||
if FreeCAD.GuiUp:
|
||||
if FreeCAD.GuiUp:
|
||||
# register the FreeCAD command
|
||||
FreeCADGui.addCommand('Path_Stock',CommandPathStock())
|
||||
FreeCADGui.addCommand('Path_Stock', CommandPathStock())
|
||||
|
||||
FreeCAD.Console.PrintLog("Loading PathStock... done\n")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user