Restore ViewObject implementation for all Draft objects
In my tests the code works fine. Using @AIRCAP's instructions, I have created a 'broken' file from draft_test_objects.FCStd.
This commit is contained in:
@@ -31,12 +31,11 @@
|
||||
from PySide.QtCore import QT_TRANSLATE_NOOP
|
||||
|
||||
import FreeCAD as App
|
||||
|
||||
from draftobjects.draft_annotation import DraftAnnotation
|
||||
from draftutils import gui_utils
|
||||
from draftutils.messages import _wrn
|
||||
from draftutils.translate import translate
|
||||
|
||||
from draftobjects.draft_annotation import DraftAnnotation
|
||||
|
||||
|
||||
class Text(DraftAnnotation):
|
||||
"""The Draft Text object."""
|
||||
@@ -75,15 +74,17 @@ class Text(DraftAnnotation):
|
||||
def onDocumentRestored(self,obj):
|
||||
"""Execute code when the document is restored."""
|
||||
super().onDocumentRestored(obj)
|
||||
|
||||
# See loads: self.Type is None for new objects.
|
||||
if self.Type is not None \
|
||||
and hasattr(obj, "ViewObject") \
|
||||
and obj.ViewObject:
|
||||
self.update_properties_0v21(obj, obj.ViewObject)
|
||||
|
||||
gui_utils.restore_view_object(obj, vp_module="view_text", vp_class="ViewProviderText")
|
||||
# See loads: old_type is None for new objects.
|
||||
old_type = self.Type
|
||||
self.Type = "Text"
|
||||
|
||||
if old_type is None:
|
||||
return
|
||||
if not getattr(obj, "ViewObject", None):
|
||||
return
|
||||
self.update_properties_0v21(obj, obj.ViewObject)
|
||||
|
||||
def update_properties_0v21(self, obj, vobj):
|
||||
"""Update view properties."""
|
||||
# The DisplayMode is updated automatically but the new values are
|
||||
|
||||
Reference in New Issue
Block a user