InDesign - Outline text, Move, Layers question please

Hello!

I need this script to do the following things please:

  1. Make a new layer called “Live Copy”

  2. Create outlines of all text in frames

  3. Create outlines of all text on paths

  4. Move all non-outlined live copy on a path or in a frame to the “Live Copy” layer

  5. Hide the “Live Copy” layer

When I run what I presently have, my live text frames move to the new layer without being outlined, and my text paths do not outline and do not move. I need outlined text on one layer and live text on another.

Any ideas? Thanks!
-Clobberella


tell application "Adobe InDesign CS2"
	tell document 1
		
		--make new layer for live text
		set Text_Layer to make layer
		try
			set name of Text_Layer to "live copy"
		on error
			--name already exists
		end try
		
		
		--ungroup all items
		try
			set grouped_items to every group
			repeat with ungroup_repeater from 1 to count grouped_items
				ungroup grouped_items
			end repeat
		on error
			--no grouped items found
		end try
		
		
		
		--create outlines of text frames
		try
			set parent_text_frames to parent text frames of insertion point 1 of every story
			repeat with repeater from 1 to count parent_text_frames
				create outlines item 1 of item repeater of parent_text_frames without delete original
			end repeat
			
		end try
		
		
		
		
		--create outlines of text on paths
		try
			set text_outlines to every text path of every page item of document 1
			repeat with textoutlines_repeater in text_outlines
				create outlines of (every text of text_outlines) without delete original
			end repeat
		on error
			-- no path items found
		end try
		
		
		
		
		-- move all text frames to new layer
		try
			set text_frames to every text frame
			repeat with textframe_repeater from 1 to count text_frames
				move text_frames to layer "live copy"
			end repeat
			
		end try
		
		try
			set text_paths to every text path
			repeat with text_path_repeater from 1 to count text_paths
				move text_paths to layer "live copy"
			end repeat
		end try
		
		
		--Hide "Live Copy" layer
		set visible of Text_Layer to false
		
		
		
	end tell
end tell


Hi Clobberella

Based around your original script I ended up with the below for you, hope this helps.

tell application "Adobe InDesign CS3"
	set Text_Layer to "live copy"
	tell document 1
		try
			set myLayer to layer Text_Layer
			set the properties of myLayer to {locked:false}
		on error
			set myLayer to make layer with properties {name:Text_Layer, layer color:red, visible:true}
		end try
		
		--ungroup all items
		try
			set grouped_items to every group
			repeat with ungroup_repeater from 1 to count grouped_items
				ungroup grouped_items
			end repeat
		on error
			--no grouped items found
		end try
		
		--create outlines of text frames
		tell application "Adobe InDesign CS3"
			tell document 1
				set _Outline to every text frame of it
				create outlines of _Outline without delete original
			end tell
		end tell
		
		--create outlines of text on paths
		tell application "Adobe InDesign CS3"
			tell document 1
				set _PathOutline to every text path of every page item of it
				repeat with _Outline in _PathOutline
					create outlines of (every text of _Outline) without delete original
				end repeat
			end tell
		end tell
		
		-- move all text frames to new layer
		try
			set text_frames to every text frame
			repeat with textframe_repeater from 1 to count text_frames
				move text_frames to layer "live copy"
			end repeat
		end try
		try
			set text_paths to every text path
			repeat with text_path_repeater from 1 to count text_paths
				move text_paths to layer "live copy"
			end repeat
		end try
		
		--Hide "Live Copy" layer
		set visible of layer Text_Layer to false
	end tell
end tell

Budgie

Hi Budgie,

I am getting this error at “–create outlines of text on paths”:

Adobe InDesign CS3 got an error: Can’t get every text path of every page item of document 1.

Another thing I think is kind of weird about this, is Mister Friendly recently shared this gem with me (thank you Mister Friendly) and it works great:

tell application “Adobe InDesign CS2”
tell document 1
set myOutlines to every text path of every page item of it
repeat with outlineMe in myOutlines
create outlines of (every text of outlineMe) without delete original
end repeat
end tell
end tell

