Is there a default undo operation?
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Re: Is there a default undo operation?
No, not for GUI stuff at the moment.
-
- Posts: 216
- Joined: Tue Oct 02, 2012 7:29 am
Re: Is there a default undo operation?
ok, thank you, wmayer.
Re: Is there a default undo operation?
Hi wmayerwmayer wrote: ↑Tue Jul 16, 2013 1:45 pm You are mixing up two concepts: the transaction framework and macro recording
Yes. And for convenience you can also do:1. Does a transaction starts with 'FreeCAD.ActiveDocument.openTransaction([name])' and ends with FreeCAD.ActiveDocument.commitTransaction() ?The second call of openTransaction automatically closes the first transaction.Code: Select all
FreeCAD.ActiveDocument.openTransaction("Command 1") ... # change some properties FreeCAD.ActiveDocument.openTransaction("Command 2") ...
The recording of a command has nothing to do with the transaction framework. Since (funnily) for Python it's impossible to record the code (because we need to save a string) Yorik wrote the saveTransaction() function where he can pass a string to the interpreter and thus make it possible to record the command.2. Will commands between 2 transactions be recorded?
If macro recording is activated and the command comes through the doCommand() function it gets recorded.3. What kinds of command could be recorded?
And again for the transaction framework it's currently impossible to store changes on the GUI side. So, that's why your script doesn't do for CTRL+Z. Here is a modified one:Code: Select all
import FreeCAD , FreeCADGui , Part from FreeCAD import Vector obj = FreeCAD.ActiveDocument.addObject("Part::Feature", 'ABC') v1 = Vector(1,1,0) v2 = Vector(1,0,0) v3 = Vector(0,0,0) v4 = Vector(0,1,0) l1 = Part.makeLine(v1,v2) l2 = Part.makeLine(v1,v3) l3 = Part.makeLine(v1,v4) def saveTransaction(commands): assert isinstance(commands , list) FreeCAD.ActiveDocument.openTransaction('abc') for command in commands: FreeCADGui.doCommand(command) FreeCAD.ActiveDocument.commitTransaction() saveTransaction(['''FreeCAD.ActiveDocument.getObject('ABC').Shape = l1''']) saveTransaction(['''FreeCAD.ActiveDocument.getObject('ABC').Shape = l2''']) saveTransaction(['''FreeCAD.ActiveDocument.getObject('ABC').Shape = l3'''])
Thanks for your clarification in transaction.
Generally if we save and re-open the project, the history of undo/redo is gone.
I'm wondering if we could also save the history of undo/do, in this way, undo/redo is still alive when re-opening.
Looking forward to hearing from you.
Best Regards,
Mea08kw
Re: Is there a default undo operation?
This would be very difficult and I doubt that this is common behaviour. If you check any text editor then the undo/redo list is also gone when closing the file.I'm wondering if we could also save the history of undo/do, in this way, undo/redo is still alive when re-opening.