Difference between revisions of "Get session"

From PyMOLWiki
Jump to: navigation, search
(Description of top-level structure)
Line 1: Line 1:
 +
Returns a dictionary representation the currently loaded PyMOL session.The session file (.pse) is a compressed version of its output.
  
Returns a dictionary representation the currently loaded PyMOL session.
+
By using this API, user scripts can access many interesting properties which are otherwise inaccessible. Examples include [[Pymol2glmol]] and [[get_raw_distances]] scripts.
 +
 
 +
WARNING: This API is undocumented API, intended for internal use. Use it only when it is necessary.
  
 
= Usage =
 
= Usage =
 
<source lang="python">
 
<source lang="python">
 
# get the session as a dictionary
 
# get the session as a dictionary
cmd.get_session()
+
print cmd.get_session()
 
</source>
 
</source>
 +
 +
= Return value =
 +
 +
The returned dictionary has following key-value pairs.
 +
 +
:main: An array encoding window size. For example, [640, 480]
 +
 +
:color_ext:
 +
 +
:settings: An array of PyMOL's global settings. They are dumped by SettingAsPyList in layer1/Setting.c. Further details will not be discussed because scripts can access these values from [[get|cmd.get]] API.
 +
 +
:colors: If you have defined color names by [[Set Color]], they are described here. Default color names (red, blue, etc...) will not appear. This dict can also be obtained by [[Get Color Indices|cmd.get_color_indices()]]. To get RGB definition of a color, get its pallet ID by cmd.get_color_index and convert it to RGB tuple by cmd.get_color_tuple.
 +
 +
:view: Same as [[Get View|cmd.get_view()]]
 +
 +
:version: Version number of PyMOL
 +
 +
:view_dict:
 +
 +
:names: This is the most complex but interesting part. Produced by ExecutiveGetNamedEntries, this array describes internal C-objects of the current session. Each element is an array of five elements.
 +
 +
 +
(documentation in progress... Please feel free to expand)
  
 
[[Category:Commands]]
 
[[Category:Commands]]

Revision as of 09:49, 22 February 2012

Returns a dictionary representation the currently loaded PyMOL session.The session file (.pse) is a compressed version of its output.

By using this API, user scripts can access many interesting properties which are otherwise inaccessible. Examples include Pymol2glmol and get_raw_distances scripts.

WARNING: This API is undocumented API, intended for internal use. Use it only when it is necessary.

Usage

# get the session as a dictionary
print cmd.get_session()

Return value

The returned dictionary has following key-value pairs.

main: An array encoding window size. For example, [640, 480]
color_ext:
settings: An array of PyMOL's global settings. They are dumped by SettingAsPyList in layer1/Setting.c. Further details will not be discussed because scripts can access these values from cmd.get API.
colors: If you have defined color names by Set Color, they are described here. Default color names (red, blue, etc...) will not appear. This dict can also be obtained by cmd.get_color_indices(). To get RGB definition of a color, get its pallet ID by cmd.get_color_index and convert it to RGB tuple by cmd.get_color_tuple.
view: Same as cmd.get_view()
version: Version number of PyMOL
view_dict:
names: This is the most complex but interesting part. Produced by ExecutiveGetNamedEntries, this array describes internal C-objects of the current session. Each element is an array of five elements.


(documentation in progress... Please feel free to expand)