Can't get "true" height of text box (text object) in Photoshop CS4-CS6

I’m seeing this behavior in Photoshop CS4, CS5 and CS6 on the Mac using AppleScript. When I get the height of a text object layer as such:

 tell app "Adobe Photoshop CS4"
      tell current document
           set textObjectHeight to height of text object of art layer 1
      end tell
 end tell

The value returned doesn’t match the height of the text object. In my mind the text object is the box that’s displayed when I click on text in a text layer with the text tool active. The value for the width appears to match, just as I’d expect.

I’m trying to get the height and width of the text box (text object) so that I can draw a box “underneath” it on another layer so that one can tell where the text box is. Kind of an FPO-type assistant. I’m currently using the position values and the height and width to create a colored box. I realized that the height isn’t exactly right.

Any help would be great appreciated. I’ve not explored the use of Javascript thus far, but am open to that as a solution.

Thanks,
Stephan

Turns out the issue is related to the documents resolution. You also need to set the unit types for type and rulers to pixels. Here’s my updated code:

tell application “Adobe Photoshop CS4”
–Capture unit types
set initialTypeUnit to type units of settings
set initialRulerUnit to ruler units of settings
–Set unit types to pixels
set ruler units of settings to pixel units
set type units of settings to pixel units
activate
tell current document
set docRes to resolution
set textObjectPosition to position of text object of art layer 1
set textObjectPositionX to item 1 of textObjectPosition
set textObjectPositionY to item 2 of textObjectPosition
set textObjectWidth to (width of text object of art layer 1) * (docRes / 72)
set textObjectHeight to (height of text object of art layer 1) * (docRes / 72)
make art layer at end with properties {name:“fill”}
select region {{textObjectPositionX, textObjectPositionY}, {textObjectPositionX + textObjectWidth, textObjectPositionY}, {textObjectPositionX + textObjectWidth, textObjectPositionY + textObjectHeight}, {textObjectPositionX, textObjectPositionY + textObjectHeight}} without antialiasing
fill selection with contents {class:RGB color, red:255, green:0, blue:0} blend mode normal opacity 100 without preserving transparency
deselect
end tell
–Reset unit types
set ruler units of settings to initialRulerUnit
set type units of settings to initialTypeUnit
end tell