I'm in Part design-sketcher, from macro how to click the close button

Need help, or want to share a macro? Post here!
openBrain
Posts: 2372
Joined: Fri Nov 09, 2018 5:38 pm

Re: I'm in Part design-sketcher, from macro how to click the close button

Postby openBrain » Wed Nov 13, 2019 6:41 pm

chrisb wrote:
Wed Nov 13, 2019 6:31 pm
Using the list of imports and executing this line I get no error and FreeCAD switches the tab in ComboView from Tasks to Model. The Sketch stays in edit mode in Sketcher.
:+1: I should have guess what the setCurrentIndex was doing. :)
freedman
Posts: 1031
Joined: Thu Mar 22, 2018 3:02 am
Location: Washington State, USA

Re: I'm in Part design-sketcher, from macro how to click the close button

Postby freedman » Wed Nov 13, 2019 7:03 pm

This does work (see below), it closes sketcher, and switches to tree mode. It doesn't work in my macro but I will look into that. Thanks.

Code: Select all

import FreeCAD
import FreeCADGui
import time
from pivy import coin
import FreeCAD as App, FreeCADGui 
from PySide import QtGui,QtCore

Gui.ActiveDocument.resetEdit()
App.ActiveDocument.recompute()
App.ActiveDocument.commitTransaction()
FreeCADGui.getMainWindow().findChild(QtGui.QDockWidget, "Combo View").findChild(QtGui.QTabWidget).setCurrentIndex(0)
chrisb
Posts: 19602
Joined: Tue Mar 17, 2015 9:14 am

Re: I'm in Part design-sketcher, from macro how to click the close button

Postby chrisb » Wed Nov 13, 2019 10:01 pm

This works here, even if combo view is switched to Model.