(Re)Draw a straight line

Say that I have line drawn at 87 degrees, and I later want it to be at 90 degrees (or 180, 270 or 0).  Is there a way to "straighten" the existing line, or must I redraw the line with constraints?

  • when I don't want to redraw I do it this way:
    1. enable SnapToObjects (Alt-Z), move line's rotation point to one of its ends
    2. create a guideline, snap it to that same line's point, enable SnapToGuides (it's the default behaviour)
    3. switch to rotate mode, grab the other end point of the line so that it is "snapped" (tick mark is shown) and rotate it so that the node snaps to the guideline

    .....I've just thought that I need this a few times a week, so here's two macros to straighten such lines, but don't ask me how to use them, LOL

    Sub StraightenLinesH()
       Dim sh As Shape, a#, x1#, y1#, x2#, y2#, x#, y#
       On Error Resume Next
       ActiveDocument.ReferencePoint = cdrCenter
       ActiveDocument.BeginCommandGroup "Straighten lines horizontally"
       
       For Each sh In ActiveSelection.Shapes.FindShapes(, cdrCurveShape)
          sh.GetPosition x, y
          With sh.Curve.Nodes
             .First.GetPosition x1, y1
             .Last.GetPosition x2, y2
          End With
          If y1 <> y2 Then
             If x1 = x2 Then a = -90 _
                Else a = CorelScriptTools.AngleConvert(2, 1, _
                            Atn((y2 - y1) / (x2 - x1)))
             sh.RotateEx -a, x, y
          End If
       Next
       
       ActiveDocument.EndCommandGroup
    End Sub
    
    Sub StraightenLinesV()
       Dim sh As Shape, a#, x1#, y1#, x2#, y2#, x#, y#
       On Error Resume Next
       ActiveDocument.ReferencePoint = cdrCenter
       ActiveDocument.BeginCommandGroup "Straighten lines vertically"
       
       For Each sh In ActiveSelection.Shapes.FindShapes(, cdrCurveShape)
          sh.GetPosition x, y
          With sh.Curve.Nodes
             .First.GetPosition x1, y1
             .Last.GetPosition x2, y2
          End With
          If x1 <> x2 Then
             If y1 = y2 Then a = 90 _
                Else a = CorelScriptTools.AngleConvert(2, 1, _
                            Atn((x2 - x1) / (y2 - y1)))
             sh.RotateEx a, x, y
          End If
       Next
       
       ActiveDocument.EndCommandGroup
    End Sub

  • Another option is to turn on dynamic guides (alt+shift+d). With a little practice, you can straighten a line to 90 degrees with the nodeedit tool very quickly.

    Regards,
    Hendrik

    • Thank you, too, Hendrik.  There is so much functionality in DRAW that I was certain there was something(s) I was missing in the manner of a simple adjustment in the way I was doing this.

      Regards,
      Mad Dog