2 Replies Latest reply on Feb 10, 2011 9:19 AM by flavioflavio

    depth ruler can return value?

    flavioflavio Level 1

      Hi, there,


      I have some texts I'd have to measure when they are printed. I know InCopy can show the "depth ruler" in Galley and Story modes and, there, it shows me the texts' sizes. I'm trying to do a script that, when I select some pice of text, returns me a value that'd be that text's size in print. Here's what I've got so far:


      var selectedLines = app.selection[0].lines.length;

      //gives me the number of lines selected

      alert ('"'+selectedLines+'"');


      //multiplies that number by the text's size in print

      var test = selectedLines *2.7;

      alert ('"'+teste+'"');


      Here, I'm considering that each line has 2,7 mm in print. But I think my approach is wrong, because it considers only one paragraph style. If I use different styles, that math will not work.


      Maybe if there was a way of getting the values of the depth ruler at the beginning and end of the selection, that'd be great, but I'm not finding anything about it... I considered getting the text frame geometric bounds, but I guess that would only work for the whole story, since all my text is in only one text frame...


      Or, even, if there's any other approach to the matter, that'd be also welcome...


      thanks a lot!


        • 1. Re: depth ruler can return value?
          flavioflavio Level 1

          Here goes my progress: I've managed to do a search for style (so as to create a function). Now, for each style in the document (or in the selected text), I can find the number of lines that style uses - then, the next step would be just to multiply that number of lines by the physical space ocupyied by each line in a physical print.


          Here it goes:


          //Search for Paragraph Style:
          app.findGrepPreferences.appliedParagraphStyle = "TX - TEXTO"; 
          var myFoundItems = myDocument.findGrep();
          //To do that only in the selected text, change the above line to:
          //var myFoundItems = app.selection[0].findGrep();
          var myTxTEXTOLines = 0;
          //Add the number of lines found for that style:
          for (var myCounter = 0; myCounter<myFoundItems.length; myCounter++){
               var myTxTEXTOLines = myTxTEXTOLines + myFoundItems[myCounter].lines.length;
          alert ('"The number of lines with style TX - TEXTO is: '+myTxTEXTOLines+'"');


          So, in a sense, I guess that with this I can get where I want to, but it would be simpler if I could do something using the 'depth ruler' value... Any hints?




          • 2. Re: depth ruler can return value?
            flavioflavio Level 1

            Hi, there,


            Any answer would be welcome, even if it is a 'it's not possible do use the depth ruler value, it's calculated internally but you can't access it'.