A robot program generating device for generating an operating program for a system including a robot and a visual sensor for conducting a two-dimensional measurement or three-dimensional measurement of a work, the robot program generating device comprising: a displaying means for displaying a model of a work or an image of a work which has been previously snapped; a measuring portion designating means for designating a measuring portion measured by the visual sensor on the work model or work image displayed by the displaying means; a measuring method designating means for designating whether a measuring method for measuring the measuring portion designated by the measuring portion designating means is the two-dimensional measurement or the three-dimensional measurement; a work information designating means for designating information of at least one attribute of the work by numerical values or types; characterised in that it further comprises: a rule storing means for storing predetermined rules for judging whether or not the measuring portion, which is designated by the measuring portion designating means, is good and/or whether or not the measuring method, which is designated by the measuring method designating means, is good in connection with the numerical values or types; a judging means for judging whether or not the measuring portion, which is designated by the measuring portion designating means, is good and/or whether or not the measuring method, which is designated by the measuring method designating means, is good according to the at least one attribute of the work (w) designated by the work information designating means and the rule stored by the rule storing means; and a means for generating a robot program including a measuring command for executing the measurement of the designated measuring portion, which has been judged good by the judging means by the designated measuring method, which has been judged good by the judging means. a displaying means for displaying a model of a work or an image of a work which has been previously snapped; a measuring portion designating means for designating a measuring portion measured by the visual sensor on the work model or work image displayed by the displaying means; a measuring method designating means for designating whether a measuring method for measuring the measuring portion designated by the measuring portion designating means is the two-dimensional measurement or the three-dimensional measurement; a work information designating means for designating information of at least one attribute of the work by numerical values or types; a rule storing means for storing predetermined rules for judging whether or not the measuring portion, which is designated by the measuring portion designating means, is good and/or whether or not the measuring method, which is designated by the measuring method designating means, is good in connection with the numerical values or types; a judging means for judging whether or not the measuring portion, which is designated by the measuring portion designating means, is good and/or whether or not the measuring method, which is designated by the measuring method designating means, is good according to the at least one attribute of the work (w) designated by the work information designating means and the rule stored by the rule storing means; and a means for generating a robot program including a measuring command for executing the measurement of the designated measuring portion, which has been judged good by the judging means by the designated measuring method, which has been judged good by the judging means.