In this paper, a new method for generating tensegrity structures, based on mixed-integer programming and introduction of length constraints, is proposed. Tensegrity structures are of interest in a number of fields, and in Robotics they are expected to be used as structural elements of walking robots (tensegrity spines), as impact-resilient drones and as planetary exploration robots, among other things. The necessity for automated design tools for such structures makes it of interest to formulate tensegrity generation task as a mixed-integer convex program, making the process fast and reliable. Proposed length constraints allow to steer the solutions towards the desired shapes, such as tensegrity structures with smaller struts, hence easily foldable and compact. The study demonstrates three types of structures with different geometrical properties that we were able to generate with the proposed method, and discusses the growth in the time cost per problem with the increasing number of nodes in the structures.