Not totally sure, but I think you’re asking for the script in this thread: Delete everything outside boundary curve?