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

Startup Script for Illustrator only

Explorer ,
Aug 16, 2013 Aug 16, 2013

Copy link to clipboard

Copied

Hi,

I've made a nice palette script for Illustrator CS6 on OSX 10.6.8.

I put it into HD/Library/Application\ Support/Adobe/Startup\ Scripts\ CS6/Illustrator

I works fine in Illustrator.

BUT: If I start Indesign CS6, the palette show up twice and it is not possible to close both pallettes.

Any hints?

Next question: The palette is used to have an easy access to script. If I start the scripts with the palette, the error messages of the scripts are not displayed. If I start individal script directly in Illustrator errors are displayed. What can I do?

Thanks for your help.

#target illustrator;

#targetengine main;

//var pfad = "/Applications/Adobe\ Illustrator\ CS6/Presets.localized/de_DE/Skripten/"

var pfad = "/Volumes/Platte/Hilfsmittel/Skripte/"

var win = new Window('palette', 'Daniels Zauberkiste');

var tpanel = win.add ("tabbedpanel");

tpanel.alignChildren = ["fill", "fill"];

tpanel.preferredSize = [100,20];

win.margins = 0;

win.spacing = 0;

var subtab1panel = tpanel.add ("tab", undefined, "allgemein");

subtab1panel.orientation="row";

subtab1panel.alignChildren = ["fill", "fill"];

var t1group = subtab1panel.add("group");

t1group.orientation = "column";

t1group.alignChildren = ["fill", "fill"];

var btnSelect1 = t1group.add('button', undefined, 'Passer');

var scriptToLoad1 = new File(pfad+"_Passer-Montage.jsx");

var btnSelect2 = t1group.add('button', undefined, 'Prüfpasser');

var scriptToLoad2 = new File(pfad+"_Prüfpasser-Montage.jsx");

var btnSelect3 = t1group.add('button', undefined, 'Kontur+10');

var scriptToLoad3 = new File(pfad+"_Kontur+Dok+10.jsx");

var btnSelect4 = t1group.add('button', undefined, 'Kontur+20');

var scriptToLoad4 = new File(pfad+"_Kontur+Dok+20.jsx");

var btnSelect5 = t1group.add('button', undefined, 'Standardbogen Stanze');

var scriptToLoad5 = new File(pfad+"_Bogengröße.jsx");

btnSelect1.onClick = function(){

   

   var des = scriptToLoad1;

   des.open("r");

      

   var bt = new BridgeTalk;

   bt.target = "illustrator";

      

   var script = des.read();

   des.close();

           

   bt.body = script;

   bt.send();

  

}// end function

btnSelect2.onClick = function(){

   

   var des = scriptToLoad2;

   des.open("r");

      

   var bt = new BridgeTalk;

   bt.target = "illustrator";

      

   var script = des.read();

   des.close();

           

   bt.body = script;

   bt.send();

 

}// end function

btnSelect3.onClick = function(){

   

   var des = scriptToLoad3;

   des.open("r");

      

   var bt = new BridgeTalk;

   bt.target = "illustrator";

      

   var script = des.read();

   des.close();

           

   bt.body = script;

   bt.send();

}// end function

btnSelect4.onClick = function(){

   

   var des = scriptToLoad4;

   des.open("r");

      

   var bt = new BridgeTalk;

   bt.target = "illustrator";

      

   var script = des.read();

   des.close();

           

   bt.body = script;

   bt.send();

}// end function

btnSelect5.onClick = function(){

   

   var des = scriptToLoad5;

   des.open("r");

      

   var bt = new BridgeTalk;

   bt.target = "illustrator";

      

   var script = des.read();

   des.close();

           

   bt.body = script;

   bt.send();

}// end function

win.center();

win.show();

TOPICS
Scripting

Views

6.2K

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

Guru , Aug 16, 2013 Aug 16, 2013

Make an Illustrator Start Up Scripts folder and place in that…? From the guide…

Application-specific startup scripts folder

You must place application-specific startup scripts in a folder named Startup Scripts, which you create

in the Illustrator installation directory.

For example, when Illustrator CS6 is installed to its default location, you would create the

Startup Scripts folder at the following location:

Windows: C:\Program Files\Adobe\Adobe Illustrator CS6\Startup Scripts\

Mac OS: /Applications/

...

Votes

Translate

Translate
Adobe
Guru ,
Aug 16, 2013 Aug 16, 2013

Copy link to clipboard

Copied

Make an Illustrator Start Up Scripts folder and place in that…? From the guide…

