6 Replies Latest reply on Jul 18, 2013 6:11 PM by JETalmage

    Z Order based on relative position


      Hello All,


      Sorry if this is a simple question, I just can't seem to find a way to do this. I am using multiple objects to make larger more complex objects. As part of this I need a way to select a large group of objects and adjust their Z Order. For example, say I have a grid of 100 squares, 10 columns of 10 squares. I want to arrange them so the squares (rows) toward the bottom of the grid are in front (bring to front/bring forward) the squares that are higher up in the grid. Basically, every row should be further back in the Z order than the row below it.


      Now you might say well for a grid this is simple just select every object/square in the row and move them forward or back as needed. But in my case they are not actually arranged in a neat grid, they are pretty randomly thrown together. But the requirement is still the same, I want to take all of the objects and arrange them so the objects that are closer to the bottom of the art board are further forward in the Z order than the objects above them. Basically think of the bottom of the artboard as being the front most row of the Z order and the top of the art board as the furthest back in the Z order. I use this type of configuration to give the perception of depth and form. Below you can see an example of a cloud like graphic created using this technique by manually adjusting each individual object which takes forever on larger objects. I pick a point toward the bottom, and then I manually start adjusting Z order on each item until I get the effect I want. Having some way to pick a point on the art board and then arrange the objects above and below it on the Y axis by moving them forward or back in the Z order as needed would save me a ton of time. As you can see below, from about the 3rd or fourth row of squares from the bottom, I have brought those to the front, and each row above or below it has had it's Z order adjusted to give the impression of depth. Each consecutive row after the foreground row is progressively further back in the Z order. Can anyone think of a way to automate this so that I can atleast have a base to start with before I start doing my manual adjustments? Thanks!



        • 1. Re: Z Order based on relative position
          Steve Fairbairn Level 5


          You mean stack or what?

          • 2. Re: Z Order based on relative position
            JETalmage Level 5

            All the transformations in Illustrator, except for explicit send back/forward/front/rear and the Symbol Shifter, are about X/Y shifts. But that doesn't change the fact that everything in Illustrator still has a Z stacking order; it's just effectively "automatically asigned" by the creation order. Patterns, brushes, effects, even meshes and dashes auto-replicate things, but the copies do not occur at the same Z position; they still have a Z order.


            So simply use to advantage the tools which automate replication.


            Don't create a Group. Draw one object. Store it as a Symbol.

            Apply Transform Effect with copies to create a row; apply Transform Effect again to create a stack of rows.

            Do it again to create a stack of matrices.

            To impart a bit of random distribution, Expand Appearance, Ungroup; apply Transform Each with the Random option on.







            • 3. Re: Z Order based on relative position
              BluePhaze Level 1

              Thanks for the info JET. I will mess around with it and see if I can get it to work. I am wondering if it may be easier if I want a more controled effect to create a custom action or macro that can iterate through a large group of objects and set the z stacking order on them in this way as well...

              • 4. Re: Z Order based on relative position
                JETalmage Level 5

                I am wondering if it may be easier if I want a more controled effect to create a custom action or macro...

                Easier? Using multiple applications of Transform Effect is easy:


                • The transformation parameters are still editable after-the-fact.
                • The transformation stack can be stored as a Graphic Style.
                • Using a Symbol lets you swap out the entire array using the Replace Symbol command.


                You can make a Graphic Style which results in a "one dimensional" array (a line of ordered duplicates), another Style for a "two dimensional array" (a grid of ordered duplicates), and another Style for a "three dimensional array" (an ordered stack of grids). That set of Styles, in combination with Symbols is quite versatile and re-usable. All four of the examples I depicted are re-applications of the same Style and/or minor tweaks of the parameters, and a Symbol replacement.


                The problem with Actions is the matter of "iteration through a large group." Actions (macros) are just dumb recordings of a sequence of standard interface commands. To iterate through a large group, you have to devise a means by which make the Action select the appropriate "next" object. There is no programmable aspect to Actions. So you would have to figure a way to "define" for the Action what "next" means in terms of standard commands. The regular Select>Next Object Above/Below won't do you any good, because they already refer to the existing stacking order (the very aspect you are trying to edit), not the merely visual arrangement (the X/Y positions of each). So devising a means that would work for all similar instances is unlikely and will be unwieldy.


                Scripting can be used, but it's certainly not "easier" to set up, and you have a similar problem in that you have to very explicitly work out exactly what you want to occur. You can't code human "fuzzy logic" like "the next object in this group" without defining exactly what "next" means. In other words, if "next" means to you the object merely visually located at a "higher" or "lower" or "left" or "right" position on the page, you have to explicitly code that so as to target the desired objects in the requred sequence. And once a script is run, it's done. You don't invoke the script to go back and "further" adjust what it's already done. The script is starting all over.


                For example, I have a set of scripts which I use to re-arrange the z-order of individual textFrames in correct reading order, so that the reading order is correct when the text is concatenated into a single textFrame. (A common problem when dealing with text in CAD imports.) But that's a repeatable algorithm for a repeatingly similar situation. The situation you are describing is not like that.


                So before you dismiss the suggestion already provided, try it.



                • 5. Re: Z Order based on relative position
                  BluePhaze Level 1

                  Hello JET, I did try it, I was not dismissing your method at all. The symbol transform works great as long as I plan it from the beginning. The other peice for a script or action is for those situations where I have already done a great deal of work or already have a large number of objects that are not symbols and am trying to arrange them after the fact. I also wish I had started using symbols much earlier due to realizing I now need to go back and adjust some of the elements of existing objects which in some cases there are hundreds. Oh well, I will have to start doing that in the future. Thanks again for all of your assistance!


                  Any idea if there is a way when selecting a group of objects if you can have it intelligently change the stroke color for just those pieces in the groupt that have a visible stroke? For example I have hundreds of leaves on a tree. Each leaf is a small group made of multiple pieces some with stroke applied and some with the stroke set to none (not visible). I realized I need to change the stroke color on the parts that actually have a stroke showing. Going into each leaf object and inidividually updating the stroke on the peices within the leaf that have a visible stroke is going to be a nightmare as I have hundreds of leaves...


                  Thanks again for the transformation approach, I did not mean to sound as if I was dismissing it, I should have been more clear in that reply that I had tried it and the script peice was in regards to projects that are already far along that did not use symbols. Any idea if I have hundreds of copys of an object if there is a way to have it convert all of them to instances of a symbol?

                  • 6. Re: Z Order based on relative position
                    JETalmage Level 5

                    ...I need to change the stroke color on the parts that actually have a stroke showing...

                    See the documentation for the several Select Same... commands. (Not nearly as powerful as select-by-attribute features in other programs, but will probably do what you describe, unless there are complicating issues you have not described.) Subselect (white pointer) one of the paths with the stroke. Select>Same>Stroke Color. Apply a different Swatch.


                    Similar selections are possible (to select similar attributes within a tolerance range) with the Magic Wand selector.


                    I have hundreds of copys of an object if there is a way to...convert all of them to instances of a symbol?

                    That's something I use a script for; not because I fail to use Symbols from the start, but as a subroutine for more elaborate automation procedures that necessarily involve an intermediate step in which many non-Symbol objects are generated. It's a fairly simple thing to script, and is a good exercise to get acquainted with scripting.


                    Get in the habit of always considering Symbols whenever you find yourself using multiple occurrances of the same graphic.