Skip to main content
Inspiring
August 2, 2017
Answered

Rectangle geometricBounds property causing the error 'invalid object for this request'

  • August 2, 2017
  • 1 reply
  • 834 views

I have a textFrame a small number of graphicObjects that are grouped together.  The text frame checks to see if it is part of a group and processes each of the graphic elements.

var parent = sign.textFrame.parent;

if (parent != undefined)

{

// see if this sign is part of a group then grap the other graphic elements

     if (parent instanceof Group)

     {

     for (var i = 0; i < parent.allPageItems.length; i++)

     {

          var graphicItem = parent.allPageItems;

          if (graphicItem instanceof Rectangle)

          {

            var saRectangle = new SARectangle(graphicItem);

            this.rectangles.push(saRectangle);

          }

     else if (graphicItem instanceof GraphicLine)

     {

          var saLine = new SALine(graphicItem);

          this.lines.push(saLine);

     }

}

The SARectangle function is defined as:

function SARectangle (rectangle)

{

     this.rotation = rectangle.absoluteRotationAngle;

     logger.info("Rectangle: ")

     boundsProperty  = (rectangle.visible ? 'visible' : 'geometric') + 'Bounds';

     var rect = rectangle[boundsProperty];

     this.upperLeft = new SAPoint(rect[1], rect[0]);

     this.lowerRight = new SAPoint(rect[3], rect[2]);

     this.upperLeft.toPixels();

     this.lowerRight.toPixels();

     logger.info("upperLeft (" + rect[1] + "," + rect[0] + ") to upperLeft (" + upperLeft.x + "," + saUpperLeft.y + ")");

     logger.info("lowerRight (" + rect[3] + "," + rect[2] + ") to upperLeft (" + upperLeft.x + "," + saUpperLeft.y + ")");

}

The problem is that the geometricBounds property does not seem to be defined!  When the rect variable is assigned the error 'invalid object for this request' is thrown.

Any help would be appreciated.

This topic has been closed for replies.
Correct answer Bill McLean

A second time around looking at the problem allowed me to solve the issue.

Just check to see if the geometric bounds rectagle is defined then do the processing otherwise ignore it.

1 reply

Bill McLeanAuthorCorrect answer
Inspiring
August 6, 2017

A second time around looking at the problem allowed me to solve the issue.

Just check to see if the geometric bounds rectagle is defined then do the processing otherwise ignore it.