• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Neue Größe in Zeichenfläche schreiben mit Skript

New Here ,
Oct 04, 2022 Oct 04, 2022

Copy link to clipboard

Copied

Hallo Zusammen, 
ich versuche seit zwei Tagen ein Skript zu schreiben, um hunderte .ai-Dateien via Skript auf die gleiche Zeichenfläche-Größe zu bringen. 
Mein Skript läuft soweit auch wie gewollt durch, nur wird die neu berechnete Größe nicht in die Zeichenfläche eingetragen. D.h. die Zeichenfläche verändert ihre Größe nicht. 

 

 

 

#target Illustrator

var OPTIONS = {
    size   : 144.566895,
    width  : 144.566895,
    height : 144.566895
};
app.userInteractionLevel.DISPLAYALERTS
    var dir = Folder.selectDialog("Where?");
    var files = dir.getFiles("*.ai");
    
     OPTIONS.size = Window.prompt(
			"Enter New Artboard size in pixels as WxH ( Example: 250x300 )", 144.566895,title);

    // var doc = app.open(files);
            
      for (var j = 0; j < files.length; j++) {

          var doc = app.open(files[j]);
          
			var title = "Resize All Artboards";

            var width  = OPTIONS.width;
          var height = OPTIONS.height;
          
          var idoc = app.activeDocument;

          var ab = idoc.artboards[0];
			
			
            // var abBounds = doc.artboards[j].artboardRect; // left, top, right, bottom
          var abBounds = ab.artboardRect; // left, top, right, bottom
          

        //   Window.alert(ab);
           Window.alert(abBounds);
          
            var ableft   = abBounds[0];
            var abtop    = abBounds[1];
            var abwidth  = abBounds[2] - ableft;
            var abheight = abtop- abBounds[3];

            var abctrx   = abwidth / 2 + ableft;
            var abctry = abtop - abheight / 2;
          
        //   Window.alert(width);
        //   Window.alert(height);

            var ableftNew   = abctrx - width  / 2;
            // Window.alert(ableft)
          var abtopNew = abctry + height / 2;
            // Window.alert(abtop)
          var abrightNew = abctrx + width / 2;
            // Window.alert(abright)
          var abbottomNew = abctry - height / 2;
            // Window.alert(abbottom)
        
          var test = app.activeDocument.artboardRect = [abBounds[0], abBounds[1], abBounds[2], abBounds[3]];
        //   var test = app.activeDocument.artboardRect = [ableftNew, abtopNew, abrightNew, abbottomNew];
            Window.alert(test);
            app.activeDocument.artboardRect = [abBounds[0], abBounds[1], abBounds[2], abBounds[3]];

          
        doc.close(SaveOptions.SAVECHANGES);
}
     

 

 

 

 Weiß jemand, woran es liegen kann? 

3 Beispiel .ai-Dateien zum ausprobieren hänge ich mit an :https://drive.google.com/drive/folders/1kslWAPYwdXeZRihVg4rZKlDapho9dgLp?usp=sharing

TOPICS
Scripting

Views

196

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Guide , Oct 04, 2022 Oct 04, 2022

The line before last should be

 

app.activeDocument.artboards[0].artboardRect = [ableftNew, abtopNew, abrightNew, abbottomNew];

 

(artboards[0] is missing in all similar statements in the script.)

Votes

Translate

Translate
Adobe
Guide ,
Oct 04, 2022 Oct 04, 2022

Copy link to clipboard

Copied

The line before last should be

 

app.activeDocument.artboards[0].artboardRect = [ableftNew, abtopNew, abrightNew, abbottomNew];

 

(artboards[0] is missing in all similar statements in the script.)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 12, 2022 Oct 12, 2022

Copy link to clipboard

Copied

Thank you! Adding that"0" made the script work!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 04, 2022 Oct 04, 2022

Copy link to clipboard

Copied

Hallo @EliaB82B 

wie dir @femkeblanco bereits geschrieben hat: du verwendest in deinem Script die ausgelesenen Koordinaten des Originalartboards. Das heißt nicht anderes als die Größe des Artboards mit der originalen Größe zu ersetzen. Verwende deine "New-Koordinaten". dann sollte es auch funktionieren.

 

Was sich mir allerdings nicht ganz erschließt - wie du mit deinem bisherigen Scriptaufbau und deiner Variable "Options" etwas anderes als ein quadratisches Artboard erstellen kannst.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 12, 2022 Oct 12, 2022

Copy link to clipboard

Copied

LATEST

Also mit den rechteckigen Motiven hat es auch geklappt. Keine Ahnung wieso 😄

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines