Restore the ViewObject
I think we need to restore the ViewObject in such cases. I assume this problems exists for all Draft and BIM objects. So this commit is just an example implementation.
This commit is contained in:
@@ -59,12 +59,12 @@ class DraftAnnotation(object):
|
||||
Check if new properties are present after the object is restored
|
||||
in order to migrate older objects.
|
||||
"""
|
||||
if not hasattr(obj, "ViewObject"):
|
||||
if not getattr(obj, "ViewObject", None):
|
||||
return
|
||||
vobj = obj.ViewObject
|
||||
if not vobj:
|
||||
return
|
||||
if not getattr(vobj, "Proxy", None):
|
||||
# Object was save without GUI.
|
||||
# onDocumentRestored in the object class should restore the ViewObject.
|
||||
return
|
||||
if hasattr(vobj, "ScaleMultiplier") and hasattr(vobj, "AnnotationStyle"):
|
||||
return
|
||||
|
||||
@@ -227,10 +227,15 @@ class Label(DraftAnnotation):
|
||||
super().onDocumentRestored(obj)
|
||||
self.Type = "Label"
|
||||
|
||||
if not hasattr(obj, "ViewObject"):
|
||||
if not getattr(obj, "ViewObject", None):
|
||||
return
|
||||
vobj = obj.ViewObject
|
||||
if not vobj:
|
||||
if not getattr(vobj, "Proxy", None):
|
||||
# Object was save without GUI. We need to restore the ViewObject.
|
||||
from draftviewproviders.view_label import ViewProviderLabel
|
||||
from draftutils import gui_utils
|
||||
ViewProviderLabel(obj.ViewObject)
|
||||
gui_utils.format_object(obj)
|
||||
return
|
||||
if hasattr(vobj, "FontName") and hasattr(vobj, "FontSize"):
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user