By the study of the pattern book Ying Zao Fa Shi (building regulations of Song Dynasty, 1103 AD), while analyzing the combining and dimensioning rule of timber framework and tile work, a model self-generating program has been compiled for the first time. The operating framework has been firstly defined, while solving the issues of clustering principle, connecting method, output classification, etc. with the detailed description of algorithm theory. Taking the corner bracket set and nine-ridge roof for example, after the compilation and debug by Grasshopper, according to various input parameters, various models have been generated automatically by the plugin, proving the velocity and the veracity of the algorithm.