Information

How do I get the current “camera position” in PyMol so I can reuse it in scripts?

How do I get the current “camera position” in PyMol so I can reuse it in scripts?


We are searching data for your request:

Forums and discussions:
Manuals and reference books:
Data from registers:
Wait the end of the search in all databases.
Upon completion, a link will appear to access the found materials.

I have a few protein models I want to take pictures of with various ligands bound. It would be nice if I could do it from the same "position", but the only way I can figure out to repeat the same view is withzoom resi. 64, 152, 150or the like, which isn't framed that well.

How can I manually position the viewport, capture it's parameters, and repeat it in the script?


I have found get_view, e.g.

PyMOL>get_view ### cut below here and paste into script ### set_view ( 0.590180993, 0.670941532, 0.448923886, -0.507570565, 0.740831316, -0.439937204, -0.627747774, 0.031782545, 0.777776182, 0.000000000, 0.000000000, -417.497009277, 0.741809845, 7.078243256, 16.473480225, 329.157806396, 505.836212158, -20.000000000 ) ### cut above here and paste into script ###

but this doesn't work in a.pyscript, where I need to modify it tocmd.set_view(… ), as it complains it wants just (or up to 5) arguments, not 18. The wiki is vague about it, it just says

PYMOL API

cmd.set_view(string-or-sequence view)

Try to pass the matrix as a String containing 18 floats separated by commas, e.g. like

cmd.set_view ("0.590180993, 0.670941532, 0.448923886, -0.507570565, 0.740831316, -0.439937204, -0.627747774, 0.031782545, 0.777776182, 0.000000000, 0.000000000, -417.497009277, 0.741809845, 7.078243256, 16.473480225, 329.157806396, 505.836212158, -20.000000000")

cmd.get_view()seems to return a tuple, so you'll have to convert that to a String if you want to pass the same position tocmd.set_view().

I tried it in Pymol 1.3 on the command line (not in a script though) and it seemed to work.