Method of programming an industrial robot, said robot having a robot arm with an end-effector mounted thereto which is controlled by a robot control unit to manipulate a workpiece which is arranged in a workplace of said robot, wherein a target coordinate system is associated to said workplace and an image of said workplace and said workpiece to be manipulated by said robot is captured by an image capturing device and transmitted to a computing device having a human-machine-interface to generate control code for controlling said robot which is transmitted to said robot control unit, wherein said captured image is displayed on a display associated to said computing device, said workpiece displayed on said display is marked with a marker-object on said display, said marker-object is manipulated in a sequence of at least two subsequent manipulating steps which are associated to robot commands on said display by means of said human-machine-interface, wherein said sequence of manipulating steps includes positions (P1 to P5) of the marker-object in a coordinate system for displaying said marker-object on said display, said positions (P1 to P5) of the marker-object in the sequence of manipulating steps are transformed to positions (P1' to P5') of said workpiece in said target coordinate system and control code for controlling said robot is generated from said transformed positions (P1' to P5') and associated robot commands, characterized by the steps of measuring a first distance value between a reference point which is located above said workpiece and a first measuring location on said workpiece, measuring a second distance value between said reference point and a second measuring location on said workplace, determining a workpiece height value associated to said workpiece as the difference between the measured first distance value and said measured second distance value and generating said control code and associated robot commands for controlling said robot on basis of said workpiece height value, wherein said image capturing device is a 3D-camera which captures said image of said workplace together with measured distance values (D1, D2, D3) associated to at least some of the pixels of said captured image, and said workpiece height value is determined as a difference between a first distance value associated to a first pixel of said captured image which is located at said first measuring location and a second distance value associated to a second pixel of said captured image which is located in said second measuring location, wherein said first measuring location is located within said marker-object after marking said workpiece, said second measuring location is located outside of and adjacent to said marker-object, and wherein said first and/or second pixels are selectable by means of said human-machine-interface on said display. control code for controlling said robot is generated from said transformed positions (P1' to P5') and associated robot commands, characterized by the steps of measuring a first distance value between a reference point which is located above said workpiece and a first measuring location on said workpiece, measuring a second distance value between said reference point and a second measuring location on said workplace, determining a workpiece height value associated to said workpiece as the difference between the measured first distance value and said measured second distance value and generating said control code and associated robot commands for controlling said robot on basis of said workpiece height value, wherein said image capturing device is a 3D-camera which captures said image of said workplace together with measured distance values (D1, D2, D3) associated to at least some of the pixels of said captured image, and said workpiece height value is determined as a difference between a first distance value associated to a first pixel of said captured image which is located at said first measuring location and a second distance value associated to a second pixel of said captured image which is located in said second measuring location, wherein said first measuring location is located within said marker-object after marking said workpiece, said second measuring location is located outside of and adjacent to said marker-object, and wherein said first and/or second pixels are selectable by means of said human-machine-interface on said display.