A novel optimal allocation framework for photovoltaic generations in an integration system of buildings‐to‐distribution‐network using improved backtracking search optimization algorithm is proposed here. In the proposed framework, photovoltaic generations are optimally allocated to optimize the overall performance of a buildings‐to‐distribution‐network regarding the efficient active power usage of photovoltaic generations, the energy savings, and voltage profile improvement of distribution network. The effects of building active demand response on the photovoltaic generations' optimal allocation are considered in the proposed framework. An improved backtracking search algorithm using two new operators is developed to optimize the active power reduction factors and locations of photovoltaic generations. The test results of IEEE 33‐bus and 69‐bus systems demonstrate that the developed framework can take full advantage of photovoltaic generation power and the active demand response of buildings to coordinate the efficient active power usage of photovoltaic generations, the voltage profile improvement and energy savings of a buildings‐to‐distribution‐network. In addition, the improved backtracking search optimization algorithm converges faster than genetic algorithm, classical backtracking search optimization algorithm, and bird swarm algorithm.