Application-specific startup scripts folder

You must place application-specific startup scripts in a folder named Startup Scripts, which you create

in the Illustrator installation directory.

For example, when Illustrator CS6 is installed to its default location, you would create the

Startup Scripts folder at the following location:

Windows: C:\Program Files\Adobe\Adobe Illustrator CS6\Startup Scripts\

Mac OS: /Applications/Adobe Illustrator CS6/Startup Scripts/

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
Explorer ,
Aug 16, 2013 Aug 16, 2013

Copy link to clipboard

Copied

Thanks Mark for showing me again: RTFM!

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
Explorer ,
Aug 16, 2013 Aug 16, 2013

Copy link to clipboard

Copied

Another question on this case:

With the Script above, I want to start another script.

This works in most cases. But this script (export PDF) runs perfectly if started direct in Illustrator.

If the script is started from the palette-script it show "this.getOptions is no function" error.

Could anyone explain this to me?

/** Saves Illu-Doc as PDF

*/

// Main Code [Execution of script begins here]

#target illustrator

var doc = app.activeDocument;

//if (!doc.saved) doc.save();

var fileName = doc.fullName;

var thisFile = new File(fileName);

try {

          // uncomment to suppress Illustrator warning dialogs

          // app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;

          if (app.documents.length > 0 ) {

                    // Get the folder to save the files into

                    var destFolder = fileName;

        //destFolder = thisFile.saveDlg( 'Ordner für PDF-Dateien auswählen.', '~' );

                    if (destFolder != null) {

                              var options, targetFile;

                              // Get the PDF options to be used

                              options = this.getOptions();

                              // You can tune these by changing the code in the getOptions() function.

                                        // Get the file to save the document as pdf into

                                        targetFile = this.getTargetFile('.pdf', destFolder);

                                        // Save as pdf

                                        doc.saveAs( targetFile, options );

                              doc.close(SaveOptions.DONOTSAVECHANGES);

                    }

          }

          else{

                    throw new Error('Keine geöffneten Dokumente!');

          }

}

catch(e) {

          alert( e.message, "Skript-Warnung", true);

}

/** Returns the options to be used for the generated files.

          @return PDFSaveOptions object

*/

function getOptions()

{

          // Create the required options object

          var options = new PDFSaveOptions();

          // See PDFSaveOptions in the JavaScript Reference for available options

          // STANDARD:

          // For example, uncomment to set the compatibility of the generated pdf to Acrobat 7 (PDF 1.6)

           options.compatibility = PDFCompatibility.ACROBAT6;

          options.acrobatLayers = false;

    options.preserveEditability = false;

    options.generateThumbnails = false;

          // For example, uncomment to view the pdfs in Acrobat after conversion

           options.viewAfterSaving = true;

    //  Komprimierung

        options.compressArt = true;

        options.colorCompression = CompressionQuality.AUTOMATICJPEGMAXIMUM;

        options.colorDownsampling = 150;

        options.colorDownsamplingImageThreshold = 225;

        options.colorDownsamplingMethod = DownsampleMethod.BICUBICDOWNSAMPLE;

         options.grayscaleCompression = CompressionQuality.AUTOMATICJPEGMAXIMUM;

        options.grayscaleDownsampling = 150;

        options.grayscaleDownsamplingImageThreshold = 225;

        options.grayscaleDownsamplingMethod = DownsampleMethod.BICUBICDOWNSAMPLE;

      options.monochromeCompression = MonochromeCompression.CCIT4;

        options.monochromeDownsampling = 600;

        options.monochromeDownsamplingImageThreshold = 900;

        options.monochromeDownsamplingMethod = DownsampleMethod.BICUBICDOWNSAMPLE;

          return options;

}

/** Returns the file to save or export the document into.

          @param docName the name of the document

          @param ext the extension the file extension to be applied

          @param destFolder the output folder

          @return File object

*/

function getTargetFile(ext, destFolder) {

    destFolder=destFolder.toString();

    var fileName = "";

              var slash = destFolder.lastIndexOf('/');

                    fileName += destFolder.substring(slash+1);

    var newName = "";

          // if name has no dot (and hence no extension),

          // just append the extension

          if (fileName.indexOf('.') < 0) {

                    newName = fileName + ext;

          } else {

                    //var dot = fileName.lastIndexOf('.');

                    newName += fileName.substring(0, 7);

                    newName += ext;

          }

          // Create the file object to save to

          var newDest = "";

              var slash = destFolder.lastIndexOf('/');

                    newDest += destFolder.substring(0, slash);

    var myFile = new File( newDest + '/' + newName );

          // Preflight access rights

          if (myFile.open("w")) {

                    myFile.close();

          }

          else {

                    throw new Error('Zugriff verweigert.');

          }

          return myFile;

}

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
Participant ,
Aug 21, 2013 Aug 21, 2013

