Pages, Shapes and attributes.

Not a question, but a tip.

From time to time I read questions about the way to change attributes to specific shapes in a Pages document.

I wrote two short scripts to do that.

The first one gives the wanted name to a selected shape.
Apply it to every shapes to which you will have to apply specific new identical attributes from time to time.

--[SCRIPT nameOneShape]
(* select a shape in Pages
then run the script.
It will give it the name defined in the property theName

Yvan KOENIG (Vallauris, FRANCE)
9 octobre 2008
*)
property theName : "old Airport Station" -- define the wanted name here
try
	tell application "Pages" to tell document 1
		set propsOfSel to item 1 of (get properties of the selection)
		set listeProps to (get properties of every shape)
		
		repeat with i from 1 to count of listeProps
			if item i of listeProps is propsOfSel then set name of shape i to theName
		end repeat
	end tell
on error
	error "You must select a shape in a Pages document !" number 8001
end try
--[/SCRIPT]

The second one apply the new attributes to every shapes of a document whose name matches the embedded one.

--[SCRIPT changeShapesAttributes]
(* apply new properties to every shapes of a Pages document whose Name is theName

Yvan KOENIG (Vallauris, FRANCE)
9 octobre 2008
*)
property theName : "old Airport Station"
tell application "Pages" to tell document 1
	set listeProps to (get properties of every shape)
	set myShapes to {}
	repeat with i from 1 to count of listeProps
		if name of item i of listeProps is theName then
			tell shape i -- define the new attributes here
				set stroke width to 2
				set stroke color to {3, 3, 3}
				set single color to {65535, 59624, 52171} (* fill with it *)
			end tell
		end if
	end repeat
end tell
--[/SCRIPT]

I hope that it will help some of you.

Yvan KOENIG (from FRANCE jeudi 9 octobre 2008 17:11:06)