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 8c4d696180
commit 0fac810797
24 changed files with 226 additions and 94 deletions

View File

@@ -30,18 +30,25 @@
from PySide.QtCore import QT_TRANSLATE_NOOP
from draftobjects.base import DraftObject
from draftutils import gui_utils
class Block(DraftObject):
"""The Block object"""
def __init__(self, obj):
super(Block, self).__init__(obj, "Block")
super().__init__(obj, "Block")
_tip = QT_TRANSLATE_NOOP("App::Property",
"The components of this block")
obj.addProperty("App::PropertyLinkList","Components", "Draft", _tip)
def onDocumentRestored(self, obj):
super().onDocumentRestored(obj)
gui_utils.restore_view_object(
obj, vp_module="view_base", vp_class="ViewProviderDraftPart", format=False
)
def execute(self, obj):
if self.props_changed_placement_only(obj):
obj.positionBySupport()