The mechanical behavior of nanomaterials, due to their very small dimensions, cannot be easily evaluated in experiments. Therefore, finding suitable and simple models to determine the mechanical properties of carbon nanotubes has always been of interest to researchers. In this paper, to investigate the mechanical behavior of carbon nanotubes, a spatial structure consisting of a unit cell was used. The mechanical unit cell is considered as a two-dimensional truss for the structure of the carbon nanotube wall. First, the carbon bonds in the nanotube is converted into a structural element and its properties is calculated. Then, by numerically simulating the structure in a finite element software, the stress-strain curves in tension and compression is extracted. The method presented in this article is a simple and novel method for obtaining the stress-strain curve of carbon nanotubes and other nanostructures. The results of presented in this article show that there is a good agreement with the results of other experimental and theoretical studies in this field.