That is basically what I have in my big script except that I changed the names of the variables. Now the script is getting hung up there. Maybe my problem is a conflict between text Frames and text Paths ? Maybe I’m not calling them out correctly?

I noticed that you used “Adobe InDesign CS2” in your origional script, I used “Adobe InDesign CS3”, maybe this is the problem, in saying that though the creation of outlines from text on paths and from text from text box’s works fine here in CS3.

Budgie

Actually I’m running both CS2 and CS3 (version 5.0.3). I was trying it in both to see if I could get it to work. When I tried CS3 I still got the same error “Adobe InDesign CS3 got an error: Can’t get every text path of every page item of document 1.”

hmm, ok I create a new doc, add say three text boxs with text in them, create say an oval then add text to it’s path, group the whole lot and run the script. result, everything is ungrouped, all text in boxs and on path is outlined, all live copy text is on live copy layer, oops, apart from
the path’s origional text, minor issue though. not quite sure whats not going right for you. :confused:

Budgie

While you are developing this, it would be helpful for you to disable the instances of “try”; they are keeping you from seeing useful errors in the event log. I don’t have access to InDesign, at the moment, but I think the “create outlines of text frames” and “create outlines of text paths” segments are incompatible, as ordered; you should try flip-flopping them, and see if that gets around the error you are receiving.

A few of the repeat loops (in the original code) were repeating with an iterator using your variable’s whole list, rather than an item within that list, and some of those operations didn’t require repetition. The ungroup segment is an example, and it can be improved:

ungroup groups

Budgie and Marc Anthony, thanks for your help so far. I’ve done some tweaking and this is what I have now, which is still not correct:


tell application "Adobe InDesign CS2"
	tell document 1
		set myLayer to make layer with properties {name:"Live Copy"}
		
		
		--ungroup all items
		ungroup groups
		
		
		--create outlines of text on paths
		tell application "Adobe InDesign CS2"
			tell document 1
				set _PathOutline to every text path of every page item of it
				repeat with _Outline in _PathOutline
					create outlines of (every text of _Outline) without delete original
				end repeat
			end tell
		end tell
		
		--move all text paths to "Live Copy" layer
		tell application "Adobe InDesign CS2"
			tell document 1
				set text_paths to every text path of every page item of it
				move text_paths to layer "Live Copy"
			end tell
		end tell
		
		
		--create outlines of text frames
		tell application "Adobe InDesign CS2"
			tell document 1
				set _Outline to every text frame of it
				create outlines of _Outline without delete original
			end tell
		end tell
		
		
		-- move all text frames to "Live Copy" layer
		tell application "Adobe InDesign CS2"
			tell document 1
				set text_frames to every text frame
				repeat with textframe_repeater from 1 to count text_frames
					move text_frames to layer "Live Copy"
				end repeat
			end tell
		end tell
		
		
		--Hide "Live Copy" layer
		set visible of layer "Live Copy" to false
	end tell
end tell

I’ve got my snag area narrowed down to "move text_paths to layer “Live Copy” "

Which produces this error: {text path id 211 of polygon id 192 of page id 178 of spread id 173 of document “Untitled.indd”} doesn’t understand the move message.

Any ideas please on how to improve my “move” -ment? Ha.

Thank you!

ok, I think I see the problem, your attempting to move the text on a path (which is sort of correct), in fact you should be trying to move the object the text is attached to, meaning if it’s a polygon, move the polygon, if it’s a rectangle move the rectangle etc etc,( not sure if that’s to good an explanation or not) the script below works based on the info given from error: :slight_smile:

“Which produces this error: {text path id 211 of polygon id 192 of page id 178 of spread id 173 of document “Untitled.indd”} doesn’t understand the move message.”

