AE ENHANCERS

Expressions/Scripts/Presets
It is currently Sat May 25, 2013 8:34 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 63 posts ]  Go to page 1, 2, 3, 4, 5  Next
Author Message
 Post subject: Determining Width and Height of a Text Layer
PostPosted: Wed Feb 02, 2005 12:14 am 
Offline

Joined: Thu Oct 21, 2004 12:36 am
Posts: 86
Location: Phoenix, AZ
Is it me or is this another item to add to the list of, "Text Layers don't Expose Much Functionality to Scripting":

The width and height of a text layer reported in a script (or expression, for that matter) is the same as the width and height of the comp. If anyone has any ideas as to how to get the actual width and height of a text layer, it would be greatly appreciated.

Thanks,
Peter


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 03, 2005 3:00 am 
Offline

Joined: Sat Dec 04, 2004 10:10 am
Posts: 36
You should create a plugin for that, in fact ^^

I don't know if t has been coded yet :D

_________________
http://www.shinjipierre.be/


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 24, 2005 1:43 pm 
Offline

Joined: Thu Oct 21, 2004 12:36 am
Posts: 86
Location: Phoenix, AZ
For the record, I took Shinjipierre's advice and wrote a plug-in that would return the actual width and height of a Text Layer... almost.

The way Text Layers are implemented, the layer is actually the size of the comp and never moves. The text is then rendered onto that layer by the text engine. This can be observed in other ways such as applying a healthy blur to a Text Layer and then positioning the text near the edge of the comp. Lo and behold, the blur will fade at the edge of the comp even though the text seems to extend beyond.

So, my plug-in successfully reports the width and height of the text so long as it is contained entirely within the comp, which isn't what I was after to begin with. Also, for some odd reason, I had an interaction problem where, when the plug-in was enabled, I was only able to edit the text one character at a time before it would pop out of the editing mode. Strange.

Oh what glorious wonders I suspect are hiding in the unseen depths of the TextDocument, both in scripting and the SDK API.

Peter


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 25, 2005 5:42 am 
Offline

Joined: Wed Jul 07, 2004 2:30 pm
Posts: 319
Location: Charlotte, NC
Any plans to make your plugin available? I can think of a few scripts of mine that could use the data it outputs.

_________________
Byron Nash
CG/VFX Generalist
http://www.editatjoes.com
http://www.armoredsquirrel.com


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 25, 2005 3:41 pm 
Offline

Joined: Thu Oct 21, 2004 12:36 am
Posts: 86
Location: Phoenix, AZ
For those brave souls like Byron, I have put this version of the plug-in up at http://www.petertorpey.com/files/ae/TextInfo.aex. Windows only. As mentioned, it is buggy and doesn't work in most instances where I had hoped it would be useful. Try it on a non-text AV Layer for some interesting information (i.e. the width and height of the visible portion of a layer).


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 04, 2006 12:43 pm 
Offline

Joined: Tue Jun 21, 2005 2:08 pm
Posts: 9
any chance of a mac version? or the source, so we can hack one together? This sounds super handy, and poking around in the SDK has been on my to-do list for a while.

The text layer script-ability is one of my bigger disappointments in AE scripting ...

-austin


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 05, 2006 12:19 am 
Offline

Joined: Thu Oct 21, 2004 12:36 am
Posts: 86
Location: Phoenix, AZ
The plug-in is actually deceptively simple and I still find it to be of little practical use. I can provide the source if you (or someone else) would like to build it for a Mac.

I was hoping for improved scripting support for Text Layers in AE7. While there are many other advantages to 7, I think that such support would have motivated me to move on from 6.5.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 07, 2006 5:58 am 
Offline

Joined: Thu Mar 10, 2005 5:50 am
Posts: 114
Location: London, UK
Absolutely.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 10, 2006 10:25 am 
Offline

Joined: Tue Jun 21, 2005 2:08 pm
Posts: 9
well, i solved my immediate problem with a really hacky function, but if that turns out not to work reliably, the plugin (and a real .width result) may be more helpful.

Basically, I'm just trying to make sure that text fits within a specified width, and if not, scale it down.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 12, 2006 3:52 pm 
Offline
Enhancement master
User avatar

Joined: Thu Jun 17, 2004 9:27 am
Posts: 456
Location: New York City, NY
the only solution we've been able to come up with is to write a script that sets the text in illustrator (although that is not bullet proof either) and brings it in to AE which then properly reports it's height and width


Top
 Profile  
 
 Post subject: Another possibility...
PostPosted: Mon Jan 15, 2007 8:38 am 
Offline

