Loop the loop... and exit

Trying to loop a function that contains a PickFace…

ref = uidoc.Selection.PickObject(ObjectType.Face, "Select a face.")

But don’t want to collect a bunch of faces with the pyRevit pick_face as I’m completing a transaction on each loop for both the user feedback and the undo steps.

So I’m looking for a way to while loop and then break the loop. I would probably use import keyboard - but not installed and IT is a pita.

I’ve tried msvcrt - but that is seeing some sort of keypress inside my function. Maybe the mouseclick is being detected(?) Thought I’d just loop and spacebar to start a second loop (AutoCAAD style repeat command) and anykey to exit the loop.

Command is a paste paint command.

  • Pick desired face for paint material.
  • Pick destination. (Undo marker, paint shows up.)
  • Again!
  • Pick destination. (Undo marker, paint shows up.)
  • anykey
  • Exit…

Never mind. I’m silly.
I just had move my try except up into the function where the PickFace was being done and o return True or False and catch the OperationCanceledException.
Simple.