Hello,
I'm trying to write to write a macro which toggles the node between smooth or cusp.
Below code is intended to work on all selected nodes, but it only works on single node.
Sub toggleCusp_Smooth() Dim s As Shape, n As Node Set s = ActiveShapeFor Each n In s.Curve.Nodes If n.Selected Then If n.Type = cdrCuspNode Then n.Type = cdrSmoothNode ElseIf n.Type = cdrSmoothNode Then n.Type = cdrCuspNode End If End If Next nEnd Sub
Thanks.
Try:
Sub toggleCusp_Smooth() Dim s As Shape, n As Node
Set s = ActiveShape For Each n In s.Curve.Selection If n.Type = cdrCuspNode Then n.Type = cdrSmoothNode ElseIf n.Type = cdrSmoothNode Then n.Type = cdrCuspNode End IfNext nEnd Sub
Node selection is lost after the macro runs.How do I retain the selection?Thanks.
Sub toggleCusp_Smooth() ActiveDocument.BeginCommandGroup "Toggle Cusp-Smooth" Dim s As Shape, n As Node
Set s = ActiveShape Dim SelectedNodes As NodeRange Set SelectedNodes = s.Curve.Selection
For Each n In SelectedNodes If n.Type = cdrCuspNode Then n.Type = cdrSmoothNode ElseIf n.Type = cdrSmoothNode Then n.Type = cdrCuspNode End If Next n SelectedNodes.CreateSelection ActiveDocument.EndCommandGroupEnd Sub
The macro result should not depend on BeginCommandGroup - EndCommandGroup construction, but it depends on my comp.
Thank you very much for the code.