loonghao / photoshop-python-api

Python API for Photoshop.
https://loonghao.github.io/photoshop-python-api/
MIT License
604 stars 68 forks source link

How to rollback operations? #288

Closed ljp-cyber closed 10 months ago

ljp-cyber commented 11 months ago
def step_backward():
    app = ps.Application()
    doc = app.activeDocument

    current_state = doc.ActiveHistoryState

    history_states = doc.HistoryStates

    cur_index = history_states.index(current_state)

    rollback_index = history_states.index(current_state) - 1

    if rollback_index >= 0:
        rollback_state = history_states[rollback_index]
        doc.ActiveHistoryState = rollback_state
        print("success")
    else:
        print("fail")

The above code cannot be successfully rolled back.

Thanks!

loonghao commented 10 months ago

I deployed a new version and the issue has been solved