Building integrated Photovoltaics (BIPV) receives growing attentions from both architectural and energy saving perspectives. Large commercial building envelopes can be utilized due to their great potential of reducing building energy consumption and increasing PV integration impact, especially in climate zones with rich solar resources. Most current studies have been focused on predicting electricity generation of BIPV systems with existing envelope geometries, while few studies have discussed the generation of proper envelope shapes for PV integration due to the challenge of integrating architecture and engineering. This paper introduces a novel optimization method for BIPV shape development based on the shape grammar theory. The method reforms given building shapes/envelopes to produce a set of better BIPV shape alternatives, as well as determines the best placement and matching BIPV systems for the optimized envelopes. The main set of criteria considered during the generation and optimization process include PV power generation, PV economic impact and building energy consumption. Architectural preferences are included in generating preferred design alternatives, such as view consideration and shape direction. Commercial buildings in Egypt are used to demonstrate and validate the applications of the developed method and tool. The method and tool can help designers in achieving an optimal design of building envelope that is most suitable for maximizing PV integration.