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!
Hello,
FWIW, we have ecut 6 as a commercial solution for this. It offers various sorting parameters in its routing module. It's ready to go, for those who want to cut jobs faster and with less movement on the machine.
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,