EDIT: Simpler solution:
https://github.com/FreeCAD/FreeCAD/pull/8386
Code: Select all
def make_clone(obj, delta=None, forcedraft=False):
# ...
if App.GuiUp:
# ...
# Workaround to trigger update of DiffuseColor:
# Note: only works if obj contains 1 object.
reapply_DiffuseColor_store(cl, cl.ViewObject.DiffuseColor)
ToDo.delay(reapply_DiffuseColor_action, [])
gui_utils.select(cl)
return cl
def reapply_DiffuseColor_store(obj, difcol):
doc = App.ActiveDocument
meta = doc.Meta
meta["Draft_DiffuseColor_Workaround"] = str([obj.Name, difcol])
doc.Meta = meta
def reapply_DiffuseColor_action():
doc = App.ActiveDocument
if doc is None:
return
meta = doc.Meta
data = meta.get("Draft_DiffuseColor_Workaround")
if data is None:
return
data = eval(data)
name = data[0]
difcol = data[1]
obj = doc.getObject(name)
if obj is None:
return
if not hasattr(obj, "ViewObject"):
return
vobj = obj.ViewObject
if not vobj:
return
vobj.DiffuseColor = difcol
del meta["Draft_DiffuseColor_Workaround"]
doc.Meta = meta