Last active
September 23, 2023 20:37
-
-
Save longyuxi/7b690242dc136dc6027bc4507f106441 to your computer and use it in GitHub Desktop.
Keybinds for adjusting PyMOL camera's front and back clipping plane
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Purpose: Adjusts the front and back clipping planes of the camera in pymol | |
# To use: Drag and drop this script into pymol, then use (CTRL-R, CTRL-F) and (CTRL-U, CTRL-J) to adjust the front and back clipping planes, respectively | |
from pymol import cmd | |
def adjust_front_view(amount=1): | |
view = list(cmd.get_view()) | |
view[15] += amount | |
cmd.set_view(view) | |
print(f'New front plane distance: {view[15]}') | |
def adjust_back_view(amount=1): | |
view = list(cmd.get_view()) | |
view[16] += amount | |
cmd.set_view(view) | |
print(f'New back plane distance: {view[16]}') | |
cmd.set_key("CTRL-R", adjust_front_view, kw={ | |
"amount": 1 | |
}) | |
cmd.set_key("CTRL-F", adjust_front_view, kw={ | |
"amount": -1 | |
}) | |
cmd.set_key("CTRL-U", adjust_back_view, kw={ | |
"amount": 1 | |
}) | |
cmd.set_key("CTRL-J", adjust_back_view, kw={ | |
"amount": -1 | |
}) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment