Hello,

I have a diagonal line and would like to reduce it's length by 2 units. Is this done by trigonometry or are there utility functions available for computing points based on angle and length?

Thanks in advance!

Jr.

Cadtool is a commercial macro that can do it;

http://macromonster.com/product/alexander-penkins-cadtool-5/

The reverse button will be of interest, to cut off a piece of the diagonal line.

Here is an example of how you can do this. It doesn't matter if the line is straight or at any angle since it is using the segment length.

To test this code draw a single line say 6 inches long. Run the code and you will see that after it will now be 4 inches long.

Sub ShortenLine() Const dblLength As Double = 2 'Shorten by 2 inches Dim crv As Curve Set crv = ActiveShape.Curve crv.Segments.First.AddNodeAt (crv.Segments.First.Length - dblLength) / crv.Segments.First.Length, cdrRelativeSegmentOffset crv.Nodes.Last.Delete End Sub

Happy Coding,

-Shelby

Thanks Shelby,

I've been trying to do it with calculating a new X and Y using the nodes and the angle of a line segment (X3 = ChangeInX + Cos(angle) * 2 , Y3 = changeInY + sin(angle) * 2 etc.), but I must be doing something wrong. Somehow it changes the angle. Maybe I'll try to post the code later, but can you change the nodes by assigning a different X & Y? Your code is definitely easier to read though. Thanks!

Yep, say I wanted to move the first node you could so something like this:

crv.Nodes.First.SetPosition x, y

With the offset having to be between 0 and 1, how would you do the opposite? Lengthen the line by 2 inches?