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

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
openBrain
Veteran
Posts: 9041
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

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

Post by openBrain »

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
Veteran
Posts: 3472
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

Post by freedman »

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
Veteran
Posts: 54280
Joined: Tue Mar 17, 2015 9:14 am

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

Post by chrisb »

This works here, even if combo view is switched to Model.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Post Reply