8 Replies Latest reply on Oct 1, 2008 4:23 AM by (Dave_Saunders)

    [CS3][VB] Invalid object GeometricBounds in CS3

      Hello,

      I used in InDesign CS2 the following VB code:

      Set tfSupb = myRange.InsertionPoints.Item(1).TextFrames.Add
      tfSupb.parentstory.AppliedFont = myRange.InsertionPoints.Item(2).AppliedFont
      tfSupb.parentstory.PointSize = myRange.InsertionPoints.Item(2).PointSize * 0.6
      tfSupb.parentstory.Leading = tfSupb.parentstory.PointSize
      GB = tfSupb.GeometricBounds

      In InDesign CS3 I get in the last line the error:
      "Invalid object for this request"

      Is there a problem in CS3 when using GeometricBounds for frames in frames?

      Best regards

      Harald
        • 1. Re: [CS3][VB] Invalid object GeometricBounds in CS3
          Peter Kahrel Adobe Community Professional & MVP
          >Is there a problem in CS3 when using GeometricBounds for frames in frames?

          Generally not. And the JS equivalent of your code works fine. Maybe it's a VB thing.

          Peter
          • 2. Re: [CS3][VB] Invalid object GeometricBounds in CS3
            Level 1
            If adding the text frame as an inline pushed it into overset text, you'd get that error message.

            Dave
            • 3. Re: [CS3][VB] Invalid object GeometricBounds in CS3
              Level 1
              Hello Dave,

              thank you for confirm. I will change my VB code, if there is no workaround.

              Harald
              • 4. Re: [CS3][VB] Invalid object GeometricBounds in CS3
                Level 1
                It's just the way things work. And overset inline/anchored frame doesn't have geometry, so it doesn't have geometricBounds -- this is a change in CS3; previously, you'd get meaningless values, but that at least would allow you to work with the width and height.

                Dave
                • 5. Re: [CS3][VB] Invalid object GeometricBounds in CS3
                  Level 1
                  >And overset inline/anchored frame doesn't have geometry, so it doesn't have geometricBounds

                  Is there a way to query if an object is within the overset?

                  With this exception thrown I can't even test if it's overset or not.

                  if(textframe.geometricBounds==null) ... [crashes if textframe is in overset]

                  Thanks Tom
                  • 6. Re: [CS3][VB] Invalid object GeometricBounds in CS3
                    Level 1
                    If the parentTextFrames property of the parent of the anchored object is an array of length zero, then the object is in overset text.

                    Dave
                    • 7. Re: [CS3][VB] Invalid object GeometricBounds in CS3
                      Level 1
                      Hi Dave,
                      thanks for your quick reply.

                      I still have some problems with this. I created a scenario where a textframe holds some text plus another textframe.
                      Something like this

                      >// create outer textframe
                      var outerTF = app.documents[0].textFrames.add();
                      outerTF.geometricBounds = [30, 30, 100, 100];
                      outerTF.texts[0].contents = "Hello World!";
                      // create inner textframe
                      var innerTF = outerTF.characters[-1].textFrames.add();
                      innerTF.geometricBounds = [30, 70, 70, 90];
                      innerTF.texts[0].contents = "I am the inner Textbox";
                      // resize outer textframe so that the inner one becomes overset
                      outerTF.geometricBounds = [30, 30, 60, 60];
                      alert(innerTF.parent); // works fine

                      After that I tried to address the inner textframe in another script. When accessing the textframe via the textframes property of the textframe I even get exceptions when calling to textframe.parent. But when I access using the pageItems, it works fine.
                      I quite don't understand the reasons for that...

                      >// the following two lines of code work only if the inner textframe is not in overset - if it is in overset the expression "innerOne.parent" throws an exception
                      var innerOne = app.documents[0].textFrames[0].textFrames[0];
                      alert(innerOne.parent); // crashes

                      >// these following lines work fine whether or not it is in overset
                      var myinnertf = app.documents[0].textFrames[0].allPageItems[0];
                      alert(myinnertf.parent); // works fine

                      [edit: beware of the formatting; some parts are in the comments; dont't know how to insert explicit newline-chars]
                      • 8. Re: [CS3][VB] Invalid object GeometricBounds in CS3
                        Level 1
                        If the internal text frame is in overset then it is not in the text frame, it's in the parent story of the text frame.

                        The allPageItems property might be an interesting exception here. For example, in the UI, if you cut that last frame of the overset story and paste it somewhere else, then the overset content comes along for the ride, so it looks as though in this case allPageItems is picking up the overset page items where the pageItems property wouldn't.

                        Interesting difference of which I was not aware, but I can see how it makes sense.

                        Dave