Well, this example shows one way to lengthen a line. It doesn't utilize the Line class, just shows the math using the XYZ class. I would definitely check the Line class for any properties or methods that could help.
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
//Create a 'line' from 1,1 to 5,1
XYZ startPoint = new XYZ(1, 1, 0);
XYZ endPoint = new XYZ(5, 1, 0);
//Create a vector that represents the original 'line'
//and then generate a unit vector from it
XYZ originalVector = endPoint - startPoint;
XYZ unitVector = originalVector.Normalize();
//Generate a vector with a magnitude of the amount
//to lengthen the 'line'
double additionalLength = 5;
XYZ additionalLengthVector = unitVector * additionalLength;
//Find the new endpoint
XYZ newEndPoint = endPoint.Add(additionalLengthVector);
TaskDialog.Show("Lengthen Line Example", "Original endpoint: " + endPoint.ToString() +
"\nNew endpoint: " + newEndPoint.ToString());
return Result.Succeeded;
}
--
Bobby C. Jones