Reduce Length of Diagonal Line Segment VBA

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.

Parents
  • 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

Reply Children