9 Replies Latest reply on Mar 22, 2013 2:10 PM by Jump_Over

    finding X value of selection

    bduffy323 Level 1

      Is there any way of finding the X coordinate of the current selection without temporarily grouping, finding the x value of the group and then ungrouping? Or accessing the X value next to the transformationPoint in the layout window?

        • 1. Re: finding X value of selection
          [Jongware] Most Valuable Participant

          "The" x value? Left? Center? Right?


          To get any if these three, you need not group everything first. Just gather all x coordinates from their geometricBounds and: for Left, take the minimum; for Right, take the maximum; for center, first find the minimum *and* maximum and use the average.

          • 2. Re: finding X value of selection
            Laubender Adobe Community Professional & MVP

            @bduffy323 – would you like to consider anchored objects for calculating the x coordinates?
            Then Jongware's method would be best. Of course you have to use "allPageItems" for every selected object to get ALL the geometric bounds. Maybe even better to use the visual bounds of the objects…


            In this case the UI controls are misleading and grouping the objects does not add information…


            Something more to consider:
            At first glance this task seems trivial, but unfortuantely it is not, if you want to take into account tables that exceed text frames, effects like drop shadows, text on paths, generally spoken, texts that exceed the text frames and the case of anchored objects.




            • 3. Re: finding X value of selection
              bduffy323 Level 1

              @jongware That is what I normally do until I reached a situation shown below. For me, this group of page items needs to be assigned the x-value from page one. By just running through the geometric bounds for each of the pages items, the top page item returns an x value based on the right page. So my solution was to temporarily group the objects, get the x value and then ungroup. However, this was becoming an issue because the group was bringing pageitems that were behind other items to the front and not sending them back on an ungroup. I am trying to avoid temporarily changing the rulerOrigin to spread but I'm pretty sure that would work. I was really hoping there was a way to get the bounds that shows when I select a group of page items.




              @Uwe - I am coming to realize that this task isn't as trivial as I first thought it would too! I run through allpageitems that are tied to my label then attempt to climb the parent tree to a top level page item. Which proves to be difficult with anchored objects!

              • 4. Re: finding X value of selection
                Laubender Adobe Community Professional & MVP

                @bduffy323 – That's a valid point!


                To find out, if a specific object is an anchored one, you can check its parent:

                that will always be a character.



                • 5. Re: finding X value of selection
                  bduffy323 Level 1

                  @Uwe - This is PRECISELY what I did. I didn't know if this was always valid but it seemed to work so it is nice to know that. Side note to this thread. Is there anyway of getting the pageitem that anchor is inside of?

                  • 6. Re: finding X value of selection
                    Laubender Adobe Community Professional & MVP

                    That should be the "parentTextFrame".


                    This, of course, is an array and since we have only one single character to consider, you will be good with "parentTextFrames[0]". It will usually result in a TextFrame Object; is the character part of text on path, you'll get a TextPath Object.


                    And that could be part of a text frame (or a spline item of the type Rectangle, Oval or Polygon), which itself could be anchored, etc.pp.


                    No nice and easy task, in my opinion…
                    Is someone else here to cut this Gordian Knot? ;-)



                    • 7. Re: finding X value of selection
                      Dirk Becker Level 4

                      We recently had a short discussion of the rarely used resolve method (not the global one!).


                      var xy = tf.resolve(AnchorPoint.TOP_LEFT_ANCHOR,CoordinateSpaces.SPREAD_COORDINATES)[0];



                      • 8. Re: finding X value of selection
                        bduffy323 Level 1

                        I actually saw that post before posting this one. When I tried this method I got strange results including some negative values.

                        • 9. Re: finding X value of selection
                          Jump_Over Level 5


                          @bduffy323, in case of your post no 3,

                          did you consider to change a doc view pref rulerOrigin to SPREAD

                          to avoid repeating X-values accross a spread?