Skip to content

Commit

Permalink
revert buggy ondsel changes
Browse files Browse the repository at this point in the history
  • Loading branch information
shaise committed Oct 21, 2024
1 parent 68f3a9d commit 6348811
Show file tree
Hide file tree
Showing 12 changed files with 886 additions and 679 deletions.
368 changes: 243 additions & 125 deletions Resources/panels/UnfoldOptions.ui

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions SheetMetalBaseCmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def smBase(
return wallSolid

class SMBaseBend:
def __init__(self, obj):
def __init__(self, obj, sketch):
'''"Add wall or Wall with radius bend"'''
_tip_ = translate("App::Property", "Bend Radius")
obj.addProperty(
Expand All @@ -129,7 +129,7 @@ def __init__(self, obj):
_tip_ = translate("App::Property", "Wall Sketch object")
obj.addProperty(
"App::PropertyLink", "BendSketch", "Parameters", _tip_
).BendSketch = None
).BendSketch = sketch
_tip_ = translate("App::Property", "Extrude Symmetric to Plane")
obj.addProperty(
"App::PropertyBool", "MidPlane", "Parameters", _tip_
Expand Down Expand Up @@ -162,6 +162,9 @@ def execute(self, fp):
)

fp.Shape = s
obj = Gui.ActiveDocument.getObject(fp.BendSketch.Name)
if obj:
obj.Visibility = False


##########################################################################################################
Expand Down Expand Up @@ -260,15 +263,13 @@ def Activated(self):
doc.openTransaction("BaseBend")
if activeBody is None:
a = doc.addObject("Part::FeaturePython", "BaseBend")
SMBaseBend(a)
SMBaseBend(a, selobj)
SMBaseViewProvider(a.ViewObject)
a.BendSketch = selobj
else:
# FreeCAD.Console.PrintLog("found active body: " + activeBody.Name)
a = doc.addObject("PartDesign::FeaturePython", "BaseBend")
SMBaseBend(a)
SMBaseBend(a, selobj)
SMBaseViewProvider(a.ViewObject)
a.BendSketch = selobj
activeBody.addObject(a)
doc.recompute()
doc.commitTransaction()
Expand Down
10 changes: 5 additions & 5 deletions SheetMetalBend.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,15 @@ def smSolidBend(radius = 1.0, selEdgeNames = '', MainObject = None):


class SMSolidBend:
def __init__(self, obj):
def __init__(self, obj, selobj, sel_elements):
'''"Add Bend to Solid" '''

_tip_ = FreeCAD.Qt.translate("App::Property","Bend Radius")
obj.addProperty("App::PropertyLength","radius","Parameters", _tip_).radius = 1.0

_tip_ = FreeCAD.Qt.translate("App::Property","Base object")
obj.addProperty("App::PropertyLinkSub", "baseObject", "Parameters", _tip_)
obj.addProperty("App::PropertyLinkSub", "baseObject", "Parameters", _tip_).baseObject = (selobj, sel_elements)
obj.Proxy = self

def getElementMapVersion(self, _fp, ver, _prop, restored):
if not restored:
Expand Down Expand Up @@ -390,13 +391,12 @@ def Activated(self):
doc.openTransaction("Add Bend")
if activeBody is None or not SheetMetalTools.smIsPartDesign(selobj):
a = doc.addObject("Part::FeaturePython","SolidBend")
SMSolidBend(a)
a.baseObject = (selobj, sel.SubElementNames)
SMSolidBend(a, selobj, sel.SubElementNames)
SMBendViewProviderTree(a.ViewObject)
else:
#FreeCAD.Console.PrintLog("found active body: " + activeBody.Name)
a = doc.addObject("PartDesign::FeaturePython","SolidBend")
SMSolidBend(a)
SMSolidBend(a, selobj, sel.SubElementNames)
SMBendViewProviderFlat(a.ViewObject)
activeBody.addObject(a)
SheetMetalTools.SetViewConfig(a, viewConf)
Expand Down
10 changes: 4 additions & 6 deletions SheetMetalCmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -1367,14 +1367,14 @@ def smBend(


class SMBendWall:
def __init__(self, obj):
def __init__(self, obj, selobj, sel_items):
'''"Add Wall with radius bend"'''
self._addProperties(obj)

_tip_ = translate("App::Property", "Base Object")
obj.addProperty(
"App::PropertyLinkSub", "baseObject", "Parameters", _tip_
)
).baseObject = (selobj, sel_items)
obj.Proxy = self

def _addProperties(self, obj):
Expand Down Expand Up @@ -2066,14 +2066,12 @@ def Activated(self):
doc.openTransaction("Bend")
if activeBody is None or not SheetMetalTools.smIsPartDesign(selobj):
a = doc.addObject("Part::FeaturePython", "Bend")
SMBendWall(a)
a.baseObject = (selobj, sel.SubElementNames)
SMBendWall(a, selobj, sel.SubElementNames)
SMViewProviderTree(a.ViewObject)
else:
# FreeCAD.Console.PrintLog("found active body: " + activeBody.Name)
a = doc.addObject("PartDesign::FeaturePython", "Bend")
SMBendWall(a)
a.baseObject = (selobj, sel.SubElementNames)
SMBendWall(a, selobj, sel.SubElementNames)
SMViewProviderFlat(a.ViewObject)
activeBody.addObject(a)
SheetMetalTools.SetViewConfig(a, viewConf)
Expand Down
10 changes: 4 additions & 6 deletions SheetMetalCornerReliefCmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,9 +433,8 @@ def smCornerR(


class SMCornerRelief:
def __init__(self, obj):
def __init__(self, obj, selobj, sel_items):
'''"Add Corner Relief to Sheetmetal Bends"'''
selobj = Gui.Selection.getSelectionEx()
_tip_ = FreeCAD.Qt.translate("App::Property", "Corner Relief Type")
obj.addProperty(
"App::PropertyEnumeration", "ReliefSketch", "Parameters", _tip_
Expand All @@ -449,7 +448,7 @@ def __init__(self, obj):
_tip_ = FreeCAD.Qt.translate("App::Property", "Base object")
obj.addProperty(
"App::PropertyLinkSub", "baseObject", "Parameters", _tip_
).baseObject = (selobj[0].Object, selobj[0].SubElementNames)
).baseObject = (selobj, sel_items)
_tip_ = FreeCAD.Qt.translate("App::Property", "Size of Shape")
obj.addProperty("App::PropertyLength", "Size", "Parameters", _tip_).Size = 3.0
_tip_ = FreeCAD.Qt.translate("App::Property", "Size Ratio of Shape")
Expand Down Expand Up @@ -640,13 +639,12 @@ def Activated(self):
doc.openTransaction("Corner Relief")
if activeBody is None or not SheetMetalTools.smIsPartDesign(selobj):
a = doc.addObject("Part::FeaturePython", "CornerRelief")
SMCornerRelief(a)
a.baseObject = (selobj, sel.SubElementNames)
SMCornerRelief(a, selobj, sel.SubElementNames)
SMCornerReliefVP(a.ViewObject)
else:
# FreeCAD.Console.PrintLog("found active body: " + activeBody.Name)
a = doc.addObject("PartDesign::FeaturePython", "CornerRelief")
SMCornerRelief(a)
SMCornerRelief(a, selobj, sel.SubElementNames)
SMCornerReliefPDVP(a.ViewObject)
activeBody.addObject(a)
SheetMetalTools.SetViewConfig(a, viewConf)
Expand Down
10 changes: 4 additions & 6 deletions SheetMetalExtendCmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ def smExtrude(extLength = 10.0, gap1 = 0.0, gap2 = 0.0, subtraction = False, off
return finalShape

class SMExtrudeWall:
def __init__(self, obj):
def __init__(self, obj, selobj, sel_items):
'''"Add Sheetmetal Wall by Extending" '''

_tip_ = FreeCAD.Qt.translate("App::Property","Length of Wall")
Expand All @@ -273,7 +273,7 @@ def __init__(self, obj):
_tip_ = FreeCAD.Qt.translate("App::Property","Gap from right side")
obj.addProperty("App::PropertyDistance","gap2","Parameters",_tip_).gap2 = 0.0
_tip_ = FreeCAD.Qt.translate("App::Property","Base object")
obj.addProperty("App::PropertyLinkSub", "baseObject", "Parameters",_tip_).baseObject
obj.addProperty("App::PropertyLinkSub", "baseObject", "Parameters",_tip_).baseObject = (selobj, sel_items)
_tip_ = FreeCAD.Qt.translate("App::Property","Wall Sketch")
obj.addProperty("App::PropertyLink","Sketch","ParametersExt",_tip_)
_tip_ = FreeCAD.Qt.translate("App::Property","Use Subtraction")
Expand Down Expand Up @@ -579,13 +579,11 @@ def Activated(self):
doc.openTransaction("Extend")
if (activeBody is None):
a = doc.addObject("Part::FeaturePython","Extend")
SMExtrudeWall(a)
a.baseObject = (selobj, sel.SubElementNames)
SMExtrudeWall(a, selobj, sel.SubElementNames)
SMViewProviderTree(a.ViewObject)
else:
a = doc.addObject("PartDesign::FeaturePython","Extend")
SMExtrudeWall(a)
a.baseObject = (selobj, sel.SubElementNames)
SMExtrudeWall(a, selobj, sel.SubElementNames)
SMViewProviderFlat(a.ViewObject)
activeBody.addObject(a)
SheetMetalTools.SetViewConfig(a, viewConf)
Expand Down
18 changes: 8 additions & 10 deletions SheetMetalFoldCmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def smFold(
facenormal = cutFaceDir.Faces[0].normalAt(0, 0)
# print(facenormal)

if position == "middle":
if position == "middle" or position == "intersection of planes":
tool.translate(facenormal * -unfoldLength / 2.0)
toolFaces = tool.extrude(normal * -thk)
elif position == "backward":
Expand Down Expand Up @@ -243,11 +243,13 @@ def smFold(
else:
if bendlinesketch and bendA > 0.0:
resultsolid = FoldShape
Gui.ActiveDocument.getObject(MainObject.Name).Visibility = False
Gui.ActiveDocument.getObject(bendlinesketch.Name).Visibility = False
return resultsolid


class SMFoldWall:
def __init__(self, obj):
def __init__(self, obj, selobj, sel_items, sel_sketch):
'''"Fold / Bend a Sheetmetal with given Bend Radius"'''

_tip_ = FreeCAD.Qt.translate("App::Property", "Bend Radius")
Expand All @@ -259,11 +261,11 @@ def __init__(self, obj):
_tip_ = FreeCAD.Qt.translate("App::Property", "Base Object")
obj.addProperty(
"App::PropertyLinkSub", "baseObject", "Parameters", _tip_
)
).baseObject = (selobj, sel_items)
_tip_ = FreeCAD.Qt.translate("App::Property", "Bend Reference Line List")
obj.addProperty(
"App::PropertyLink", "BendLine", "Parameters", _tip_
)
).BendLine = sel_sketch
_tip_ = FreeCAD.Qt.translate("App::Property", "Invert Solid Bend Direction")
obj.addProperty(
"App::PropertyBool", "invertbend", "Parameters", _tip_
Expand Down Expand Up @@ -458,16 +460,12 @@ def Activated(self):
doc.openTransaction("Bend")
if activeBody is None or not SheetMetalTools.smIsPartDesign(selobj):
a = doc.addObject("Part::FeaturePython", "Fold")
SMFoldWall(a)
a.baseObject = (selobj, sel[0].SubElementNames)
a.BendLine = sel[1].Object
SMFoldWall(a, selobj, sel[0].SubElementNames, sel[1].Object)
SMFoldViewProvider(a.ViewObject)
else:
# FreeCAD.Console.PrintLog("found active body: " + activeBody.Name)
a = doc.addObject("PartDesign::FeaturePython", "Fold")
SMFoldWall(a)
a.baseObject = (selobj, sel[0].SubElementNames)
a.BendLine = sel[1].Object
SMFoldWall(a, selobj, sel[0].SubElementNames, sel[1].Object)
SMFoldPDViewProvider(a.ViewObject)
activeBody.addObject(a)
SheetMetalTools.SetViewConfig(a, viewConf)
Expand Down
20 changes: 11 additions & 9 deletions SheetMetalFormingCmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def makeforming(tool, base, base_face, thk, tool_faces = None, point = FreeCAD.V
return base

class SMBendWall:
def __init__(self, obj):
def __init__(self, obj, selobj, selobj_items, seltool, seltool_items):
'''"Add Forming Wall" '''

_tip_ = FreeCAD.Qt.translate("App::Property","Offset from Center of Face")
Expand All @@ -117,9 +117,11 @@ def __init__(self, obj):
_tip_ = FreeCAD.Qt.translate("App::Property","Thickness of Sheetmetal")
obj.addProperty("App::PropertyDistance","thickness","Parameters",_tip_)
_tip_ = FreeCAD.Qt.translate("App::Property","Base Object")
obj.addProperty("App::PropertyLinkSub", "baseObject", "Parameters",_tip_)
obj.addProperty("App::PropertyLinkSub", "baseObject", "Parameters",
_tip_).baseObject = (selobj, selobj_items)
_tip_ = FreeCAD.Qt.translate("App::Property","Forming Tool Object")
obj.addProperty("App::PropertyLinkSub", "toolObject", "Parameters",_tip_)
obj.addProperty("App::PropertyLinkSub", "toolObject", "Parameters",
_tip_).toolObject = (seltool, seltool_items)
_tip_ = FreeCAD.Qt.translate("App::Property","Point Sketch on Sheetmetal")
obj.addProperty("App::PropertyLink","Sketch","Parameters1",_tip_)
obj.Proxy = self
Expand Down Expand Up @@ -155,6 +157,10 @@ def execute(self, fp):
else :
a = base
fp.Shape = a
Gui.ActiveDocument.getObject(fp.baseObject[0].Name).Visibility = False
Gui.ActiveDocument.getObject(fp.toolObject[0].Name).Visibility = False
if fp.Sketch:
Gui.ActiveDocument.getObject(fp.Sketch.Name).Visibility = False


##########################################################################################################
Expand Down Expand Up @@ -472,16 +478,12 @@ def Activated(self):
doc.openTransaction("WallForming")
if activeBody is None or not SheetMetalTools.smIsPartDesign(selobj):
a = doc.addObject("Part::FeaturePython","WallForming")
SMBendWall(a)
a.baseObject = (selobj, sel[0].SubElementNames)
a.toolObject = (sel[1].Object, sel[1].SubElementNames)
SMBendWall(a, selobj, sel[0].SubElementNames, 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)
a.baseObject = (selobj, sel[0].SubElementNames)
a.toolObject = (sel[1].Object, sel[1].SubElementNames)
SMBendWall(a, selobj, sel[0].SubElementNames, sel[1].Object, sel[1].SubElementNames)
SMFormingPDVP(a.ViewObject)
activeBody.addObject(a)
SheetMetalTools.SetViewConfig(a, viewConf)
Expand Down
Loading

0 comments on commit 6348811

Please sign in to comment.