Get coordset

From PyMOLWiki
Jump to: navigation, search

get_coordset is an API only function that returns the coordinates of one object-state (one "coordinate set") as a numpy array.

New in PyMOL 1.7.4

The order of coordinates might differ from functions like iterate or get_coords. The function does not take the state or TTT matrices into account.


cmd.get_coordset(str name, int state=1, int copy=1)

Returns: ndarray, shape (N, 3), where N is the number of atoms.


  • name = str: object name
  • state = int: state index {default: 1}
  • copy = 0/1: {default: 1} Warning: only use copy=0 if you know what you're doing. copy=0 will return a numpy array which is a wrapper of the internal coordinate set memory and provides read-write access. If the internal memory gets freed or reallocated, this wrapper will become invalid.


Move an object to its geometric center:

cs = cmd.get_coordset('1ubq', copy=0)
cs -= cs.mean(0)

See Also