Create a Rule in a space that adds rules to sub-spaces within this space.
When a space is created in "this" space, a rule is applied to it.
I have used the following code for it. When I create a space, a rule (Transform n copy content to PDF) is automatically applied to it and its sub-spaces.
Hope, it helps you. U'll need to import d necessary classes.