Midi Editing beyond Logical Editor

Hi all,
I have a question:
Is it possible to do automated midi editing in Cubase 6 in the way you can do it with Logical Editor - but with more possibilities?
What I want to do is:
Select a midi passage (let’s say one measure) and then run a script on it to alter the notes. Basically exactly what Logical Editor does - but without being limited to the few commands the Logical Editor has.
Is there any way to do this?
Thanks a lot!!
Frank