[GastForen Programmierung/Entwicklung AppleScript Indesign Skript Rahmeninhalt skalieren/verschieben

  • Suche
  • Hilfe
  • Lesezeichen
  • Benutzerliste
Themen
Beiträge
Moderatoren
Letzter Beitrag

Indesign Skript Rahmeninhalt skalieren/verschieben

Anonym
Beiträge gesamt: 22827

25. Mär 2007, 09:48
Beitrag # 1 von 29
Bewertung:
(6617 mal gelesen)
URL zum Beitrag
Beitrag als Lesezeichen
Guten Tag,

mir liegt ein Apple-Skript vor, mit dem ich in InDesign den Rahmeninhalt skalieren bzw. verschieben kann.

Mein Problem ist es, daß alle Bildrahmen erst markiert werden müssen. Ist es möglich, das Skript so zu ändern, daß alle Bildrahmen automatisch erkannt und bearbeitet werden können?

Bei 4800 Bildern im Dokument doch sehr mühselig.

Das Skript:






tell application "Adobe InDesign CS2"

-- Initialisierung
set aSel to selection
if aSel = {} then
return
end if

set myDialog to make dialog with properties {name:"Einzeln Transformieren"}
tell myDialog
make dialog column
tell the result
set moveThisGroup to make enabling group with properties {static label:"Verschieben", checked state:true}
tell moveThisGroup
make dialog column
tell the result
make static text with properties {static label:"X:"}
make static text with properties {static label:"Y:"}
end tell
make dialog column
tell the result
set moveXField to make real editbox with properties {edit value:0}
set moveYField to make real editbox with properties {edit value:0}
end tell
end tell
set scaleThisGroup to make enabling group with properties {static label:"Skalieren", checked state:true}
tell scaleThisGroup
make dialog column
tell the result
make static text with properties {static label:"X:"}
make static text with properties {static label:"Y:"}
end tell
make dialog column
tell the result
set scaleXField to make real editbox with properties {edit value:100}
set scaleYField to make real editbox with properties {edit value:100}
end tell
end tell
set rotateThisGroup to make enabling group with properties {static label:"Rotieren", checked state:true}
tell rotateThisGroup
make dialog column
tell the result
make static text with properties {static label:"Winkel:"}
end tell
make dialog column
tell the result
set rotateAField to make real editbox with properties {edit value:0}
end tell
end tell
end tell
end tell
set nu to show myDialog
if nu is true then
set moveThis to checked state of moveThisGroup
set scaleThis to checked state of scaleThisGroup
set rotateThis to checked state of rotateThisGroup
set moveX to edit value of moveXField
set moveY to edit value of moveYField
set scaleX to edit value of scaleXField
set scaleY to edit value of scaleYField
set rotateA to edit value of rotateAField
else
destroy myDialog
return
end if



repeat with aThing in aSel
tell aThing
if moveThis then
set t to item 1 of geometric bounds
set l to item 2 of geometric bounds
set b to item 3 of geometric bounds
set r to item 4 of geometric bounds
set geometric bounds to {t + moveY, l + moveX, b + moveY, r + moveX}
end if
if scaleThis then
set absolute horizontal scale to absolute horizontal scale * scaleX / 100
set absolute vertical scale to absolute vertical scale * scaleY / 100
end if
if rotateThis then
set absolute rotation angle to absolute rotation angle + rotateA
end if
end tell
end repeat
end tell



Danke und liebe Grüße,

Thor
X

Indesign Skript Rahmeninhalt skalieren/verschieben

Hans Haesler
  
Beiträge gesamt: 5826

25. Mär 2007, 18:37
Beitrag # 2 von 29
Beitrag ID: #421573
Bewertung:
(6613 mal gelesen)
URL zum Beitrag
Beitrag als Lesezeichen
Hallo Thor,

herzlich willkommen im Page-Forum! :-)

Ja, es ist möglich, das Script Deinen Vorgaben anzupassen. Das heisst,
am besten schreibt man ein neues ...

Bevor ich mich an die Arbeit mache, eine Frage: Warum benutzest Du nicht
das JavaScript "ScaleEveryImage.jsx", welches Martin im HDS-Forum speziell
für Dich erweitert hat?

Gruss, Hans


