Guten Abend, ich habe heute im Adobe Forum ein Script zur automatischen Bildpositionierung in InDesign gefunden. Auf einem Standard Dokument (DIN A4) werden alle Bilder aus einem Ordner positioniert; incl Bildunterschrift. Ich habe das Script für meine Bedürfnisse verändert; Dialog zur Anzahl der Spalten und Zeilen eingebaut. Vielleicht kann es ja jemand gebrauchen.
--InDesign CS--PlaceImagesOfFolderWithFileName --This script attempts to place all files found in a specified folder and adds a label --to each frame containing the full file path to the file. --Tested with JPG and TIFF. (doesn't with e.g. PDF yet.) --If you don't want to remove empty frames, set myRemoveEmptyFrames to false.
--Edit document and text preferences in ID before running the script with no open document
--Edit Text formatting
--BUG: does not create additional pages yet global X, y
set X to display dialog "Wieviel Spalten soll das Dokument haben?" default answer 1 buttons {"OK"} default button 1 set y to display dialog "Wieviel Zeilen soll das Dokument haben?" default answer 1 buttons {"OK"} default button 1 set myNumberOfColumns to text returned of X as number set myNumberOfRows to text returned of y as number set myRemoveEmptyFrames to true -- ••• H E I G H T OF T E X T F R A M E ••••••••••••••••••••••••••••••••••••••••• --myOffset defines the height of the text frame for the labels. set myOffset to 18 set myFramesPerPage to (myNumberOfRows * myNumberOfColumns) --Display a "Choose Folder" dialog box. set myFolder to choose folder with prompt "Bitte den Ordner mit Bildern auswählen, die platziert werden sollen." tell application "Finder" set myNumberOfFrames to (count files in folder myFolder) set myFiles to files of myFolder end tell tell application "InDesign CS" set myDocument to make document --Set the measurement units to points if they're not already set to points. set myViewPreferences to «class vwpp» of myDocument if «class hunt» of myViewPreferences is not «class zpoi» then set myOldXUnits to «class hunt» of myViewPreferences set myResetXUnits to true set «class hunt» of myViewPreferences to «class zpoi» else set myResetXUnits to false end if if «class vunt» of myViewPreferences is not «class zpoi» then set myOldYUnits to «class hunt» of myViewPreferences set myResetYUnits to true set «class vunt» of myViewPreferences to «class zpoi» else set myResetYUnits to false end if -- ••• T E X T F O R M A T T I N G •••••••••••••••••••••••••••••••••••••••• --Create a paragraph style for the label set myParagraphStyle to make «class psty» with properties {name:"label", size:7} set myDocumentPreferences to «class dcpp» of myDocument set myNumberOfPages to round (myNumberOfFrames / myFramesPerPage) rounding «constant FSttFstn» -- ••• A M O U N T O F P A G E S •••••••••••••••••••••••••••••••••••••••• -- [ commented by ot on 18october04 -- set pages per spread of myDocumentPreferences to 1 tell «class dcpp» of myDocument set «class ppsd» to false set «class nump» to (myNumberOfPages + 1) end tell -- commented by ot on 18october04 ] set myMarginPreferences to «class impp» of «class page» 1 of myDocument set myLeftMargin to «class marl» of myMarginPreferences set myRightMargin to «class marr» of myMarginPreferences set myTopMargin to «class mart» of myMarginPreferences set myBottomMargin to «class marb» of myMarginPreferences set myLiveWidth to («class pwdt» of myDocumentPreferences) - (myLeftMargin + myRightMargin) set myLiveHeight to («class phgt» of myDocumentPreferences) - (myTopMargin + myBottomMargin) set myFrameWidth to (myLiveWidth / myNumberOfColumns) set myFrameHeight to (myLiveHeight / myNumberOfRows) set myPages to every «class page» of myDocument repeat with myCounter from (count myPages) to 1 by -1 set myPage to item myCounter of myPages repeat with myRowCounter from myNumberOfRows to 1 by -1 set myY1 to myTopMargin + (myFrameHeight * (myRowCounter - 1)) set myY2 to myTopMargin + (myFrameHeight * myRowCounter) repeat with myColumnCounter from myNumberOfColumns to 1 by -1 set myX1 to myLeftMargin + (myFrameWidth * (myColumnCounter - 1)) set myX2 to myLeftMargin + (myFrameWidth * myColumnCounter) tell myPage to make «class crec» with properties {«class gbnd»:{myY1, myX1, myY2 - myOffset, myX2}} tell myPage to make «class txtf» with properties {«class gbnd»:{myY2 - myOffset, myX1, myY2, myX2}} end repeat end repeat end repeat repeat with myCounter from 1 to myNumberOfFrames set myFileName to item myCounter of myFiles as string «event CoRedoex» myDocument «event CoRedoex» «class crec» myCounter of myDocument set myRectangle to «class crec» myCounter of myDocument tell myRectangle «event InESplac» myFileName given «class insh»e end tell --Position/fit the graphic in the frame. «event InESfitc» myRectangle given «class givn»:«constant fitoctof» «event InESfitc» myRectangle given «class givn»:«constant fitoconp» «event InESfitc» myRectangle given «class givn»:«constant fitocenc» --Add the file name to the text frame. tell «class txtf» myCounter of myDocument set contents to (myFileName as string) set «class prst» of paragraph 1 to «class psty» "label" of myDocument end tell end repeat --Do cleanup, if necessary. if myRemoveEmptyFrames is true then tell myDocument tell (every «class crec» whose «class cntt» is «constant cntyunas») to «event CoRedelo» tell (every «class txtf» whose contents is "") to «event CoRedelo» end tell end if --Reset the measurement units, if necessary. if myResetXUnits is true then set «class hunt» of myViewPreferences to myOldXUnits end if if myResetYUnits is true then set «class vunt» of myViewPreferences to myOldYUnits end if display dialog "Fertig." buttons "OK" default button 1 with icon 1 giving up after 5 end tell
Uwe Beutler-Bußmann
Automatische Bildpositionierung in InDesign per AS
Hallo Hans, das Script läuft aber reibugslos durch. Aber meiner Meinung nach ist Scripting für InDesign nicht so einfach zu beherschen wie für XPress; oder täusche ich mich da?
Uwe
Automatische Bildpositionierung in InDesign per AS
ich glaube gerne, dass das Script funktioniert. Aber das Editieren und Verstehen des Codes ist sehr erschwert. Es sieht aus, als ob das Script aus einer früheren Version stamme und beim Öffnen mit CS die Begriffe nicht richtig umgesetzt wurden. Ähnliches passiert auch mit XPress, aber nie in diesem Ausmass.
Es stimmt, dass Scripting für InDesign schwieriger ist, als für QuarkXPress. Schon allein das gewaltige Wörterbuch macht die Sache nicht einfacher. Aber dafür ist es vielseitiger. Und Dinge, welche mit XPress nur mit akrobatischen Workarounds oder überhaupt nicht möglich sind, seien mit InDesign kein Problem.
Das "seien" ist kein Tippfehler, denn bisher habe ich mich aus Zeitmangel nur am Rande mit InDesign-Scripts befasst.
Hans Haesler <hsa@ringier.ch>
Automatische Bildpositionierung in InDesign per AS
ich habe mir jetzt die Zeit genommen und das Script näher angeschaut. InDesign CS und Script Editor gestartet und den von Dir geposteten Code eingesetzt. Syntax prüfen: Da wird reklamiert, dass das Ende der Zeile erwartet, aber ein Doppelpunkt gefunden wurde. Es betrifft drei Zeilen, von welchen hier die erste kommt: In jeder Zeile habe ich das '«class givn»:' entfernt. Und erneutes Prüfen der Syntax. Diesmal ist die Zeile … … hervorgehoben. Die Meldung sagt: "Can't set «class ppsd» to false. Access not allowed." Ich kommentiere die Zeile für den Moment aus. Bei der nächsten Prüfung kommt eine gleiche Meldung bei: Wieder auskommentieren und nochmals prüfen. Diesmal klappt es. Und beim Kompilieren werden sämtliche Raw-Codes in lesbare Konstanten umgewandelt. Bis auf die beiden, welche ich auskommentiert hatte. Kurzes Stöbern im Wörterbuch. Ohne fündig zu werden. Dann hatte ich eine Idee (kommt ab und zu vor :-) und tippte ein kleines Script: --- tell application "InDesign CS" set myDocument to make document tell document preferences of myDocument «class ppsd» end tell end tell --- Beim Prüfen der Syntax wird '«class ppsd»' in 'facing pages' verwandelt. Ha! Wenn dies so einfach geht: Auch den Code '«class nump»' eingetippt. Dieser wird zu 'pages per document'. Die beiden Konstanten eingesetzt, das Aus- kommentieren aufgehoben und nun konnte ich das Script ausführen. Und es funktioniert …
Hans Haesler <hsa@ringier.ch>
Automatische Bildpositionierung in InDesign per AS
Hallo Hans, ich muß mich Entschuldigen, das ich ein fehlerhaftes Script reingestellt habe. Nachdem ich das Script mit dem in der Firma verglichen habe, mußte ich fesstellen, das einige Passagen falsch sind. Irgendwas ist passiert beim senden des Scripts zu mir nach Hause und dann beim reinstellen ins Forum. Ich werde dir mal das Orginalscript zusenden.
Uwe
Automatische Bildpositionierung in InDesign per AS
kein Problem. Kann mal passieren. Ich nehme an, dass das Script ungeschützt an ein E-mail gehängt wurde und dann als Textdokument geöffnet werden konnte. Deshalb die vielen nicht übersetzten Raw-Codes.
Ja, das Originalscript funktioniert problemlos. Danke.