Hi.
Can anybody help me out in getting the number of a selected Node??!!
I have been trying to use the Node Index but without success.
Thank you very much.
Shape.Curve.Selection returns a noderange containing the selected nodes.
If you only have one node selected, then you could use:
Shape.Curve.Selection.FirstNode.Index
or
Shape.Curve.Selection.FirstNode.AbsoluteIndex
depending on whether you want the index of the node within the subpath that contains it, or in the curve as a whole.
Thank you for replaying.
You are absolutely right.And was doing this wrong, must understand how this works later.I was trying yo create a macro that changes the first Node.
My code is:
Sub ChangeFirstNode() Dim s As Shape Dim sp As SubPath Set s = ActiveShape Set sp = s.Curve.SubPaths(1) Dim n As Long ' I wanted to pass the Node Index value to a variable' but I get a error "Object doesn't support this property or method" n = s.Selection.FirstNode.Index If sp.Closed Then sp.Nodes(n).BreakApart sp.StartNode.JoinWith sp.EndNode End IfEnd Sub
Changing my code, removing this part: Dim n As Long ' I wanted to pass the Node Index value to a variable' but I get a error "Object doesn't support this property or method" n = s.Selection.FirstNode.Index
And changing this one to:
If sp.Closed Then sp.Nodes(ActiveShape.Curve.Selection.FirstNode.Index).BreakApart sp.StartNode.JoinWith sp.EndNode End If
It works. So, I'm missing something in the code. I'm learning as I go.
'n = s.Selection.FirstNode.Index' does not have any meaning for your code...
It should have a meaning changing it in 'n = s.Curve.Selection.FirstNode.Index. Exactly as Eskimo suggested.
Even in this way, to have a meaning and not returning an error you have to select (at least) a node...
Using Shape Tool (F10) and selecting it (them).
Without this, maybe it is good to explain what you exactly want. Even if you try to play and learn...
What do you select and what do you intend to do with that selected shape...
To be more spectacular (of course, on my taste...) the above Eskimo's code can be transformed in:
1 2 3 4 5 6 7 8 9 10 11 12 13
Sub change_subpath_start_node_bis() Dim s As Shape Dim spThis As SubPath Dim nodeThis As Node Set s = ActiveShape Set nodeThis = s.Curve.Selection.FirstNode Set spThis = nodeThis.SubPath If spThis.Closed Then nodeThis.BreakApart nodeThis.Move s.Curve.Nodes.last.PositionX - nodeThis.PositionX, s.Curve.Nodes.last.PositionY - nodeThis.PositionY End If End Sub
Of course you must select a node which will be moved to the last node of the shape...