CAM: fix regressions with material handling

The ShapeAppearance is a list of materials and thus assigning a color with 'obj.ViewObject.ShapeAppearance.DiffuseColor = color'
is incorrect.
But doing it with 'obj.ViewObject.ShapeAppearance[0].DiffuseColor = color' doesn't work as expected because the
internal notification doesn't work with a list.

So, the only viable way is to revert the changes and do it by assigning the color to the 'ShapeColor' attribute.
This commit is contained in:
wmayer
2024-04-18 13:57:48 +02:00
parent 588917d926
commit 113782f65e
4 changed files with 8 additions and 8 deletions

View File

@@ -59,7 +59,7 @@ def debugMarker(vector, label, color=None, radius=0.5):
vector, FreeCAD.Rotation(FreeCAD.Vector(0, 0, 1), 0)
)
if color:
obj.ViewObject.ShapeAppearance.DiffuseColor = color
obj.ViewObject.ShapeColor = color
def debugCircle(vector, r, label, color=None):
@@ -73,7 +73,7 @@ def debugCircle(vector, r, label, color=None):
)
obj.ViewObject.Transparency = 90
if color:
obj.ViewObject.ShapeAppearance.DiffuseColor = color
obj.ViewObject.ShapeColor = color
def addAngle(a1, a2):

View File

@@ -231,7 +231,7 @@ class TaskPanel:
)
self.interpshape.Shape = obj.interpSurface
self.interpshape.ViewObject.Transparency = 60
self.interpshape.ViewObject.ShapeAppearance.DiffuseColor = (1.00000, 1.00000, 0.01961)
self.interpshape.ViewObject.ShapeColor = (1.00000, 1.00000, 0.01961)
self.interpshape.ViewObject.Selectable = False
stock = PathUtils.findParentJob(obj).Stock
self.interpshape.Placement.Base.z = stock.Shape.BoundBox.ZMax

View File

@@ -83,7 +83,7 @@ def debugMarker(vector, label, color=None, radius=0.5):
vector, FreeCAD.Rotation(FreeCAD.Vector(0, 0, 1), 0)
)
if color:
obj.ViewObject.ShapeAppearance.DiffuseColor = color
obj.ViewObject.ShapeColor = color
def debugCylinder(vector, r, height, label, color=None):
@@ -97,7 +97,7 @@ def debugCylinder(vector, r, height, label, color=None):
)
obj.ViewObject.Transparency = 90
if color:
obj.ViewObject.ShapeAppearance.DiffuseColor = color
obj.ViewObject.ShapeColor = color
def debugCone(vector, r1, r2, height, label, color=None):
@@ -112,7 +112,7 @@ def debugCone(vector, r1, r2, height, label, color=None):
)
obj.ViewObject.Transparency = 90
if color:
obj.ViewObject.ShapeAppearance.DiffuseColor = color
obj.ViewObject.ShapeColor = color
class Tag:

View File

@@ -228,7 +228,7 @@ class PathSimulation:
)
self.cutMaterialIn.ViewObject.Proxy = 0
self.cutMaterialIn.ViewObject.show()
self.cutMaterialIn.ViewObject.ShapeAppearance.DiffuseColor = (1.0, 0.85, 0.45, 0.0)
self.cutMaterialIn.ViewObject.ShapeColor = (1.0, 0.85, 0.45, 0.0)
else:
self.cutMaterial = FreeCAD.ActiveDocument.addObject(
"Part::FeaturePython", "CutMaterial"
@@ -236,7 +236,7 @@ class PathSimulation:
self.cutMaterial.Shape = self.job.Stock.Shape
self.cutMaterial.ViewObject.Proxy = 0
self.cutMaterial.ViewObject.show()
self.cutMaterial.ViewObject.ShapeAppearance.DiffuseColor = (0.5, 0.25, 0.25, 0.0)
self.cutMaterial.ViewObject.ShapeColor = (0.5, 0.25, 0.25, 0.0)
# Add cut path solid for debug
if self.debug: