Guest User

YAK (indesign) to RagTime importer

a guest
Apr 23rd, 2012
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. set a to "
  2. "
  3. tell application "RagTime 6"
  4.     activate
  5.    
  6.     set theSelection to (choose file {} with multiple selections allowed)
  7.     set i to 1
  8.     set theAnzahl to number of items in theSelection
  9.    
  10.     open layout 1 of document 1
  11.    
  12.     repeat with i from i to theAnzahl
  13.         set theFile to item i of theSelection as text
  14.         tell application "System Events"
  15.             tell XML element 1 of contents of XML file theFile
  16.                 set vorname to (value of (XML elements whose name is "vorname")) as string
  17.                 set nachname to (value of (XML elements whose name is "name")) as string
  18.                 set geburtstag to (value of (XML elements whose name is "geb")) as string
  19.                 set kommentare to (value of (XML elements whose name is "kommentare")) as string
  20.                 set spitznamen to (value of (XML elements whose name is "stbr1")) as string
  21.                 set leistungsk to (value of (XML elements whose name is "stbr2")) as string
  22.                 set lebensmotto to (value of (XML elements whose name is "stbr3")) as string
  23.                 set hobbies to (value of (XML elements whose name is "stbr4")) as string
  24.                 set ichmag to (value of (XML elements whose name is "stbr5")) as string
  25.                 set ichmagnicht to (value of (XML elements whose name is "stbr6")) as string
  26.                 set unvergesslich to (value of (XML elements whose name is "stbr7")) as string
  27.                 set nachdemabi to (value of (XML elements whose name is "stbr8")) as string
  28.                 set jahreschule to (value of (XML elements whose name is "stbr9")) as string
  29.             end tell
  30.         end tell
  31.        
  32.         if i > 1 then
  33.             make new page at after page (i - 1) of layout 1 of document 1
  34.         end if
  35.         tell document 1
  36.            
  37.             make new text flow at end with properties {name:"Steckbrief_" & i}
  38.             tell text flow ("Steckbrief_" & i)
  39.                 make new paragraph at end with data "Hobbies: " & hobbies
  40.                 make new paragraph at end with data "Ich mag: " & ichmag
  41.                 make new paragraph at end with data "Ich mag nicht: " & ichmagnicht
  42.                 make new paragraph at end with data "Unvergessliche Momente: " & unvergesslich
  43.                 make new paragraph at end with data "Nach dem Abi: " & nachdemabi
  44.                 make new paragraph at end with data "12 Jahre Schule waren: " & jahreschule
  45.                 set font to "EspinosaNova-Regular"
  46.                 repeat with p from 1 to (count paragraphs)
  47.                     repeat with w from 1 to (count characters in paragraph p)
  48.                         set style of character w of paragraph p to bold
  49.                         if (character w of paragraph p as text) = ":" then
  50.                             exit repeat
  51.                         end if
  52.                     end repeat
  53.                 end repeat
  54.             end tell
  55.             set contents of rectangle "SteckbriefL" of page i of layout 1 to text flow ("Steckbrief_" & i)
  56.            
  57.             make new text flow at end with properties {name:"Details_" & i}
  58.             tell text flow ("Details_" & i)
  59.                 make new paragraph at end with data "Spitznamen: " & spitznamen
  60.                 make new paragraph at end with data "Geburtstag: " & geburtstag
  61.                 make new paragraph at end with data "Leistungskurse: " & leistungsk
  62.                 set font to "EspinosaNova-Regular"
  63.                 repeat with p from 1 to (count paragraphs)
  64.                     repeat with w from 1 to (count characters in paragraph p)
  65.                         set style of character w of paragraph p to bold
  66.                         if (character w of paragraph p as text) = ":" then
  67.                             exit repeat
  68.                         end if
  69.                     end repeat
  70.                 end repeat
  71.             end tell
  72.             set contents of rectangle "Details" of page i of layout 1 to text flow ("Details_" & i)
  73.            
  74.             make new text flow at end with properties {name:"Kommentare_" & i}
  75.             tell text flow ("Kommentare_" & i)
  76.                 make new paragraph at end with data "Kommentare der Stufe: " & kommentare
  77.                 set font to "EspinosaNova-Regular"
  78.                 repeat with p from 1 to (count paragraphs)
  79.                     repeat with w from 1 to (count characters in paragraph p)
  80.                         set style of character w of paragraph p to bold
  81.                         if (character w of paragraph p as text) = ":" then
  82.                             exit repeat
  83.                         end if
  84.                     end repeat
  85.                 end repeat
  86.             end tell
  87.             set contents of rectangle "Kommentare" of page i of layout 1 to text flow ("Kommentare_" & i)
  88.            
  89.             make new text flow at end with properties {name:"Name_" & i}
  90.             tell text flow ("Name_" & i)
  91.                 make new paragraph at end with data vorname & " " & nachname
  92.                 set font to "EspinosaNova-Regular"
  93.                 set style of paragraph 1 to bold
  94.                 set size of paragraph 1 to 24
  95.             end tell
  96.             set contents of rectangle "Name" of page i of layout 1 to text flow ("Name_" & i)
  97.            
  98.            
  99.         end tell
  100.        
  101.         set contents of rectangle "Bild" of page i of layout 1 of document 1 to file ":Users:User_01:Desktop:dummyPic.jpeg"
  102.        
  103.     end repeat
  104. end tell
Advertisement
Add Comment
Please, Sign In to add comment