Sorting shapes by outline colors, including Groups

Hello, all.

Yet again I am coming up with more and more peculiar questions. This time it is about using CQL or something else to sort things by outline colors. What is necessary, is sorting the shapes by their RGB outline color G value (I have to use that because it is the only thing another system can change as far as shape data goes). This works great with regular shapes:

ActiveRange.Sort "@shape1.Outline.Color.rgb.G > @shape2.Outline.Color.rgb.G"

But, as discussed in the other topic, grouped shapes are unable to return outline colors. So how to sort a ShapeRange of both shapes and shape groups based on outline colors? Is there an easier way than making some sort of an array with StaticIDs + outline colors (read from inside the group when necessary), sorting it based on the color value and then rearranging a ShapeRange by going through that array and just sending things back or front in sequence?

Parents
No Data
Reply
  • Hello Joe, 

    This is a very good question. Groups can make things much more interesting for sure. What I normally do is create a variable for a ShapeRange then us the FindShapes() to dig into all the groups and return the shapes. I do not normally want the groups in the ShapeRange I am going to be working with, so I remove any groups from the Range.

    Now that I have a ShapeRange with just the shapes, I would do the sort. 

    Set sr = ActiveSelectionRange
    Set sr = sr.Shapes.FindShapes()
    sr.RemoveRange sr.FindAnyOfType(cdrGroupShape)
        
    sr.Sort "@shape1.Outline.Color.rgb.G > @shape2.Outline.Color.rgb.G"
    

    Happy Coding,

    -Shelby

Children