One of the important categories in office spaces is the control of daylight and energy consumption. By controlling natural light, it is possible to provide uniform light in the entire space, sufficient daylight, and visual comfort for office workers. In many cases, this important issue can be resolved by choosing the right shading. In this study, the aim is to investigate the significance of some important parameters such as DoS (Depth of Shading), FO (Facade Offset), FSoS (Flip Start of Shading), LoS (Location of Shading), WWR (Window to Wall Ratio), CoS (Count of Shading), AoS (Angle of Shading), and HoW (Height of Window) in the optimal design of shading for an office environment in Tehran. For this purpose, eight variables have been designed and the aim is to improve the indicators of Energy Usage Intensity (EUI), Spatial Daylight Autonomy(sDA), Daylight Glare Probability (DGP), and Tc (Thermal comfort) in the office space. For optimization in the grasshopper environment, Wallacei’s algorithm was used. Then, the algorithm provides a set of optimal points. Then a point was selected as optimal by the WSM (Weighted Sum Method) method. According to the input variables that are DoS, FO, FSoS, LoS, WWR, CoS, AoS, and HoW its optimal point values are 0.4, 0, Up, Horizontal, 80, 5, 30, 0.5, respectively. The results show that the values of sDA, DGP, EUI, and Tc were improved by 43.6%, 52.77%, 13.9, and 3.696%, respectively, before and after shading optimization. Also, the annual glare and the hottest and coldest day of the year were checked where there were around 500(cd/m2) and 200(cd/m2) reduction of glare value in winter and summer seasons, respectively. Finally, the value of Useful Daylight Illuminance (UDI)before and after the installation of the optimal shading was 25.8 and 68.4, respectively.