There’s nothing I’m aware of in the API that’ll let you either block undo/redo in Rhino. But this user managed something like this → Hook KeyboardEvent when command is running - #11 by Yannou
That being said, I think I’d be curious to know what and why you’re trying to do what you’re trying to do, preventing undo/redo might not be the best approach.
Why is this? What happens?