Simple macro request: Create a node at the center between two selected nodes - macro.

Should be very easy, but I lack node manipulation knowledge and couldn't find the magic code words.

Parents
No Data
Reply
  • This might get you started:

    Sub add_node_halfway_selected_segment()
    
    Dim nodeThis As Node
    Dim noderangeSelected As New NodeRange
    
        For Each nodeThis In ActiveShape.Curve.Nodes.All
            If nodeThis.Selected Then
                noderangeSelected.Add nodeThis
            End If
        Next nodeThis
        
        If noderangeSelected.Count = 1 Then
            If noderangeSelected(1).Index > 1 Or noderangeSelected(1).SubPath.Closed Then
                noderangeSelected(1).segment.AddNodeAt 0.5, cdrRelativeSegmentOffset
            Else
                MsgBox "Selected Node cannot be the first Node of an open SubPath"
            End If
        Else
            MsgBox "Exactly one Node must be selected."
        End If
    End Sub
    

    That doesn't get into the niceties of checking that a document is active, checking that the selection is a single Curve shape, error handling, etc.,

    Note that the node you need to select is the "end node" of the segment to which you wish to add the new node.

Children