tell application "Adobe InDesign CS3"
	tell document 1
		set myLayer to make layer with properties {name:"Live Copy"}
		ungroup groups
		------------------------------------------
		--TEXT PATH--
		tell application "Adobe InDesign CS3"
			tell document 1
				set _PathOutline to every text path of every page item of it
				repeat with _Outline in _PathOutline
					create outlines of (every text of _Outline) without delete original
				end repeat
				set properties of every polygon to {item layer:myLayer} -- text is on a polygon not in a text frame.
			end tell
		end tell
		-------------------------------------------
		--TEXT FRAME--
		tell application "Adobe InDesign CS3"
			tell document 1
				set _Outline to every text frame of it
				create outlines of _Outline without delete original
				set text_frames to every text frame
				repeat with textframe_repeater from 1 to count text_frames
					move text_frames to layer "Live Copy"
				end repeat
			end tell
		end tell
		------------------------------------------
		--Hide "Live Copy" layer
		set visible of layer "Live Copy" to false
	end tell
end tell

Budgie

Hi, Clobberella. The explanation for your error is that text paths are these semi-real things that rely on their parents”polygons, ellipses, etc.”to exist. I think they’re immovable, at least directly.

It’s a minor beef, but your current code grew a little more verbose than in your previous try; you don’t need the multiple calls to InDesign and its document, as everything within the first tell block is rightly going to the same place.

	
--© 2008, Marc Anthony. All rights reserved.
-------------------------------------------------------------

tell application "InDesign CS"'s document 1
	--UNGROUP
	ungroup groups
	
	--DEFINE, path type
	try
		set pathObjectType to page items's text paths's parent
	on error
		set pathObjectType to {}
	end try
	
	--DEFINE, standard type
	try
		set standardTextType to text frames
	on error
		set standardTextType to {}
	end try
	
	--MAKE LAYER
	set newLayer to make layer
	
	--CREATE OUTLINES
	create outlines stories without delete original
	
	--MOVE
	if not pathObjectType = {} then move pathObjectType to newLayer
	if not standardTextType = {} then move standardTextType to newLayer
	
	--HIDE
	set newLayer's visible to false
	
	end

Sorry, Budgie. I didn’t mean to repeat parts of your answer, but it looks like you got in there while I was still typing.
http://bbs.macscripter.net/edit.php?id=102366#

no worries Marc, much better explanation than mine, cheers :smiley:

Budgie

Hi

Not sure if this is relevant or helps much but i believe its possible to get.
both text frames and text paths even in groups at the same time with this:

tell application "Adobe InDesign CS3"
	tell document 1
		create outlines of every story
	end tell
end tell

sorry for butting in if this is unhelpful.

[u]Victory!![/u]

Ok, first off, THANK YOU Budgie and Marc Anthony! It ended up being so cool that you both posted so close to each other because each of you had a critical piece of the puzzle I needed. Here is what the final script looks like:


-- This is mostly Budgie's script:

tell application "Adobe InDesign CS2"
	tell document 1
		set myLayer to make layer with properties {name:"Live Copy"}
		ungroup groups
		------------------------------------------
		--TEXT PATH--
		tell application "Adobe InDesign CS2"
			tell document 1
				set _PathOutline to every text path of every page item of it
				repeat with _Outline in _PathOutline
					create outlines of (every text of _Outline) without delete original
				end repeat
				set text_path_object to page items's text paths's parent
				move text_path_object to layer "Live Copy"
			end tell
		end tell
		-------------------------------------------
		--TEXT FRAME--
		tell application "Adobe InDesign CS2"
			tell document 1
				set _Outline to every text frame of it
				create outlines of _Outline without delete original
				set text_frames to every text frame
				repeat with textframe_repeater from 1 to count text_frames
					move text_frames to layer "Live Copy"
				end repeat
			end tell
		end tell
		------------------------------------------
		--Hide "Live Copy" layer
		set visible of layer "Live Copy" to false
	end tell
end tell



This part comes from Marc Anthony. Without it, both the text on the path AND the outlined text went to the “Live Copy” layer. That’s because once the type was outlined, it also became polygons.

And Pidge thanks for that great suggestion. I am using on another project. :slight_smile:

The boss was just looking over my shoulder. She says to tell you all we made her VERY happy. :cool:

sweet, glad you got it sorted, a happy boss is a good boss :wink:

Budgie