Skip to content

Commit

Permalink
Fix restoring object proxies adn view providers from old files
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianinsaval committed May 14, 2024
1 parent 47a7f80 commit ae9773f
Show file tree
Hide file tree
Showing 13 changed files with 75 additions and 60 deletions.
37 changes: 0 additions & 37 deletions Init.py

This file was deleted.

6 changes: 4 additions & 2 deletions SheetMetalBaseCmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions SheetMetalBaseShapeCmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions SheetMetalBend.py
Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions SheetMetalCmd.py
Original file line number Diff line number Diff line change
@@ -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
6 changes: 4 additions & 2 deletions SheetMetalCornerReliefCmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 8 additions & 6 deletions SheetMetalExtendCmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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")
Expand Down
6 changes: 4 additions & 2 deletions SheetMetalFoldCmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 6 additions & 2 deletions SheetMetalForming.py
Original file line number Diff line number Diff line change
Expand Up @@ -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" '''

Expand Down Expand Up @@ -126,4 +126,8 @@ def execute(self, fp):
base = a
else :
a = base
fp.Shape = a
fp.Shape = a


# kept around for compatibility with files from ondsel-es 2024.2.0
SMBendWall = SMFormingWall
12 changes: 8 additions & 4 deletions SheetMetalFormingCmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 7 additions & 1 deletion SheetMetalJunction.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
6 changes: 6 additions & 0 deletions SheetMetalRelief.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 4 additions & 2 deletions SketchOnSheetMetalCmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit ae9773f

Please sign in to comment.