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:
Roy-043
2024-10-24 15:24:13 +02:00
parent 6c9ea36225
commit d218d35527
24 changed files with 226 additions and 94 deletions

View File

@@ -32,6 +32,7 @@ from PySide.QtCore import QT_TRANSLATE_NOOP
import FreeCAD as App
import DraftGeomUtils
from draftobjects.base import DraftObject
from draftutils import gui_utils
from draftutils import params
@@ -39,7 +40,7 @@ class Rectangle(DraftObject):
"""The Rectangle object"""
def __init__(self, obj):
super(Rectangle, self).__init__(obj, "Rectangle")
super().__init__(obj, "Rectangle")
_tip = QT_TRANSLATE_NOOP("App::Property", "Length of the rectangle")
obj.addProperty("App::PropertyDistance", "Length", "Draft", _tip)
@@ -71,6 +72,12 @@ class Rectangle(DraftObject):
obj.Rows=1
obj.Columns=1
def onDocumentRestored(self, obj):
super().onDocumentRestored(obj)
gui_utils.restore_view_object(
obj, vp_module="view_rectangle", vp_class="ViewProviderRectangle"
)
def execute(self, obj):
"""This method is run when the object is created or recomputed."""
if self.props_changed_placement_only():