3 Replies Latest reply on Jun 8, 2009 5:04 AM by [Jongware]

    How to differentiate a created outlines from Anchor?

    R_Thangaraj

      Hi every body

      here i created one anchor and one outlines using createOutlines now i need to differentiate outlines from anchor by javascript code

      pls help me

        • 1. Re: How to differentiate a created outlines from Anchor?
          [Jongware] Most Valuable Participant

          Some more information would have been helpful, I had to try different things for myself to see when this exactly happens. Apparently, you have some text selected and do an "app.selection[0].createOutlines(true)" on that -- that gives the result you describe, a new anchored object in the active story (and as a side result, the original text disappears).

           

          Since you are converting to outlines yourself, it would be easiest to label the new object as 'this was text'. The createOutlines method returns the newly created object as an array (and I think it always has just one item, but you should check that -- I repeat you should check that), and you can change your code to

           

          a = app.selection[0].createOutlines(true);
          a[0].label = "this used to be text, honestly";

           

          Later on, if you need to know whether a specific anchored object used to be text, check its label.

           

          If you already converted tons of text to outlines and only now thought of checking, I guess any object with more than a certain number of path segments would qualify as 'not a regular frame'. A quick check using

           

          alert (app.selection[0].paths.length);

           

          shows that rectangles and ellipses have only 1 path, the text 'Wot', converted to outlines, is a single polygon consisting of 4 paths (the outside of characters 'W', 'o', and 't', and the inner circle of the 'o'). In case of doubt with a single path, you could check the number of pathPoints per path:

           

          alert (app.selection[0].paths[0].pathPoints.length);

           

           

          (where you probably should check every path, not assume it's the 0-th one). This results 4 for a single rectangle or ellipse, and 24 for a 'W' converted to outlines.

           

          Note that this is not a 100% sure way of checking. A 5-pointed star drawn with the polygon tool has 10 path points; on the other end, a lowercase Helvetica 'L', converted to outlines, is for all practical purposes indistinguishable from a regularly created rectangular frame.

          • 2. Re: How to differentiate a created outlines from Anchor?
            R_Thangaraj Level 1

            Hi,

            this is not working that you gave,

            can you tell me one?

            how can i get access anchor object text frame text value

            if i can get access these data by javascript code i can easily differ from outlines object

            pls tell me..

            • 3. Re: How to differentiate a created outlines from Anchor?
              [Jongware] Most Valuable Participant

              "It does not work" -- the code snippets I gave do work, at least on my machine, Windows, CS3, JavaScript, on selected items.

               

              Perhaps this will help:

               

              alert (app.selection[0].parent.allPageItems.length);

               

              shows how to get the inline items, if you run it with the text cursor within a story (a text frame). If you select a frame it shows the number of contained items (anchored objects or inline items) plus 1, as it counts the frame itself as well. I don't know how to differentiate between anchored objects and inline ones at this point.