3Dprinting PP and control of tool

Hello to all, please help. When you generate rapid code based on imported 3D model that you want to print how do you control flow of material from dispensing tool in this rapid program with thousands of move instructions, when and where do you do define opening and closing of nozzle. Thanks in advance.