Joined: Tue Sep 05, 2006 3:45 am
Posts: 62
Location: Chiswick, London, UK
If there is a way to create a default mask around the text, through script, then the bounding coordinates could be read from that. Unforuntately the automatic mask creation seems to only be available through the UI, am I wrong?

Reading the width and height properties directly return the size of the containing comp (as has already been said). I have also tried precomping the text layer in the hope that it would crop to the bounding area. It doesn't.

I was trying to use vidpats plugin to determine the size of text so I could draw a bounding box (with small border) around it using an expression. While the reported numbers looked right in the Effects panel, the box scaling was random and jumping between about 3 states when it was referenced through the expression and the timeline was scrubbed. Any ideas?

Austin: Do you mind telling us about how your 'hacky' function worked?

Adobe have done a sterling job at making this important information quite impossible to get at! :oops:


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 15, 2007 5:01 pm 
Offline

Joined: Tue Nov 29, 2005 3:00 am
Posts: 201
Location: Paris
Quote:
a way to create a default mask around the text, through script

To my knowledge, no way to get this rectangular default box.

I did a quick jump into the SDK guide a few months ago and found the syntax that returns the width of a text, something like
Code:
myTextWidth = in_data->extent_hint.right - in_data->extent_hint.left;

(the in_data pointer represents the layer)

I suppose vidpat has used something similar in his plugin. But this is based on the visible (alpha) part of the layer, so that it becames useless whenever the layer is outside the comp screen.

You may execute another app from ae in which you can determine 'easily' the text length in pixels (Lloyd has mentionned Illustrator, and I wrote a ae script for this that uses Photoshop..). But of course this solution is not always possible and not very 'clean'.

Anecdotical history: last year I was working on a project for a french national tv involving a lot of 'text management'. I have determined the width of approximately hundred characters and symbols one by one (with the rectangular mask tool and a script)....a real pain. Hopefully they use a single font ! I did it one time and include now this small database in all text-related scripts I write for them. :D


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 15, 2007 5:41 pm 
Offline

Joined: Thu Oct 21, 2004 12:36 am
Posts: 86
Location: Phoenix, AZ
Yes nab, that is essentially what my plug-in does, hence the limitation about text larger than the comp size or off the edge of the comp.

I had thought about writing a plug-in that would get the masks from the text and then find the max and min verts. That might work, but probably would be unduely computationally expensive.


Top
 Profile  
 
 Post subject: Determination
PostPosted: Tue Jan 16, 2007 12:27 am 
Offline

Joined: Tue Sep 05, 2006 3:45 am
Posts: 62
Location: Chiswick, London, UK
Vidpat; your plugin appears to report the right numbers in the effects panel, but isn't reliably read by an expression. Do you have any idea why the values seen by an expression would 'glitch' in the way I have described? I can do a RAM preview and a box drawn by linking to your plugin will flicker.

Is this what you meant when you said it had limited practical use - and do you think this might be a problem intrinsic to approaching this from a plugin angle?

Being mainly a Java programmer I am not too confident with the whole C++/SDK thing, but stand a chance at working with some existing code. Since I really need this functionality, it would be nice to have a look at your source code so far and see if I can try to stabilise the reported value somehow e.g. reject 'zero' and 'comp size' values and latch on any other value.

Failing this I am joining the pixel counting club with nab!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 16, 2007 12:56 am 
Offline

Joined: Thu Oct 21, 2004 12:36 am
Posts: 86
Location: Phoenix, AZ
Darkmoon_UK:
I haven't been doing very much work in AE lately, so I haven't looked at it in a very long time and I had just thrown it together on a whim. I suppose I ought to look at it seriously, at some point. I remember some odd behaviors, like not being able to edit the text reliably with my plug-in enabled. I haven't played around to see why you might be getting the problem you described. Off the top of my head, it sounds like it might be an issue with AE caching values or not reevaluating the expression on every frame because it is not expecting my plug-in to change the parameters (since it's usually the other way about). I might not be updating the parameters in the best place, either.

There are several reasons why it is of limited practical use. My original intent at the time was to animate the text using expressions, but the text layers I had were, by necessity, larger than the comp. Thus, it was useless for that.

Your line, "Adobe have done a sterling job at making this important information quite impossible to get at!" says it all. The real problem here is that the text information is not exposed in the SDK. I think Useful Assistants had a way of getting at this data, but I haven't actually used UA myself. If it did, then it is possible to do in a plug-in. All of the pertinent information about text layers is stored in an opaque datatype. It's probably just a struct, but it's undocumented and I didn't spend the time trying to decipher it. It may be the same structure Photoshop uses, so it may be documented in the PS SDK, which I don't have.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 63 posts ]  Go to page 1, 2, 3, 4, 5  Next

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group