Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retain Shape Color and Transparency of base object #246

Merged
merged 9 commits into from Aug 4, 2022
11 changes: 11 additions & 0 deletions SheetMetalBend.py
Expand Up @@ -358,6 +358,11 @@ def Activated(self):
view = Gui.ActiveDocument.ActiveView
activeBody = None
selobj = Gui.Selection.getSelectionEx()[0].Object
selObjShapeCol = selobj.ViewObject.ShapeColor
selObjShapeTsp = selobj.ViewObject.Transparency
selObjDiffuseCol = selobj.ViewObject.DiffuseColor
# TODO Make the individual face colors be retained
# needDiffuseColorExtension = ( len(selobj.ViewObject.DiffuseColor) < len(selobj.Shape.Faces) )
if hasattr(view,'getActiveObject'):
activeBody = view.getActiveObject('pdbody')
if not smIsOperationLegal(activeBody, selobj):
Expand All @@ -367,12 +372,18 @@ def Activated(self):
a = doc.addObject("Part::FeaturePython","SolidBend")
SMSolidBend(a)
SMBendViewProviderTree(a.ViewObject)
a.ViewObject.ShapeColor = selObjShapeCol
a.ViewObject.Transparency = selObjShapeTsp
a.ViewObject.DiffuseColor = selObjDiffuseCol
else:
#FreeCAD.Console.PrintLog("found active body: " + activeBody.Name)
a = doc.addObject("PartDesign::FeaturePython","SolidBend")
SMSolidBend(a)
SMBendViewProviderFlat(a.ViewObject)
activeBody.addObject(a)
a.ViewObject.ShapeColor = selObjShapeCol
a.ViewObject.Transparency = selObjShapeTsp
a.ViewObject.DiffuseColor = selObjDiffuseCol
FreeCADGui.Selection.clearSelection()
doc.recompute()
doc.commitTransaction()
Expand Down
11 changes: 11 additions & 0 deletions SheetMetalCmd.py
Expand Up @@ -1364,6 +1364,11 @@ def Activated(self):
view = Gui.ActiveDocument.ActiveView
activeBody = None
selobj = Gui.Selection.getSelectionEx()[0].Object
selObjShapeCol = selobj.ViewObject.ShapeColor
selObjShapeTsp = selobj.ViewObject.Transparency
selObjDiffuseCol = selobj.ViewObject.DiffuseColor
# TODO Make the individual face colors be retained
# needDiffuseColorExtension = ( len(selobj.ViewObject.DiffuseColor) < len(selobj.Shape.Faces) )
if hasattr(view,'getActiveObject'):
activeBody = view.getActiveObject('pdbody')
if not smIsOperationLegal(activeBody, selobj):
Expand All @@ -1373,12 +1378,18 @@ def Activated(self):
a = doc.addObject("Part::FeaturePython","Bend")
SMBendWall(a)
SMViewProviderTree(a.ViewObject)
a.ViewObject.ShapeColor = selObjShapeCol
a.ViewObject.Transparency = selObjShapeTsp
a.ViewObject.DiffuseColor = selObjDiffuseCol
else:
#FreeCAD.Console.PrintLog("found active body: " + activeBody.Name)
a = doc.addObject("PartDesign::FeaturePython","Bend")
SMBendWall(a)
SMViewProviderFlat(a.ViewObject)
activeBody.addObject(a)
a.ViewObject.ShapeColor = selObjShapeCol
a.ViewObject.Transparency = selObjShapeTsp
a.ViewObject.DiffuseColor = selObjDiffuseCol
FreeCADGui.Selection.clearSelection()
doc.recompute()
doc.commitTransaction()
Expand Down
11 changes: 11 additions & 0 deletions SheetMetalCornerReliefCmd.py
Expand Up @@ -556,6 +556,11 @@ def Activated(self):
view = Gui.ActiveDocument.ActiveView
activeBody = None
selobj = Gui.Selection.getSelectionEx()[0].Object
selObjShapeCol = selobj.ViewObject.ShapeColor
selObjShapeTsp = selobj.ViewObject.Transparency
selObjDiffuseCol = selobj.ViewObject.DiffuseColor
# TODO Make the individual face colors be retained
# needDiffuseColorExtension = ( len(selobj.ViewObject.DiffuseColor) < len(selobj.Shape.Faces) )
if hasattr(view,'getActiveObject'):
activeBody = view.getActiveObject('pdbody')
if not smIsOperationLegal(activeBody, selobj):
Expand All @@ -565,12 +570,18 @@ def Activated(self):
a = doc.addObject("Part::FeaturePython","CornerRelief")
SMCornerRelief(a)
SMCornerReliefVP(a.ViewObject)
a.ViewObject.ShapeColor = selObjShapeCol
a.ViewObject.Transparency = selObjShapeTsp
a.ViewObject.DiffuseColor = selObjDiffuseCol
else:
#FreeCAD.Console.PrintLog("found active body: " + activeBody.Name)
a = doc.addObject("PartDesign::FeaturePython","CornerRelief")
SMCornerRelief(a)
SMCornerReliefPDVP(a.ViewObject)
activeBody.addObject(a)
a.ViewObject.ShapeColor = selObjShapeCol
a.ViewObject.Transparency = selObjShapeTsp
a.ViewObject.DiffuseColor = selObjDiffuseCol
doc.recompute()
doc.commitTransaction()
return
Expand Down
11 changes: 11 additions & 0 deletions SheetMetalExtendCmd.py
Expand Up @@ -577,6 +577,11 @@ def Activated(self):
view = Gui.ActiveDocument.ActiveView
activeBody = None
selobj = Gui.Selection.getSelectionEx()[0].Object
selObjShapeCol = selobj.ViewObject.ShapeColor
selObjShapeTsp = selobj.ViewObject.Transparency
selObjDiffuseCol = selobj.ViewObject.DiffuseColor
# TODO Make the individual face colors be retained
# needDiffuseColorExtension = ( len(selobj.ViewObject.DiffuseColor) < len(selobj.Shape.Faces) )
if hasattr(view,'getActiveObject'):
activeBody = view.getActiveObject('pdbody')
if not smIsOperationLegal(activeBody, selobj):
Expand All @@ -586,11 +591,17 @@ def Activated(self):
a = doc.addObject("Part::FeaturePython","Extend")
SMExtrudeWall(a)
SMViewProviderTree(a.ViewObject)
a.ViewObject.ShapeColor = selObjShapeCol
a.ViewObject.Transparency = selObjShapeTsp
a.ViewObject.DiffuseColor = selObjDiffuseCol
else:
a = doc.addObject("PartDesign::FeaturePython","Extend")
SMExtrudeWall(a)
SMViewProviderFlat(a.ViewObject)
activeBody.addObject(a)
a.ViewObject.ShapeColor = selObjShapeCol
a.ViewObject.Transparency = selObjShapeTsp
a.ViewObject.DiffuseColor = selObjDiffuseCol
FreeCADGui.Selection.clearSelection()
doc.recompute()
doc.commitTransaction()
Expand Down
11 changes: 11 additions & 0 deletions SheetMetalFoldCmd.py
Expand Up @@ -364,6 +364,11 @@ def Activated(self):
view = Gui.ActiveDocument.ActiveView
activeBody = None
selobj = Gui.Selection.getSelectionEx()[0].Object
selObjShapeCol = selobj.ViewObject.ShapeColor
selObjShapeTsp = selobj.ViewObject.Transparency
selObjDiffuseCol = selobj.ViewObject.DiffuseColor
# TODO Make the individual face colors be retained
# needDiffuseColorExtension = ( len(selobj.ViewObject.DiffuseColor) < len(selobj.Shape.Faces) )
if hasattr(view,'getActiveObject'):
activeBody = view.getActiveObject('pdbody')
if not smIsOperationLegal(activeBody, selobj):
Expand All @@ -373,12 +378,18 @@ def Activated(self):
a = doc.addObject("Part::FeaturePython","Fold")
SMFoldWall(a)
SMFoldViewProvider(a.ViewObject)
a.ViewObject.ShapeColor = selObjShapeCol
a.ViewObject.Transparency = selObjShapeTsp
a.ViewObject.DiffuseColor = selObjDiffuseCol
else:
#FreeCAD.Console.PrintLog("found active body: " + activeBody.Name)
a = doc.addObject("PartDesign::FeaturePython","Fold")
SMFoldWall(a)
SMFoldPDViewProvider(a.ViewObject)
activeBody.addObject(a)
a.ViewObject.ShapeColor = selObjShapeCol
a.ViewObject.Transparency = selObjShapeTsp
a.ViewObject.DiffuseColor = selObjDiffuseCol
doc.recompute()
doc.commitTransaction()
return
Expand Down
11 changes: 11 additions & 0 deletions SheetMetalFormingCmd.py
Expand Up @@ -456,6 +456,11 @@ def Activated(self):
view = Gui.ActiveDocument.ActiveView
activeBody = None
selobj = Gui.Selection.getSelectionEx()[0].Object
selObjShapeCol = selobj.ViewObject.ShapeColor
selObjShapeTsp = selobj.ViewObject.Transparency
selObjDiffuseCol = selobj.ViewObject.DiffuseColor
# TODO Make the individual face colors be retained
# needDiffuseColorExtension = ( len(selobj.ViewObject.DiffuseColor) < len(selobj.Shape.Faces) )
if hasattr(view,'getActiveObject'):
activeBody = view.getActiveObject('pdbody')
if not smIsOperationLegal(activeBody, selobj):
Expand All @@ -465,12 +470,18 @@ def Activated(self):
a = doc.addObject("Part::FeaturePython","WallForming")
SMBendWall(a)
SMFormingVP(a.ViewObject)
a.ViewObject.ShapeColor = selObjShapeCol
a.ViewObject.Transparency = selObjShapeTsp
a.ViewObject.DiffuseColor = selObjDiffuseCol
else:
#FreeCAD.Console.PrintLog("found active body: " + activeBody.Name)
a = doc.addObject("PartDesign::FeaturePython","WallForming")
SMBendWall(a)
SMFormingPDVP(a.ViewObject)
activeBody.addObject(a)
a.ViewObject.ShapeColor = selObjShapeCol
a.ViewObject.Transparency = selObjShapeTsp
a.ViewObject.DiffuseColor = selObjDiffuseCol
doc.recompute()
doc.commitTransaction()
return
Expand Down
11 changes: 11 additions & 0 deletions SheetMetalJunction.py
Expand Up @@ -345,6 +345,11 @@ def Activated(self):
view = Gui.ActiveDocument.ActiveView
activeBody = None
selobj = Gui.Selection.getSelectionEx()[0].Object
selObjShapeCol = selobj.ViewObject.ShapeColor
selObjShapeTsp = selobj.ViewObject.Transparency
selObjDiffuseCol = selobj.ViewObject.DiffuseColor
# TODO Make the individual face colors be retained
# needDiffuseColorExtension = ( len(selobj.ViewObject.DiffuseColor) < len(selobj.Shape.Faces) )
if hasattr(view,'getActiveObject'):
activeBody = view.getActiveObject('pdbody')
if not smIsOperationLegal(activeBody, selobj):
Expand All @@ -354,12 +359,18 @@ def Activated(self):
a = doc.addObject("Part::FeaturePython","Junction")
SMJunction(a)
SMJViewProviderTree(a.ViewObject)
a.ViewObject.ShapeColor = selObjShapeCol
a.ViewObject.Transparency = selObjShapeTsp
a.ViewObject.DiffuseColor = selObjDiffuseCol
else:
#FreeCAD.Console.PrintLog("found active body: " + activeBody.Name)
a = doc.addObject("PartDesign::FeaturePython","Junction")
SMJunction(a)
SMJViewProviderFlat(a.ViewObject)
activeBody.addObject(a)
a.ViewObject.ShapeColor = selObjShapeCol
a.ViewObject.Transparency = selObjShapeTsp
a.ViewObject.DiffuseColor = selObjDiffuseCol
FreeCADGui.Selection.clearSelection()
doc.recompute()
doc.commitTransaction()
Expand Down
11 changes: 11 additions & 0 deletions SheetMetalRelief.py
Expand Up @@ -391,6 +391,11 @@ def Activated(self):
view = Gui.ActiveDocument.ActiveView
activeBody = None
selobj = Gui.Selection.getSelectionEx()[0].Object
selObjShapeCol = selobj.ViewObject.ShapeColor
selObjShapeTsp = selobj.ViewObject.Transparency
selObjDiffuseCol = selobj.ViewObject.DiffuseColor
# TODO Make the individual face colors be retained
# needDiffuseColorExtension = ( len(selobj.ViewObject.DiffuseColor) < len(selobj.Shape.Faces) )
if hasattr(view,'getActiveObject'):
activeBody = view.getActiveObject('pdbody')
if not smIsOperationLegal(activeBody, selobj):
Expand All @@ -400,12 +405,18 @@ def Activated(self):
a = doc.addObject("Part::FeaturePython","Relief")
SMRelief(a)
SMReliefViewProviderTree(a.ViewObject)
a.ViewObject.ShapeColor = selObjShapeCol
a.ViewObject.Transparency = selObjShapeTsp
a.ViewObject.DiffuseColor = selObjDiffuseCol
else:
#FreeCAD.Console.PrintLog("found active body: " + activeBody.Name)
a = doc.addObject("PartDesign::FeaturePython","Relief")
SMRelief(a)
SMReliefViewProviderFlat(a.ViewObject)
activeBody.addObject(a)
a.ViewObject.ShapeColor = selObjShapeCol
a.ViewObject.Transparency = selObjShapeTsp
a.ViewObject.DiffuseColor = selObjDiffuseCol
FreeCADGui.Selection.clearSelection()
doc.recompute()
doc.commitTransaction()
Expand Down
11 changes: 11 additions & 0 deletions SketchOnSheetMetalCmd.py
Expand Up @@ -395,6 +395,11 @@ def Activated(self):
view = Gui.ActiveDocument.ActiveView
activeBody = None
selobj = Gui.Selection.getSelectionEx()[0].Object
selObjShapeCol = selobj.ViewObject.ShapeColor
selObjShapeTsp = selobj.ViewObject.Transparency
selObjDiffuseCol = selobj.ViewObject.DiffuseColor
# TODO Make the individual face colors be retained
# needDiffuseColorExtension = ( len(selobj.ViewObject.DiffuseColor) < len(selobj.Shape.Faces) )
if hasattr(view,'getActiveObject'):
activeBody = view.getActiveObject('pdbody')
if not smIsOperationLegal(activeBody, selobj):
Expand All @@ -404,12 +409,18 @@ def Activated(self):
a = doc.addObject("Part::FeaturePython","SketchOnSheet")
SMSketchOnSheet(a)
SMSketchOnSheetVP(a.ViewObject)
a.ViewObject.ShapeColor = selObjShapeCol
a.ViewObject.Transparency = selObjShapeTsp
a.ViewObject.DiffuseColor = selObjDiffuseCol
else:
#FreeCAD.Console.PrintLog("found active body: " + activeBody.Name)
a = doc.addObject("PartDesign::FeaturePython","SketchOnSheet")
SMSketchOnSheet(a)
SMSketchOnSheetPDVP(a.ViewObject)
activeBody.addObject(a)
a.ViewObject.ShapeColor = selObjShapeCol
a.ViewObject.Transparency = selObjShapeTsp
a.ViewObject.DiffuseColor = selObjDiffuseCol
doc.recompute()
doc.commitTransaction()
return
Expand Down