Mechanism design becomes more and more complicated to achieve higher mechanical function and efficiency. It is necessary to produce good configuration and geometry at the upstream design stage to satisfy the design specifications at the detail design stage. In our study, a simple algorithm is proposed for generating mechanism under the design constraints on gear box and obstacle area. The spur gear train mechanism is generated by using the Monte Carlo method. The gear train is generated successfully in the several examples and the effectiveness of the mechanism generation algorithm is reported.