Hallo Hans,
habe jetzt noch den Bildimport dazugenommen, es muss halt noch etwas verfeinert werden ist aber auch so schon ganz brauchbar. Habe bei der Gelegenheit mal, Fischer sei dank, den von Ihm stammenden CodeFormatter angeschmissen.
tell document 1 of application "Adobe InDesign CS2"
activate
set thisStory to index of every story whose name of applied paragraph style of paragraph 1 is "BTitel"
tell story thisStory
tell (every paragraph whose name of applied paragraph style is "Petit")
set CountLegends to count of (every paragraph whose word 1 is "Figure")
end tell
end tell
end tell
CreateFrames(CountLegends, thisStory)
on CreateFrames(CountLegends, thisStory)
set ItemNum to 1
repeat CountLegends times
tell document 1 of application "Adobe InDesign CS2"
activate
make page
set Seitenzahl to name of last page
if side of page Seitenzahl is left hand then
set theBounds to {"29 mm", "28.5 mm", "59 mm", "193 mm"}
else
set theBounds to {"29 mm", "227 mm", "59 mm", "391.5 mm"}
end if
tell page Seitenzahl
set Bildlegende to make text frame
tell Bildlegende
set geometric bounds to theBounds
set label to "Bildlegende_" & ItemNum
my MoveLegend(thisStory, Bildlegende)
search for return replacing with ""
fit given frame to content
--set LegNum to LegNum + 1--umgestellt
end tell
end tell
--set ItemNum to LegNum - 1
my BildImport(Seitenzahl, theBounds, ItemNum)
my AlignItems(ItemNum)
set ItemNum to ItemNum + 1
end tell
end repeat
end CreateFrames
on MoveLegend(thisStory, Bildlegende)
tell document 1 of application "Adobe InDesign CS2"
tell story thisStory
tell (every paragraph whose name of applied paragraph style is "Petit")
move (paragraph 1 whose word 1 is "Figure") to after insertion point 1 of Bildlegende
end tell
end tell
end tell
end MoveLegend
on BildImport(Seitenzahl, theBounds, ItemNum)
tell document 1 of application "Adobe InDesign CS2"
activate
set noneID to (id of every swatch whose name is "none")
set noColor to swatch id noneID
--set BilderPfad to (file path as Unicode text)
set BilderPfad to (file path as Unicode text) & "Abbildungen"
set ListFigs to list folder BilderPfad without invisibles
set curFile to item ItemNum of ListFigs
set InsertFig to BilderPfad & ":" & curFile
if curFile ends with ".tif" then
set curFile to text 4 thru -5 of curFile
end if
tell page Seitenzahl
set Bildrahmen to make rectangle
tell Bildrahmen
set geometric bounds to theBounds
set stroke color to noColor
set fill color to noColor
set label to "Rahmen_" & ItemNum
end tell
end tell
place alias InsertFig on page item ("Rahmen_" & ItemNum)
tell page item ("Rahmen_" & ItemNum)
fit given frame to content
end tell
end tell
end BildImport
on AlignItems(ItemNum)
tell document 1 of application "Adobe InDesign CS2"
activate
tell page item ("Rahmen_" & ItemNum) --"Rahmen_003"
set BoundsWidth to (item 4 of geometric bounds) - (item 2 of geometric bounds)
if BoundsWidth < 80.5 then
set Einspaltig to 1
else
set Einspaltig to 0
set NewWidth to (item 2 of geometric bounds) + 164.5
set geometric bounds to {item 1 of geometric bounds, item 2 of geometric bounds, item 3 of geometric bounds, NewWidth}
fit given center content
end if
set BoundsHeight to (item 3 of geometric bounds) - (item 1 of geometric bounds) + 2.5
end tell
tell page item ("Bildlegende_" & ItemNum)
if Einspaltig = 1 then
set NewWidth to (item 2 of geometric bounds) + 80
set geometric bounds to {item 1 of geometric bounds, item 2 of geometric bounds, item 3 of geometric bounds, NewWidth}
fit given frame to content
end if
set NewTop to (item 1 of geometric bounds) + BoundsHeight
set NewBottom to (item 3 of geometric bounds) + BoundsHeight
set geometric bounds to {NewTop, item 2 of geometric bounds, NewBottom, item 4 of geometric bounds}
end tell
end tell
end AlignItems
Hans, vielleicht fällt Dir ja noch ein schlimmer lapsus auf...
Es fehlt jetzt auch noch die Gruppierung von Bild und Legende, ist das zu bewerkstelligen?
Gruß
Jürgen
als Antwort auf: [#421204]