Selected node coordinates return

Hello!
I have a 2 -point line. It's simple to determine X,Y coordinates of each of two nodes with VBA code. 

But how to determine X,Y coordinates of selected node /with Shape tool/?

Or how to make VBA code return 
MsgBox "Coordinates of selected node are: X = " & Snode.positionX & ", Y = " & Snode.positionY"

Or
MsgBox "Coordinates of UNselected node are: X = " UNnode.positionX & ", Y = " & UNnode.positionY"

Greetings!

Parents
  • One way to do that is to "walk through" the node range of the selected curve, check each node to see if it is selected, and then add it to a node range if it is.

    I already have a function written to do that. Here is a small macro that uses that function, then reports the coordinates of the selected nodes.

    Sub report_coordinates_selected_nodes()
    Dim noderangeSelected As NodeRange
    Dim nodeThis As Node
    
        Set noderangeSelected = get_selected_nodes_from_curve(ActiveShape.Curve)
        For Each nodeThis In noderangeSelected
            MsgBox "X: " & nodeThis.PositionX & vbCrLf & "Y: " & nodeThis.PositionY
        Next nodeThis
        
    End Sub
    
    Function get_selected_nodes_from_curve(ByVal Curve As Curve) As NodeRange
    
    Dim nodeThis As Node
    Dim noderangeSelected As New NodeRange
        
        On Error GoTo ErrHandler
    
        For Each nodeThis In Curve.Nodes
            If nodeThis.Selected Then
                noderangeSelected.Add nodeThis
            End If
        Next nodeThis
    
        Set get_selected_nodes_from_curve = noderangeSelected
    
    ExitFunc:
        Exit Function
    
    ErrHandler:
        MsgBox "Error occurred: " & Err.Description & vbCrLf & vbCrLf & "get_selected_nodes_from_curve"
        Resume ExitFunc
    End Function
    

    If there is a more elegant way to find the selected nodes, I would be interested in knowing what it is.

Reply Children
No Data