Hi, all!
So the ShapeRange.Sort function is really powerful, saving tons of code. You can compare position...
ActiveSelectionRange.Sort "@shape1.left < @shape2.left"
even area in a way...
ActiveSelectionRange.Sort "@shape1.width*@shape1.height > @shape2.width*@shape2.height"
which is great, but my question is - can you stack these? I'd like to sort my ShapeRange in such a way that we have bottom-left shapes first, then the next leftmost one, etc. Basically a Bottom Left sort. I did try some things, like separate sorts, combining the queries with &, but no luck.
Can any of the pros chime in if this is possible? Thanks!
Agreed it is a fun and interesting problem. You could try something like this:
Sub SortLeftToRightTopToBottom() Dim s As Shape Dim sr As ShapeRange Set sr = ActiveSelectionRange sr.Sort " @shape1.Top * 100 - @shape1.Left > @shape2.Top * 100 - @shape2.Left" For Each s In sr.Shapes ActiveLayer.CreateArtisticText s.CenterX, s.CenterY, sr.IndexOf(s), , , "Arial", 12 Next s End Sub
This works best if the shapes are similar sizes.
If you wanted to do text I would change each character to the same character so the short then change the character back. You could also do it with a copy.
Happy Coding,
-Shelby
Joe,
Sure you could do something like this:
Sub SelectByArea() Dim sr As ShapeRange Set sr = ActiveSelectionRange.Shapes.FindShapes(Query:="@com.DisplayCurve.Area > {.072 in^0}") MsgBox sr.Count End Sub
Hope that helps,
drz,
They have done a pretty good job at documenting CQL you can find that documentation here:
Best of luck,