Still working on getting a super clean solution – but in the meantime, if you’re happy with an interim solution, you can see the code I’ve posted in this thread, which can be copy pasted into a new Rhino Command project in Visual Studio and adapted to your purpose: