Files
Qinventor/tests/ribbon_gui.FCMacro
T

28 lines
1.2 KiB
Plaintext

import sys, os, json, traceback
import FreeCAD as App
import FreeCADGui as Gui
from PySide import QtCore
ROOT = os.path.abspath(os.environ.get('QI_ROOT') or os.getcwd())
sys.path.insert(0, ROOT + '/src/QInventor')
sys.path.insert(0, ROOT + '/tests')
os.environ['QI_TEST'] = 'ribbon'
# Match the navigation and sketch camera defaults of production startup.
App.ParamGet('User parameter:BaseApp/Preferences/View').SetString('NavigationStyle', 'Gui::RevitNavigationStyle')
App.ParamGet('User parameter:BaseApp/Preferences/Mod/Sketcher/General').SetBool('ForceOrtho', True)
App.ParamGet('User parameter:BaseApp/Preferences/Mod/Sketcher/General').SetBool('RestoreCamera', True)
def run_ribbon():
try:
Gui.activateWorkbench('QInventorWorkbench')
import ribbon_suite
ribbon_suite.run(ROOT + '/artifacts/ribbon-validation')
except Exception:
with open(ROOT + '/artifacts/ribbon-validation-error.txt','w',encoding='utf-8') as stream:
stream.write(traceback.format_exc())
for name in list(App.listDocuments()):
App.closeDocument(name)
Gui.getMainWindow().close()
QtCore.QTimer.singleShot(100, QtCore.QCoreApplication.quit)
QtCore.QTimer.singleShot(2000, run_ribbon)