Copy link to clipboard

Copied

So I have a question about this, that first script that you listed creates a menu with buttons. Can you link these buttons to actions as well as scripts? Also i wanted to see if I could link my own scripts in there to try it out but it wouldnt run them. I'd like to make my own custom window with scripts and actions but I guess I dont know the proper was to link the folder here's what I tried using yours as an experiment.

#target illustrator;

#targetengine main;

var pfad = "C:\Program Files\Adobe\Adobe Illustrator CS6 (64 Bit)\Presets\en_US\Scripts"

var win = new Window('palette', 'Daniels Zauberkiste');

var tpanel = win.add ("tabbedpanel");

tpanel.alignChildren = ["fill", "fill"];

tpanel.preferredSize = [100,20];

win.margins = 0;

win.spacing = 0;

var subtab1panel = tpanel.add ("tab", undefined, "Custom Art Scripts");

subtab1panel.orientation="row";

subtab1panel.alignChildren = ["fill", "fill"];

var t1group = subtab1panel.add("group");

t1group.orientation = "column";

t1group.alignChildren = ["fill", "fill"];

var btnSelect1 = t1group.add('button', undefined, 'Mascot Import');

var scriptToLoad1 = new File(pfad+"Mascot Import.jsx");

var btnSelect2 = t1group.add('button', undefined, 'Omni Ungroup');

var scriptToLoad2 = new File(pfad+"ungroupV1.jsx");

btnSelect1.onClick = function(){

   

   var des = scriptToLoad1;

   des.open("r");

      

   var bt = new BridgeTalk;

   bt.target = "illustrator";

      

   var script = des.read();

   des.close();

           

   bt.body = script;

   bt.send();

  

}// end function

btnSelect2.onClick = function(){

   

   var des = scriptToLoad2;

   des.open("r");

      

   var bt = new BridgeTalk;

   bt.target = "illustrator";

      

   var script = des.read();

   des.close();

           

   bt.body = script;

   bt.send();

}// end function

win.center();

win.show();

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
Explorer ,
Aug 23, 2013 Aug 23, 2013

Copy link to clipboard

Copied

Hi Prails.design,

you could only link scripts to the palette. I'm MacUser, so I can't help you with the right code for the path.

To use actions with that palette you have to write a script that calls your action. If calling actions with a script is possible at all?

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 ,
Aug 23, 2013 Aug 23, 2013

Copy link to clipboard

Copied

To use actions with that palette you have to write a script that calls your action. If calling actions with a script is possible at all?

up to CS5 only VB and AS could play your actions, I think JS can now if you have CS6 or CC

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
Mentor ,
Aug 23, 2013 Aug 23, 2013

Copy link to clipboard

Copied

Like CarlosCanto said in CS6 and above you can research and try using "app.doScript();" for actions and "app.executeMenuCommand()" for menu commands via Javascript.

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 24, 2013 Oct 24, 2013

Copy link to clipboard

Copied

I'm confused and a noob to scripting with a similar question, I think.

In CS6 how can I create a button or shortcut that plays a script already in my scripts folder? I've know creating an action linked to a menu item will only work until I close the application. I've tried saving the set and reloading but got this error message.

AI-action_to_script.jpg

Does the above mentioned "Application-specific startup scripts folder" fix this issue? I'm not sure I understand the startup script folder vs the regular script folder.

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 ,
Jan 21, 2015 Jan 21, 2015

Copy link to clipboard

Copied

LATEST

sorry this response is so late.. but perhaps it will be of help to someone else who reads through this thread.

the alert in the screenshot above "Some event has not been registered for action." occurs because of Adobe's abysmal support for the actions panel especially with regards to running scripts.

When you add a script to an action via "Insert Menu Item", the script will work just fine until you quit illustrator. There is nothing in illustrators code that saves the script callout in your action when you quit. Therefore, when you restart illustrator (or try to reload the action set) you will get this alert letting you know that the script you added is missing.

Unfortunately, if you want to run a script through an action, you must re-add the script each time you open illustrator. Adobe has been aware of this issue for years and has never even commented on it. They just don't seem to care.

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