TAGGED: #python-#ironpython, ansys-spaceclaim, api, python, spaceclaim
-
-
July 26, 2023 at 7:00 pm
Sterling Butters
SubscriberGreetings, is it possible to access undo/redo operations from the python API? The record feature does not appear to pick up on these actions and seems like to basic of a feature to not be implemented in the API. Thanks in advance!
-
July 31, 2023 at 4:01 pm
Matthew Middleton
Ansys Employeefrom SpaceClaim.Api.V23 import Application
from SpaceClaim.Api.V23.Scripting.Internal import TransactionHelper
def Undo():
TransactionHelper.EndCommand()
Application.Undo(1) # number of steps to undo
#Application.Redo(1) # number of steps to redo
#Application.PurgeUndo(0) # number of steps to keep
TransactionHelper.BeginCommand("Script")
Undo()# The Undo(), Redo(), PurgeUndo() must be done within the EndCommand()/BeginCommand() block and inside a function or else the BeginCommand() cannot resume GUI operation.
-
July 31, 2023 at 4:10 pm
Sterling Butters
Subscriber@mjmiddle Thanks! What argument is passed to the
BeginCommandmethod in your example i.e. what is “Script”? Is it the name of the active.scscriptfile? I guess more generally, what command is being “begun” after theApplication.Undo(1)operation? -
August 1, 2023 at 12:04 am
Matthew Middleton
Ansys EmployeeThese are unsupported commands, and I gave you a workable method to do what has not been supported or documented. Just use the BeginCommand("Script") exactly as shown, with the string "Script" as the argument. If you try use the undo command outside of the Begin/EndCommand, you'll get an error:
Cannot undo or redo when a command is being executed.
The Begin/EndCommand allows it to halt the GUI mouse/keyboard event loop to do the command and then start the event loop again. Use the script as shown or you will run into problems.
-
August 1, 2023 at 2:04 pm
Sterling Butters
Subscriber@mjmiddle Thanks so much again! So glad this forum exists!
-
- The topic ‘SpaceClaim Python API: Undo/Redo Operations’ is closed to new replies.
-
6635
-
1906
-
1469
-
1312
-
1022
© 2026 Copyright ANSYS, Inc. All rights reserved.