U Rebar to stirrups

Hello,

I am trying to make an automated script for rebar around wall openings and I would like my script to be converted from a U-bar to a stirrup, when there is not enough room for a U bar to have sufficient overlap, which is commonly 50*Rebardiameter. I am really not sure how to implement this sort of restraint. Can some one help me get started? Do I need to write a custom python script with some if statements?

I have made some adjustments to a script i found only. Wall.Opening.Reinforcement - Copy.dyn (62.0 KB)

Wall.Opening.Reinforcement - Copy.dyn (62.0 KB)