“cmd.get_pdbstr” in an API-only function which returns a pdb corresponding to the atoms in the selection provided and that are present in the indicated state
cmd.get_pdbstr(string selection, int state)
def get_pdbstr(selection="all", state=-1, ref='', ref_state=-1, quiet=1):