Define and execute shape grammar rules in Dynamo

I am trying to create façade shading elements using shape grammar in Dynamo. I tried doing this with Python codes, but I was not very successful. I want to divide the façade into sections using shape grammar like in the picture and then randomly assign shading elements to these sections. Do you have any suggestions on this, and how can I introduce shape grammar to Dynamo? I am sharing the example rule sets:

Rule 1: Draw a rectangular façade with a width of 4480 cm and a height of 1750 cm.
Rule 2: Divide this façade into vertical grids with 250 cm intervals.
Rule 3: Divide this façade into horizontal grids with 350 cm intervals.
Rule 4: Within the rectangular area defined by four 250 cm x 350 cm grids, place a rectangle with a width of 160 cm and a height of 180 cm, centered horizontally and vertically within the grid, with a 50 cm gap from the top, a 160 cm x 180 cm rectangle, and a 120 cm gap from the bottom.
Rule 5: Divide each 180 cm x 160 cm rectangle into a combination of three rectangles or two rectangles and one square, or three squares, or two squares and one rectangle, to form a total rectangle of 180 cm x 160 cm.
Rule 6: Define at least one and at most two of the resulting rectangles or squares from Rule 5 with vertical or horizontal lines. Each rectangle or square can only have either horizontal or vertical lines within itself.

I want the shape grammar to generate a different variation each time I run it.

That image isn’t really reading - I suggest building a version that is sequential for each of the steps instead of ‘here is everything that might be’ in one go.

Focus on the actions in each step rather than the final outcome or terminology.

Generating a rectangle in Dynamo is easy, I recommend making it a surface. From there dividing it into sections is also fairly straight forward - look into nodes with the word IsoCurve in it and ‘split’.

Splitting sequentially isn’t too hard, but you may want to use Python or Imperative code depending on your desired outcome.