Delete Empty Text Blocks

Steve Mills smills at multi-ad.com
Fri Apr 11 16:05:36 CDT 2008


On Apr 11, 2008, at 15:49:43, Zach Manring wrote:

> tell application "MultiAd Creator Pro"
>    set textcount to number of text flow of document 1
>    repeat with i from 1 to textcount
>        select text flow i of document 1
>        set ztextcount to count every character of text flow i of  
> document 1
>        if ztextcount < 1 then
>            select text flow i of document 1
>
> -- after its selected then I don't how to select it as an element,  
> if I use
> it as "I" then it deletes the wrong element.
>
> delete
>        end if
>    end repeat
> end tell


A text flow is the object that holds and flows the text. Selecting a  
text flow simply selects its text. The text is flowed through text  
blocks (or text paths, both of which are subclasses of text  
container). Text blocks/paths are owned by shapes. If you know the  
flow only flows through 1 block/shape, then you can use text flow's  
owner shape property to easily get the shape. If not, then you'll have  
to walk the list of text containers and get each text container's  
owner shape.

You're going to run into  problem though when you delete objects that  
you're iterating through. If you delete object 2, then object 3  
becomes object 2, and object 4 becomes object 3, so in the next  
iteration, i is incremented from 2 to 3, you'll skip what was object 3  
and is now object 2. If objects will be deleted in a loop, you either  
need to loop backwards (which should prevent most indices from  
changing) or build a list of objects to delete, then delete them in a  
separate loop outside of the current loop.

_________________________________________________________
Steve Mills                              Me: 952-401-6255
Senior Software Architect                         MultiAd
smills at multiad.com                       www.multi-ad.com




More information about the Creator mailing list