Adobe Illustrator uses vector-based lines that you join together to make shapes eventually creating a detailed drawing or illustration. But what if you want to work backward and create a line from a shape? You can accomplish this using Adobe Illustrator's Average command. Averaging moves all of the points the same position based on your selection between vertical, horizontal or both. When you average a shape vertical or horizontal, you will get the appearance of a line with additional points in between. Averaging a shape using both returns the appearance of a point in the center of the original shape.
Select the "Direct Selection" tool or the "Lasso" tool. Select all of the curved points and press the "Convert selected anchor point to corner" icon in the control panel to remove all the curved points.
Select the "Selection" tool and select the shape that you want to convert to a line.
Click "Object" in the menu bar and select "Average" from the "Path" submenu.
Select "Horizontal" to create a horizontal line or "Vertical." Then, click "OK." The shape will appear as if it were a line; however, if you select the line, you will notice that it is not a single line segment instead all of the points have moved to center.
Select the "Direct Selection" tool or the "Lasso" tool.
Select all the point except the two end points.
Press the "Delete" key.
Click on the "Window" menu and select "Stroke" to open the stroke panel. Apply the desired attributes such as stroke weight and style to the line.