als Antwort auf: [#421572]

Indesign Skript Rahmeninhalt skalieren/verschieben

Anonym
Beiträge gesamt: 22827

25. Mär 2007, 18:52
Beitrag # 3 von 29
Beitrag ID: #421574
Bewertung:
(6613 mal gelesen)
URL zum Beitrag
Beitrag als Lesezeichen
Hallo Hans,

aus dem Grund, weil das Skript den kompletten Rahmen und nicht nur den Rahmeninhalt skaliert.

Gruß Thor


als Antwort auf: [#421572]

Indesign Skript Rahmeninhalt skalieren/verschieben

Hans Haesler
  
Beiträge gesamt: 5826

25. Mär 2007, 19:35
Beitrag # 4 von 29
Beitrag ID: #421575
Bewertung:
(6613 mal gelesen)
URL zum Beitrag
Beitrag als Lesezeichen
Hallo Thor,

dann lasse doch einfach die letzte Zeile weg:
Code
// ScaleEveryImage.jsx   
// 
var myScale = prompt("Skalierungsfaktor", 0.5); // Skalierungsfaktor
var myPics = app.documents[0].allGraphics; 
for (onePic = 0; onePic < myPics.length; onePic++){
  myPics[onePic].horizontalScale = myPics[onePic].horizontalScale * myScale;
  myPics[onePic].verticalScale = myPics[onePic].verticalScale * myScale;
}

Okay?

Gruss, Hans


als Antwort auf: [#421572]

Indesign Skript Rahmeninhalt skalieren/verschieben

Anonym
Beiträge gesamt: 22827

25. Mär 2007, 20:38
Beitrag # 5 von 29
Beitrag ID: #421576
Bewertung:
(6613 mal gelesen)
URL zum Beitrag
Beitrag als Lesezeichen
Hallo Hans,

ich habe mal 3 Bilder geladen, die das Problem vielleicht ersichtlich machen:

http://www.punkerchen.de/Fotos/

Bild 1 ist das Original

Bild 2 meine gewünschten Parameter

Bild 3 Ergebnis

Ich bin da wohl etwas blauäugig - habe gedacht, das vorhandene Skript wäre schnell zu ändern um alle Bildinhalte automatisch zu markieren.

Sorry, ich bin da absoluter Laie.

Gruß Thor


als Antwort auf: [#421572]

Indesign Skript Rahmeninhalt skalieren/verschieben

Hans Haesler
  
Beiträge gesamt: 5826

25. Mär 2007, 21:08
Beitrag # 6 von 29
Beitrag ID: #421577
Bewertung:
(6613 mal gelesen)
URL zum Beitrag
Beitrag als Lesezeichen
Hallo Thor,

okay. Schalten wir um auf AppleScript. Das folgende Script weist allen Bildern des
Dokuments eine Skalierung von 125% zu und verschiebt sie um 7 mm nach unten.
Es muss nichts ausgewählt werden.

--AlleBilderSkalieren.scpt
set scaleVal to 125
set offVal to 7
tell document 1 of application "Adobe InDesign CS2"
   activate
   set allImgs to all graphics
   repeat with i from 1 to count of allImgs
      tell item i of allImgs
         set properties to {horizontal scale:scaleVal, vertical scale:scaleVal}
         set {y1, x1, y2, x2} to geometric bounds
         set geometric bounds to {y1 + offVal, x1, y2 + offVal, x2}
      end tell
   end repeat
   display dialog "Fertig." buttons "OK" default button 1 with icon 1 giving up after 59
end tell
---
Wie Du siehst, sind die Werte fix im Script definiert. Wenn allen Bildern
dieselben Attribute zugewiesen werden sollen, ist dies die einfachste Lösung.
Sonst komm bitte zurück. Aber ich werde erst morgen gegen acht Uhr wieder
vorbeischauen.

Gruss, Hans


als Antwort auf: [#421572]

Indesign Skript Rahmeninhalt skalieren/verschieben

Anonym
Beiträge gesamt: 22827

25. Mär 2007, 21:49
Beitrag # 7 von 29
Beitrag ID: #421578
Bewertung:
(6613 mal gelesen)
URL zum Beitrag
Beitrag als Lesezeichen
Hallo Hans,

Suuuperklasse!!!

Ich freue mir ein Loch in den Bauch - die Werte im Skripteditor zu ändern, bekomme sogar ich hin.

Vielen Dank, dadurch wurde mir sehr viel Arbeit erspart.

Liebe Grüße,

Thor


als Antwort auf: [#421572]

Indesign Skript Rahmeninhalt skalieren/verschieben

Hans Haesler
  
Beiträge gesamt: 5826

26. Mär 2007, 06:05
Beitrag # 8 von 29
Beitrag ID: #421579
Bewertung:
(6613 mal gelesen)
URL zum Beitrag
Beitrag als Lesezeichen
Hallo Thor,

bitteschön.

Wie gesagt, wenn es eine einmalige Sache ist, dann sollte diese
Version genügen. Falls die Ausführungsdauer relativ klein ist,
kannst Du bei 'giving up after 59' die Zahl 59 in eine Eins
verwandeln. Dann geht der Dialog nach einer Sekunde zu.

Wenn Du aber das Script noch bei anderen Gelegenheiten einsetzen
möchtest, dann kann ich einen Dialog einbauen.

Gruss, Hans


als Antwort auf: [#421572]

Indesign Skript Rahmeninhalt skalieren/verschieben

Anonym
Beiträge gesamt: 22827

26. Mär 2007, 06:23
Beitrag # 9 von 29
Beitrag ID: #421580
Bewertung:
(6613 mal gelesen)
URL zum Beitrag
Beitrag als Lesezeichen
Guten Morgen Hans,

Zitat

Wenn Du aber das Script noch bei anderen Gelegenheiten einsetzen
möchtest, dann kann ich einen Dialog einbauen.
Code
 


das wäre natürlich die Sahnehaube. :lol:

Nochmals vielen dank


als Antwort auf: [#421572]

Indesign Skript Rahmeninhalt skalieren/verschieben

Anonym
Beiträge gesamt: 22827

26. Mär 2007, 07:17
Beitrag # 10 von 29
Beitrag ID: #421581
Bewertung:
(6613 mal gelesen)
URL zum Beitrag
Beitrag als Lesezeichen
…sag mal Hans,

kennst Du eine Softwarelösung, um bei PDFs per Batch nachträglich die Helligkeit von Bildern zu steuern? - Nur bei den Bildern.
Ich möchte einfach verschiedene Broschüren übern Laserdrucker in Graustufen ausgeben und da sind teilweise die Bilder einfach zu dunkel und schmieren zu.

vielleicht auch mittels Skript?


-> alle Bilder werden in PDF per TouchUp ausgewählt -> an Photoshop übergeben -> aufhellen -> Rücksprung zu Acrobat und damit die geänderten Bilder an die PDF-Datei übergeben.


Ist so etwas möglich?

LG, Thor


als Antwort auf: [#421572]

Indesign Skript Rahmeninhalt skalieren/verschieben

Hans Haesler
  
Beiträge gesamt: 5826

26. Mär 2007, 08:06
Beitrag # 11 von 29
Beitrag ID: #421582
Bewertung:
(6613 mal gelesen)
URL zum Beitrag
Beitrag als Lesezeichen
Hallo Thor,

hier ist schon mal eine erste Version. Anders als in Deinem geposteten
Script, ist das Ergebnis der Skalierung absolut, d.h. die Prozentwerte,
welche den Bildern zugewiesen sind, werden nicht beachtet.

Bei den Versatzwerten müssten eigentlich die Koordinaten des aktuellen
Rahmens berücksichtigt werden, damit man ebenfalls absoulte Werte hätte.
Weil ich aber davon ausgehe, dass das Script nur einmal ausgeführt wird
und die X- und Y-Parameter bei jedem Bild {0, 0} sind, habe ich darauf
verzichtet.
Code
--AlleBilderSkalieren_01d.scpt  
property xScale : 100
property yScale : 100
property xOff : 0
property yOff : 0

tell application "Adobe InDesign CS2"
  activate
  try
    destroy dialogs
  end try
  set aDialog to make dialog with properties {name:"Alle Bilder skalieren"}
  tell aDialog
    set column1 to make dialog column
    tell column1
      set row1 to make dialog row
      tell row1
        make static text with properties {static label:"Skalierung"}
        make static text with properties {static label:" "}
      end tell
      set border1 to make border panel
      tell border1
        set column2 to make dialog column
        tell column2
          set row2 to make dialog row
          tell row2
            make static text with properties {static label:"X:"}
            set xScale to make real editbox with properties ¬
              {edit value:xScale, minimum value:1, maximum value:1000, min width:36}
            make static text with properties {static label:"%    ", min width:26}
          end tell
          set row3 to make dialog row
          tell row3
            make static text with properties {static label:"Y:"}
            set yScale to make real editbox with properties ¬
              {edit value:yScale, minimum value:1, maximum value:1000, min width:36}
            make static text with properties {static label:"%    ", min width:26}
          end tell
        end tell
      end tell
      set row4 to make dialog row
      tell row4
        make static text with properties {static label:"Versatz"}
        make static text with properties {static label:" "}
      end tell
      set border2 to make border panel
      tell border2
        set column3 to make dialog column
        tell column3
          set row5 to make dialog row
          tell row5
            make static text with properties {static label:"X:"}
            set xVal to make real editbox with properties {edit value:xOff, min width:36}
            make static text with properties {static label:"mm", min width:6}
          end tell
          set row6 to make dialog row
          tell row6
            make static text with properties {static label:"Y:"}
            set yVal to make real editbox with properties {edit value:yOff, min width:36}
            make static text with properties {static label:"mm", min width:6}
          end tell
        end tell
      end tell
    end tell
  end tell
  set column4 to make dialog column at aDialog
  tell column4
    make static text with properties {static label:" ", min width:4}
  end tell
 
  set dlog to show aDialog
  if dlog is false then
    destroy aDialog
    error number -128
  else
    set xScale to edit value of xScale
    set yScale to edit value of yScale
    set xOff to edit value of xVal
    set yOff to edit value of yVal
    destroy aDialog
  end if
 
  tell document 1
    set allImgs to all graphics
    repeat with i from 1 to count of allImgs
      tell item i of allImgs
        set properties to {horizontal scale:xScale, vertical scale:yScale}
        set {y1, x1, y2, x2} to geometric bounds
        set geometric bounds to {y1 + yOff, x1 + xOff, y2 + yOff, x2 + xOff}
      end tell
    end repeat
   
    display dialog "Fertig." buttons "OK" default button 1 with icon 1 giving up after 1
   
  end tell
end tell

Zu Deinem Hellikeitsproblem kenne ich leider keine Lösung.

Gruss, Hans


als Antwort auf: [#421572]

Indesign Skript Rahmeninhalt skalieren/verschieben

Anonym
Beiträge gesamt: 22827

26. Mär 2007, 08:28
Beitrag # 12 von 29
Beitrag ID: #421583
Bewertung:
(6613 mal gelesen)
URL zum Beitrag
Beitrag als Lesezeichen
Hallo Hans,

funktioniert perfekt!

Wenn ich jetzt vor Ort wäre, würde der berühmte Kniefall kommen :-)

LG, Thor


als Antwort auf: [#421572]

Indesign Skript Rahmeninhalt skalieren/verschieben

Anonym
Beiträge gesamt: 22827

26. Mär 2007, 15:53
Beitrag # 13 von 29
Beitrag ID: #421584
Bewertung:
(6613 mal gelesen)
URL zum Beitrag
Beitrag als Lesezeichen
Hallo Hans,

Hilfeee bitte!

Seit eben bekomme ich diese Fehlermeldung vom Skript - nichts geht mehr!

http://www.punkerchen.de/Fotos/Bild 1.jpg


Gruß Thor


als Antwort auf: [#421572]

Indesign Skript Rahmeninhalt skalieren/verschieben

Hans Haesler
  
Beiträge gesamt: 5826

26. Mär 2007, 18:44
Beitrag # 14 von 29
Beitrag ID: #421585
Bewertung:
(6613 mal gelesen)
URL zum Beitrag
Beitrag als Lesezeichen
Hallo Thor,

nur keine Panik!

Das Problem ist, dass ich beim Auswerten zwei Mal für die Variable denselben Namen
gewählt hatte, wie für das Objekt im Dialog.

Das geht solange gut, als man das Script normal ausführt. Aber wehe, wenn man auf
den "Abbrechen"-Button klickt. Dann wird beim nächsten Start der Dialog gezeigt,
welchen Du auch gesehen hast.

Die Variablen sind als 'property' definiert. Behalten also ihren Wert für die nächste
Ausführung. Doch bei einem Abbruch wird nicht der aktuelle Wert des Feldes,
sondern die Referenz des Dialog-Objekts gespeichert. Und beim nächsten Ausführen
fliegt die Sache auf.

Abhilfe: Das Script neu sichern. Oder zwischen den Zeilen ...
---
   if dlog is false then
      destroy aDialog
---
... den aktuellen Wert der Felder speichern.

Oder (und viel besser) die Namen der Variablen ändern. Hier nochmals das Script ...
Code
--AlleBilderSkalieren_02d.scpt  
property xScale : 100
property yScale : 100
property xOff : 0
property yOff : 0

tell application "Adobe InDesign CS2"
  activate
  try
    destroy dialogs
  end try
  set aDialog to make dialog with properties {name:"Alle Bilder skalieren"}
  tell aDialog
    set column1 to make dialog column
    tell column1
      set row1 to make dialog row
      tell row1
        make static text with properties {static label:"Skalierung"}
        make static text with properties {static label:" "}
      end tell
      set border1 to make border panel
      tell border1
        set column2 to make dialog column
        tell column2
          set row2 to make dialog row
          tell row2
            make static text with properties {static label:"X:"}
            set xScaleVal to make real editbox with properties ¬
              {edit value:xScale, minimum value:1, maximum value:1000, min width:36}
            make static text with properties {static label:"%    ", min width:26}
          end tell
          set row3 to make dialog row
          tell row3
            make static text with properties {static label:"Y:"}
            set yScaleVal to make real editbox with properties ¬
              {edit value:yScale, minimum value:1, maximum value:1000, min width:36}
            make static text with properties {static label:"%    ", min width:26}
          end tell
        end tell
      end tell
      set row4 to make dialog row
      tell row4
        make static text with properties {static label:"Versatz"}
        make static text with properties {static label:" "}
      end tell
      set border2 to make border panel
      tell border2
        set column3 to make dialog column
        tell column3
          set row5 to make dialog row
          tell row5
            make static text with properties {static label:"X:"}
            set xVal to make real editbox with properties {edit value:xOff, min width:36}
            make static text with properties {static label:"mm", min width:6}
          end tell
          set row6 to make dialog row
          tell row6
            make static text with properties {static label:"Y:"}
            set yVal to make real editbox with properties {edit value:yOff, min width:36}
            make static text with properties {static label:"mm", min width:6}
          end tell
        end tell
      end tell
    end tell
  end tell
  set column4 to make dialog column at aDialog
  tell column4
    make static text with properties {static label:" ", min width:4}
  end tell
 
  set dlog to show aDialog
  if dlog is false then
    destroy aDialog
    error number -128
  else
    set xScale to edit value of xScaleVal
    set yScale to edit value of yScaleVal
    set xOff to edit value of xVal
    set yOff to edit value of yVal
    destroy aDialog
  end if
 
  tell document 1
    set allImgs to all graphics
    repeat with i from 1 to count of allImgs
      tell item i of allImgs
        set properties to {horizontal scale:xScale, vertical scale:yScale}
        set {y1, x1, y2, x2} to geometric bounds
        set geometric bounds to {y1 + yOff, x1 + xOff, y2 + yOff, x2 + xOff}
      end tell
    end repeat
   
    display dialog "Fertig." buttons "OK" default button 1 with icon 1 giving up after 1
   
  end tell
end tell

... versehen mit der notwendigen Korrektur. Bitte entschuldige meine Nachlässigkeit.

Gruss, Hans


als Antwort auf: [#421572]

Indesign Skript Rahmeninhalt skalieren/verschieben

Anonym
Beiträge gesamt: 22827

26. Mär 2007, 19:12
Beitrag # 15 von 29
Beitrag ID: #421586
Bewertung:
(6613 mal gelesen)
URL zum Beitrag
Beitrag als Lesezeichen
Hallo Hans,

Uff, Danke.

Wie kann ich das gut machen?

Thor


als Antwort auf: [#421572]
X