Skip to content

Commit

Permalink
Fix restoring object proxies and view providers from old files
Browse files Browse the repository at this point in the history
Increase version number
  • Loading branch information
adrianinsaval committed May 14, 2024
1 parent 47a7f80 commit 8605ca5
Show file tree
Hide file tree
Showing 18 changed files with 350 additions and 227 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
93 changes: 35 additions & 58 deletions SheetMetalJunction.py
Original file line number Diff line number Diff line change
@@ -1,58 +1,35 @@
import FreeCAD, Part

# IMPORTANT: please remember to change the element map version in case of any
# changes in modeling logic
smElementMapVersion = 'sm1.'

def smJunction(gap = 2.0, selEdgeNames = '', MainObject = None):
import BOPTools.SplitFeatures, BOPTools.JoinFeatures

resultSolid = MainObject
for selEdgeName in selEdgeNames:
edge = MainObject.getElement(selEdgeName)

facelist = MainObject.ancestorsOfType(edge, Part.Face)
#for face in facelist :
# Part.show(face,'face')

joinface = facelist[0].fuse(facelist[1])
#Part.show(joinface,'joinface')
filletedface = joinface.makeFillet(gap, joinface.Edges)
#Part.show(filletedface,'filletedface')

cutface1= facelist[0].cut(filletedface)
#Part.show(cutface1,'cutface1')
offsetsolid1 = cutface1.makeOffsetShape(-gap, 0.0, fill = True)
#Part.show(offsetsolid1,'offsetsolid1')

cutface2 = facelist[1].cut(filletedface)
#Part.show(cutface2,'cutface2')
offsetsolid2 = cutface2.makeOffsetShape(-gap, 0.0, fill = True)
#Part.show(offsetsolid2,'offsetsolid2')
cutsolid = offsetsolid1.fuse(offsetsolid2)
#Part.show(cutsolid,'cutsolid')
resultSolid = resultSolid.cut(cutsolid)
#Part.show(resultsolid,'resultsolid')

return resultSolid

class SMJunction:
def __init__(self, obj):
'''"Add Gap to Solid" '''

_tip_ = FreeCAD.Qt.translate("App::Property","Junction Gap")
obj.addProperty("App::PropertyLength","gap","Parameters",_tip_).gap = 2.0
_tip_ = FreeCAD.Qt.translate("App::Property","Base Object")
obj.addProperty("App::PropertyLinkSub", "baseObject", "Parameters",_tip_)
obj.Proxy = self

def getElementMapVersion(self, _fp, ver, _prop, restored):
if not restored:
return smElementMapVersion + ver

def execute(self, fp):
'''"Print a short message when doing a recomputation, this method is mandatory" '''
# pass selected object shape
Main_Object = fp.baseObject[0].Shape.copy()
s = smJunction(gap = fp.gap.Value, selEdgeNames = fp.baseObject[1], MainObject = Main_Object)
fp.Shape = s
# -*- coding: utf-8 -*-
###################################################################################
#
# SheetMetalJunction.py
#
# Copyright 2015 Shai Seger <shaise at gmail dot com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU 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 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 SheetMetalJunctionObj
from SheetMetalTools import isGuiLoaded

SMJunction = SheetMetalJunctionObj.SMJunction

# kept for compatibility with older files
if isGuiLoaded():
import SheetMetalJunctionCmd
SMJViewProviderTree = SheetMetalJunctionCmd.SMJViewProviderTree
SMJViewProviderFlat = SheetMetalJunctionCmd.SMJViewProviderFlat
4 changes: 2 additions & 2 deletions SheetMetalJunctionCmd.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
###################################################################################
#
# SheetMetalJunction.py
# SheetMetalJunctionCmd.py
#
# Copyright 2015 Shai Seger <shaise at gmail dot com>
#
Expand All @@ -26,7 +26,7 @@
import FreeCAD, Part, os, SheetMetalTools
from FreeCAD import Gui
from PySide import QtCore, QtGui
from SheetMetalJunction import SMJunction
from SheetMetalJunctionObj import SMJunction

icons_path = SheetMetalTools.icons_path

Expand Down
Loading

0 comments on commit 8605ca5

Please sign in to comment.