From ae9773fa73703804ccc12a1c3bfc4338fd0e4917 Mon Sep 17 00:00:00 2001 From: Adrian Insaurralde Avalos Date: Tue, 14 May 2024 00:20:32 -0400 Subject: [PATCH] Fix restoring object proxies adn view providers from old files --- Init.py | 37 ------------------------------------ SheetMetalBaseCmd.py | 6 ++++-- SheetMetalBaseShapeCmd.py | 6 ++++-- SheetMetalBend.py | 10 ++++++++++ SheetMetalCmd.py | 10 ++++++++++ SheetMetalCornerReliefCmd.py | 6 ++++-- SheetMetalExtendCmd.py | 14 ++++++++------ SheetMetalFoldCmd.py | 6 ++++-- SheetMetalForming.py | 8 ++++++-- SheetMetalFormingCmd.py | 12 ++++++++---- SheetMetalJunction.py | 8 +++++++- SheetMetalRelief.py | 6 ++++++ SketchOnSheetMetalCmd.py | 6 ++++-- 13 files changed, 75 insertions(+), 60 deletions(-) delete mode 100644 Init.py create mode 100644 SheetMetalBend.py create mode 100644 SheetMetalCmd.py diff --git a/Init.py b/Init.py deleted file mode 100644 index cc29199..0000000 --- a/Init.py +++ /dev/null @@ -1,37 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# Init.py -# -# Copyright 2015 Shai Seger -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2 of the License, or (at your option) any later version. -# -# 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 General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -# MA 02110-1301, USA. -# -# -############################################################################## - -import SheetMetalBaseShape -import SheetMetalBendWall -import SheetMetalBaseBend -import SheetMetalSolidBend -import SheetMetalFoldWall -import SheetMetalForming -import SheetMetalJunction -import SheetMetalRelief -import SketchOnSheetMetal -import SheetMetalCornerRelief -import SheetMetalExtend -import SheetMetalUnfolder \ No newline at end of file diff --git a/SheetMetalBaseCmd.py b/SheetMetalBaseCmd.py index 3a8ceea..2d3e524 100644 --- a/SheetMetalBaseCmd.py +++ b/SheetMetalBaseCmd.py @@ -25,8 +25,10 @@ import FreeCAD, os from FreeCAD import Gui -import SheetMetalTools -from SheetMetalBaseBend import SMBaseBend +import SheetMetalTools, SheetMetalBaseBend + +# kept around for compatibility with old files +SMBaseBend = SheetMetalBaseBend.SMBaseBend translate = FreeCAD.Qt.translate icons_path = SheetMetalTools.icons_path diff --git a/SheetMetalBaseShapeCmd.py b/SheetMetalBaseShapeCmd.py index ddfaf81..a082529 100644 --- a/SheetMetalBaseShapeCmd.py +++ b/SheetMetalBaseShapeCmd.py @@ -23,11 +23,13 @@ # ################################################################################### -import FreeCAD, os, SheetMetalTools +import FreeCAD, os, SheetMetalTools, SheetMetalBaseShape from PySide import QtCore from FreeCAD import Gui from SheetMetalLogger import SMLogger -from SheetMetalBaseShape import SMBaseShape + +# kept around for compatibility with old files +SMBaseShape = SheetMetalBaseShape.SMBaseShape icons_path = SheetMetalTools.icons_path panels_path = SheetMetalTools.panels_path diff --git a/SheetMetalBend.py b/SheetMetalBend.py new file mode 100644 index 0000000..a6b1cec --- /dev/null +++ b/SheetMetalBend.py @@ -0,0 +1,10 @@ +import SheetMetalSolidBend +from SheetMetalTools import isGuiLoaded + +# kept around for compatibility with old files +SMSolidBend = SheetMetalSolidBend.SMSolidBend + +if isGuiLoaded(): + import SheetMetalSolidBendCmd + SMBendViewProviderTree = SheetMetalSolidBendCmd.SMBendViewProviderTree + SMBendViewProviderFlat = SheetMetalSolidBendCmd.SMBendViewProviderFlat diff --git a/SheetMetalCmd.py b/SheetMetalCmd.py new file mode 100644 index 0000000..15aa93e --- /dev/null +++ b/SheetMetalCmd.py @@ -0,0 +1,10 @@ +import SheetMetalBendWall +from SheetMetalTools import isGuiLoaded + +# kept around for compatibility with old files +SMBendWall = SheetMetalBendWall.SMBendWall + +if isGuiLoaded(): + import SheetMetalBendWallCmd + SMViewProviderTree = SheetMetalBendWallCmd.SMViewProviderTree + SMViewProviderFlat = SheetMetalBendWallCmd.SMViewProviderFlat diff --git a/SheetMetalCornerReliefCmd.py b/SheetMetalCornerReliefCmd.py index 8401237..99ef3b2 100644 --- a/SheetMetalCornerReliefCmd.py +++ b/SheetMetalCornerReliefCmd.py @@ -23,9 +23,11 @@ # ################################################################################### -import FreeCAD, Part, os, SheetMetalTools +import FreeCAD, Part, os, SheetMetalTools, SheetMetalCornerRelief from FreeCAD import Gui -from SheetMetalCornerRelief import SMCornerRelief + +# kept around for compatibility with old files +SMCornerRelief = SheetMetalCornerRelief.SMCornerRelief icons_path = SheetMetalTools.icons_path diff --git a/SheetMetalExtendCmd.py b/SheetMetalExtendCmd.py index 7e49e91..ac28cac 100644 --- a/SheetMetalExtendCmd.py +++ b/SheetMetalExtendCmd.py @@ -23,10 +23,12 @@ # ################################################################################### -import FreeCAD, Part, os, SheetMetalTools +import FreeCAD, Part, os, SheetMetalTools,SheetMetalExtend from FreeCAD import Gui from PySide import QtCore, QtGui -from SheetMetalExtend import SMExtrudeWall + +# kept around for compatibility with old files +SMExtrudeWall = SheetMetalExtend.SMExtrudeWall icons_path = SheetMetalTools.icons_path @@ -95,7 +97,7 @@ def getIcon(self): return os.path.join( icons_path , 'SheetMetal_Extrude.svg') def setEdit(self,vobj,mode): - taskd = SMBendWallTaskPanel() + taskd = SMExtendWallTaskPanel() taskd.obj = vobj.Object taskd.update() self.Object.ViewObject.Visibility=False @@ -160,7 +162,7 @@ def getIcon(self): return os.path.join( icons_path , 'SheetMetal_Extrude.svg') def setEdit(self,vobj,mode): - taskd = SMBendWallTaskPanel() + taskd = SMExtendWallTaskPanel() taskd.obj = vobj.Object taskd.update() self.Object.ViewObject.Visibility=False @@ -174,13 +176,13 @@ def unsetEdit(self,vobj,mode): self.Object.ViewObject.Visibility=True return False -class SMBendWallTaskPanel: +class SMExtendWallTaskPanel: '''A TaskPanel for the Sheetmetal''' def __init__(self): self.obj = None self.form = QtGui.QWidget() - self.form.setObjectName("SMBendWallTaskPanel") + self.form.setObjectName("SMExtendWallTaskPanel") self.form.setWindowTitle("Binded faces/edges list") self.grid = QtGui.QGridLayout(self.form) self.grid.setObjectName("grid") diff --git a/SheetMetalFoldCmd.py b/SheetMetalFoldCmd.py index 7645139..2a8e83a 100644 --- a/SheetMetalFoldCmd.py +++ b/SheetMetalFoldCmd.py @@ -23,9 +23,11 @@ # ############################################################################## -import FreeCAD, Part, os, SheetMetalTools +import FreeCAD, Part, os, SheetMetalTools, SheetMetalFoldWall from FreeCAD import Gui -from SheetMetalFoldWall import SMFoldWall + +# kept around for compatibility with old files +SMFoldWall = SheetMetalFoldWall.SMFoldWall icons_path = SheetMetalTools.icons_path diff --git a/SheetMetalForming.py b/SheetMetalForming.py index 5129b0d..30cf445 100644 --- a/SheetMetalForming.py +++ b/SheetMetalForming.py @@ -76,7 +76,7 @@ def makeforming(tool, base, base_face, thk, tool_faces = None, point = FreeCAD.V #Part.show(base, "base") return base -class SMBendWall: +class SMFormingWall: def __init__(self, obj): '''"Add Forming Wall" ''' @@ -126,4 +126,8 @@ def execute(self, fp): base = a else : a = base - fp.Shape = a \ No newline at end of file + fp.Shape = a + + +# kept around for compatibility with files from ondsel-es 2024.2.0 +SMBendWall = SMFormingWall diff --git a/SheetMetalFormingCmd.py b/SheetMetalFormingCmd.py index 3a26335..1aad886 100644 --- a/SheetMetalFormingCmd.py +++ b/SheetMetalFormingCmd.py @@ -26,7 +26,11 @@ import FreeCAD, Part, os, SheetMetalTools from FreeCAD import Gui from PySide import QtCore, QtGui -from SheetMetalForming import SMBendWall +from SheetMetalForming import SMFormingWall + +# kept around for compatibility with old files +SMBendWall = SMFormingWall + icons_path = SheetMetalTools.icons_path @@ -193,7 +197,7 @@ def __init__(self): self.obj = None self.form = QtGui.QWidget() - self.form.setObjectName("SMBendWallTaskPanel") + self.form.setObjectName("SMFormingWallTaskPanel") self.form.setWindowTitle("Binded faces/edges list") self.grid = QtGui.QGridLayout(self.form) self.grid.setObjectName("grid") @@ -335,14 +339,14 @@ def Activated(self): doc.openTransaction("WallForming") if activeBody is None or not SheetMetalTools.smIsPartDesign(selobj): a = doc.addObject("Part::FeaturePython","WallForming") - SMBendWall(a) + SMFormingWall(a) a.baseObject = (selobj, sel[0].SubElementNames) a.toolObject = (sel[1].Object, sel[1].SubElementNames) SMFormingVP(a.ViewObject) else: #FreeCAD.Console.PrintLog("found active body: " + activeBody.Name) a = doc.addObject("PartDesign::FeaturePython","WallForming") - SMBendWall(a) + SMFormingWall(a) a.baseObject = (selobj, sel[0].SubElementNames) a.toolObject = (sel[1].Object, sel[1].SubElementNames) SMFormingPDVP(a.ViewObject) diff --git a/SheetMetalJunction.py b/SheetMetalJunction.py index a47e8ac..ef08ba8 100644 --- a/SheetMetalJunction.py +++ b/SheetMetalJunction.py @@ -1,4 +1,4 @@ -import FreeCAD, Part +import FreeCAD, Part, SheetMetalTools # IMPORTANT: please remember to change the element map version in case of any # changes in modeling logic @@ -56,3 +56,9 @@ def execute(self, fp): Main_Object = fp.baseObject[0].Shape.copy() s = smJunction(gap = fp.gap.Value, selEdgeNames = fp.baseObject[1], MainObject = Main_Object) fp.Shape = s + +# kept for compatibility with older files +if SheetMetalTools.isGuiLoaded(): + import SheetMetalJunctionCmd + SMJViewProviderTree = SheetMetalJunctionCmd.SMJViewProviderTree + SMJViewProviderFlat = SheetMetalJunctionCmd.SMJViewProviderFlat \ No newline at end of file diff --git a/SheetMetalRelief.py b/SheetMetalRelief.py index 15749aa..e6240a7 100644 --- a/SheetMetalRelief.py +++ b/SheetMetalRelief.py @@ -103,3 +103,9 @@ def execute(self, fp): Main_Object = fp.baseObject[0].Shape.copy() s = smRelief(relief = fp.relief.Value, selVertexNames = fp.baseObject[1], MainObject = Main_Object) fp.Shape = s + +# kept for compatibility with older files +if SheetMetalTools.isGuiLoaded(): + import SheetMetalReliefCmd + SMReliefViewProviderTree = SheetMetalReliefCmd.SMReliefViewProviderTree + SMReliefViewProviderFlat = SheetMetalReliefCmd.SMReliefViewProviderFlat \ No newline at end of file diff --git a/SketchOnSheetMetalCmd.py b/SketchOnSheetMetalCmd.py index f4983dd..815b4f0 100644 --- a/SketchOnSheetMetalCmd.py +++ b/SketchOnSheetMetalCmd.py @@ -23,9 +23,11 @@ # ############################################################################## -import FreeCAD, os, SheetMetalTools +import FreeCAD, os, SheetMetalTools, SketchOnSheetMetal from FreeCAD import Gui -from SketchOnSheetMetal import SMSketchOnSheet + +# kept around for compatibility with old files +SMSketchOnSheet = SketchOnSheetMetal.SMSketchOnSheet icons_path = SheetMetalTools.icons_path