Finally got it working. This seems to do the trick and be can be generalized to any use case as far as I can tell. Please correct me if I’m wrong.
Thanks for all the help Everyone. Here is the final script:
Hope some other structural guys out there find it useful