5 Replies Latest reply on Oct 12, 2017 5:22 AM by frameexpert

    Fetching AFrame for each page

    KeKeJ

      Hi,

       

      I want to fetch all Aframes information in an active doc whose layout has three columns for each page.

       

      WS000001.jpeg

       

       

       

       

      I wrote the code below:

       

      #target framemaker 

      var doc = app.ActiveDoc;

      if (doc.ObjectValid() == true) {

          var page = doc.FirstBodyPageInDoc;

          while (page.ObjectValid()) {

              var graFrame = page.PageFrame.FirstGraphicInFrame;

              while (graFrame.ObjectValid()) {

                  var subcol = graFrame.FirstSubCol;

                  while (subcol.ObjectValid()) {

                      var aFrame = subcol.FirstAFrame;

                      while (aFrame.ObjectValid()) {

                          alert(page.PageNum + " " + aFrame.Width); // display Info about Aframe

                          aFrame = aFrame.NextAFrame;

                      }

                         subcol = subcol.NextSubCol;

                  }

                  graFrame = graFrame.NextGraphicInFrame;

              }

              page = page.PageNext;

          }

      }

       

       

      This code does not work correctly.

      Alert message like below;

      -----------------------------

      0 1000

      0 2000

      1 2000

      -----------------------------

       

       

      The second alert, "0 2000" is undesirable, because this information about Aframe on page 1.

      "var subcol" ignores the page.

       

       

      Could you teach me how to fix it, please?

       

       

      Thanks,

      Koji Koike

        • 1. Re: Fetching AFrame for each page
          frameexpert Level 4

          Are all of the anchored frames in the document's main text flow? Or are some of them in tables? Do you have to process the anchored frames in document order or can you process them in in any order? If you can answer these questions, I can give you some help. Thanks.

          • 2. Re: Fetching AFrame for each page
            KeKeJ Level 1

            > Are all of the anchored frames in the document's main text flow?

            Yes, all of them in a document's main text flow.

             

            >Do you have to process the anchored frames in document order

            Yes, I just want to collect information about width of anchored frames, in page sequence.

             

            The following is the solution I considered.

            ...................................................................

                        var subcol = graFrame.FirstSubCol;

                        while (subcol.ObjectValid()) {

                            var aFrame = subcol.FirstAFrame;

                            while (aFrame.ObjectValid()) {

                                alert(page.PageNum + " " + aFrame.Width); // display Info about Aframe

                                aFrame = aFrame.NextAFrame;

                            }

                           

                            // Below lines are the solution not to go subcol.NextSubCol on next page.

                            // first column's LecX value is 1857710.

                            if (subcol.NextSubCol.LocX == 1857710) {

                                break;

                            } else {

                                subcol = subcol.NextSubCol;

                            }   

            ...................................................................

             

            But, it is not smart, I think.

            If you have better way to solve, please teach me.

             

             

            Thanks.

            • 3. Re: Fetching AFrame for each page
              frameexpert Level 4

              I would do something like this:

               

              #target framemaker
              
              var doc = app.ActiveDoc;
              var flow = doc.MainFlowInDoc;
              
              var textList, i, aframe, page;
              
              // Get a list of anchored frame text items in document order.
              textList = flow.GetText (Constants.FTI_FrameAnchor);
              for (i = 0; i < textList.length; i += 1) {
                  // Get the anchored frame object.
                  aframe = textList[i].obj;
                  // Get the page that contains the anchored frame.
                  page = getAFramePage (aframe);
              }
              
              function getAFramePage (aframe) {
                  
                  var textFrame, uframe, page;
                  
                  textFrame = aframe.InTextFrame;
                  uframe = textFrame.FrameParent;
                  page = uframe.PageFramePage;
              
                  return page;
              }
              
              1 person found this helpful
              • 4. Re: Fetching AFrame for each page
                KeKeJ Level 1

                I see, even better way than mine.

                And, this is a nice  to understand how to handle the objects in FrameMaker.

                 

                Many Thanks!

                • 5. Re: Fetching AFrame for each page
                  frameexpert Level 4

                  Keep in mind that this will only get anchored frames in the main text flow, not including those that might be in tables.

                  1 person found this helpful