Skip to main content
June 1, 2009
Question

How to detect a polygon text area

  • June 1, 2009
  • 1 reply
  • 1694 views

In my script I am looking at each textFrame to determine its alignment and orientation. No problem here. But, I also need to determine if the artist has specified a polygon rather than the standard rectangle for the text area. Is there a way to do this in the script?

Thanks in advance - Steve

This topic has been closed for replies.

1 reply

Larry G. Schneider
Community Expert
Community Expert
June 1, 2009

Have you tried looking at the path item/entire path properties of the text frame. Seems like more than 4 would indicate a polygon (except for 8 which could be a rounded rectangle).

June 1, 2009

Larry - thanks for the suggestion but I wasn't able to get the following to work:

confirm(sourceDoc.textFrames.pathItem.entirePath)

or

confirm (sourceDoc.textFrames.pathItem.pathPoints)

I receive the "undefined is not an object" error message.

It is probably of note that I am only looking at textFrames that meet the following criteria:

kind == 'TextType.AREATEXT'

Also - I am scripting for CS3 not CS4 should this be a new property.

Am I doing something wrong? Or do I need to upgrade to CS4?

Steve

CarlosCanto
Community Expert
Community Expert
June 2, 2009

Hi Steve, you can accomplish that by comparing the area property of the TextPath against your own square calculated area (width * height), if they are different then it is a polygon.

' // code

    A = YourTextFrame.TextPath.Area

    W = YourTextFrame.TextPath.Width

    H = YourTextFrame.TextPath.Height

     if A = W*H then

          msgbox "it is a square"

     else

          msgbox "it is a polygon"

     end if

' // end code

sorry, I only do VB, but you get the idea to turn it into JS or AS

CarlosCanto