Quantcast
Channel: Adobe Community : Discussion List - Illustrator Scripting
Viewing all 3671 articles
Browse latest View live

AppleScript AI CS4: path to me

$
0
0

Hi Folks,

 

I hope this is a simple question!

 

How can an AppleScript that is run from Illustrator's Scripts menu get a path to itself instead of Adobe Illustrator.app? I have been hard coding the path to the Scripts folder, but this won't work if the user puts the script into a subfolder of the Scripts folder.

 

The script below displays "<boot-volume>:Applications:Adobe Illustrator CS4:Adobe Illustrator.app" but I'm interested in the path to the script.

 

tell application "Finder"     display dialog ((path to me) as Unicode text)
end tell

 

Thanks!

 

-- Jim


Problem using Illustrator CS5 and CC 2014 in same PC

$
0
0

Hi,

 

I am developing some Illustrator scripts using VBScript, which should work on CS5, CS6 or CC 2014. When the scripts will be called, the user will pass, as command line argument, which Illustrator version they want to use. Accordingly I am instantiating the appropriate Illustrator scripting object by the following code:

 

    If version = 1Then
        Set appRef = CreateObject("Illustrator.Application.CS5") 
    ElseIf version = 2Then
        Set appRef = CreateObject("Illustrator.Application.CS6") 
    ElseIf version = 3Then
        Set appRef = CreateObject("Illustrator.Application.CC.2014") 
    Else
        Set appRef = CreateObject("Illustrator.Application") 
    Endif

 

This is working correctly in one system where CS5 and CC 2014 are both installed. However, in another similar system, where CS5 and CC 2014 are both installed, this is failing. There, always the CC 2014 version is being used, even when the user wants to use CS5. On inspection it is found that the issue is with registry entry of LocalServer32 subkey of the Illustrator.Application.CS5 automation object. There I see, the path of CC 2014 executable is stored, not that of CS5. The value is C:\Program Files\Adobe\Adobe Illustrator CC 2014 (32 Bit)\Support Files\Contents\Windows\Illustrator.exe /automation. Hence, the statement CreateObject("Illustrator.Application.CS5") is actually starting the CC 2014 Illustrator version.

 

Does anyone know how this could have happened? Is this some installation behavior of CS5 or CC 2014, that can be controlled? In this machine CC 2014 was installed after CS5. Does CC 2014 change the registry settings of CS5, if it was installed? That seems very unlikely, as then how can one use both CS5 and CC 2014 in a system through scripts? It is possible that this is a one-off case where the registry entries have been "accidentally" changed. However, I would like to be sure.

 

I can re-install CS5 in this system where the issue is noted and probably the problem will go away. However, the scripts may be used in many different installations and I cannot possibly ask users to reinstall Illustrator everywhere. Moreover, this problem can occur sometimes in the future too. 

 

Any suggestion regarding the cause and a possible full-proof solution will be highly appreciated.

 

Thanks in advance,

Joydeep Ray

convertAreaObjectToPointObject(), does not convert as far as script as concerned

$
0
0

When converting a area text item using convertAreaObjectToPointObject(), the remainder of the script still thinks it's an area text object after the function is executed and cannot be access like a point type, even though it shows correctly as point text object  in the drawing.

Also, unlike the documentation is statin,g the function appears to not return the newly converted text frame but "null"

 

Is this a known bug? How can I get this to work?

Thanks

How to rotate a art board in a illustrator using adobe extended javascript

$
0
0

How to rotate a art board in a illustrator using adobe extended javascript

 

how to create mirror image of each textframe content of artboard

Select all anchor points by using script

$
0
0

5hglfe

Hello everyone. i have some difficulties fith selecting path. After i draw shape with blob brush tool i need to copy an interior path. i do this action many times so help me guys.

Is it possible to have a keyboard shortcut run a script with CS6?

$
0
0

I see there is an option for it to go to "other scripts" with a keyboard shortcut, but that really doesn't help much. I want it to play a specific script that is already loaded. Thanks in advance!!

How to extract images from adobe illustrator using extended javascript

$
0
0

hi,

I am working on adobe extended javascript , and I need to extract all the images from artboard(adobe illustrator).and save co-ordinates of the images in the artboard to a text file.

Thanks

A way to add shortcut or panel with button to run script

$
0
0

There is an ongoing post about the shortcut to do this, so assuming there is no way. Only way I know is creating an action then inserting menu item in action and assigning shortcut to that action. This is really hacky thought since you have to reset the menu item every time you load illustrator.

 

Another way I was hoping I could do this is just make a custom panel like photoshop has and just press a button to run a script. I don't know if I have to go low level programming to do something like this, or if there is an easier way.

 

anyone have advice on how to approach either of these?


How to save a pdf to the desktop?

Any one could help me out in writing a code in VB for drawing an arc

$
0
0

Any one could help me out in writing a code in VB for drawing an arc

Script path arrows

$
0
0

I cannot seem to find a complete description of the Adobe Illustrator object model, only the scripting guides, which are a good start but seem to provide only a partial list...does one exist?  My immediate problem is figuring out the script add arrows to path: e.g., "turn arrows on, for both sides of selected stroke, using  arrow head 3 scaled at 50%". Easy enough to do by hand using the stroke menu, but not obvious how to do it via a script. In case it matters to the answer, am still in CS5.1. Thanks for any help.

How to reflect in script?

$
0
0
Hi,

I want the equivalent of choosing Object > Transform > Reflect, across the Vertical axis. How would I do this with JavaScript?

Thanks,

Max

transform > reflect objects in illustrator via javascript

$
0
0

Hi all,

 

are there any way to transform > reflect Vertical axis in illustrator but via JavaScript not apple and i mean reflect not scale H or V

 

thanks in advance.

Create element at center of artboard, move to next artboard and repeat

$
0
0

Hey All! I've been lurking around here for quite some time and i've always been able to find what i needed. Until now. =)

 

I'm writing a Javascript to create multiple rectangles on the center of the active artboard and then repeat for all remaining artboards. However, i'm getting hung up on how to shift focus to the next artboard. I've read about  "setActiveArtboardIndex();" but whenever i try to use this feature, i get the error "setActiveArtboardIndex(); is not a function".

 

Here's the code i'm working with. Could anyone please tell me how to get the loop to switch to the next artboard before creating the next set of color blocks?

 

 

//Beginning of Script

#target illustrator

if (app.documents.length > 0) {

var docRef = app.activeDocument
}
else {
alert("No Document Open");
}




//Add Color Block Layer


artLayers.locked = true;


function existBlockLayer(layers, name) {
    for (i=0; i<docRef.layers.length; i++){        if (layers[i].name===name) return true;        }    return false;    }          
if (existBlockLayer(docRef.layers,"Color Blocks")) {    var removeLayer = artLayers.getByName("Color Blocks");    removeLayer.locked = false;    removeLayer.remove();    var blockLayer = docRef.layers.add();    blockLayer.name = "Color Blocks"    }
else {    var blockLayer = docRef.layers.add();    blockLayer.name = "Color Blocks"    }


blockLayer.locked = false;






//Get Document Swatches


var swatchList = docRef.swatches;
var artLayers = docRef.layers
var aB = docRef.artboards
var colorList = [];




for(var k=0; k< swatchList.length; k++) {    if (swatchList[k].name.toLowerCase() != "thru-cut" && swatchList[k].name.toLowerCase() != "[registration]"//    && swatchList[k].name.toLowerCase() != "[none]" && swatchList[k].name.toLowerCase() != "cut line"){            colorList.push(swatchList[k].name);           }       }




//Create 1 Color Block per Swatch and Apply Swatch


for (var a=0; a<aB.length; a++) {          var aBLeft = aB[a].artboardRect[0];    var aBRight = aB[a].artboardRect[2]    var aBTop = aB[a].artboardRect[1]    var aBBottom = aB[a].artboardRect[3]        var W = (aBRight/2);    var H = (aBBottom/2);      var posH = (H/2);      var posW = (W/2);    alert(W + " width " + H + " height");     var activeArtboard = aB[a];      //var aBPlus = setActiveArtboardIndex(a);      for(var c=0,len=colorList.length;c<len;c++){        var newBlock = docRef.pathItems.rectangle(posH, posW,10,10);        newBlock.stroked = false;         }      for (var i=0; i < colorList.length; i++) {        docRef.pathItems[i].fillColor=docRef.swatches.getByName(colorList[i]).color;    }
}   
artLayers.locked = false;
blockLayer.zOrder (ZOrderMethod.SENDTOBACK);
blockLayer.locked = true;

 

 

 

 

 

Thanks in advance all!

Imagetrace Script / doesn't recognize options / wtf preset number

$
0
0

Hello,

I'm totally desperate because I need to get an imagetracing script to work and it somehow just won't.
Here's the deal. I need to adjust the options for the trace command. There are 2 ways I can think of:

1) load a preset from the Application.tracingPresetList
array:
Well I tried preset number 1 to 25 and they load the default imagetrace presets but there is no way I could figure out to load my custom made presets. Also loading by name string doesn't work. This kinda sucks bigtime. Maybe there is a working way to write a custom preset in the array and then simply load it in my script?

2) set the tracingoptions right in the script:
and here is where my lack of javascript knowledge bugs me. I spent hours and hours browsing through code and read the javascript object reference but somehow illustrator just ignores my code. I guess it's a pretty simple job for someone who knows javascript. Here is the link to the reference guide. Tracing is starting at page 230 http://www.adobe.com/content/dam/Adobe/en/devnet/pdf/illustrator/scripting/...

Here comes the code. The bold part is where the options are set (or not..) and the commentary line is the preset part from option 1.
If someone could help me out. It's a biggie to me I will gladly buy you a case of beer, wire some coin on paypal, make you a video or whatever suits you. I'm realy loosing it, so please help!

Best Regards
rold
digitaldopamine.com

// Main Code [Execution of script begins here]

// uncomment to suppress Illustrator warning dialogs
// app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;

// Collectable files
var COLLECTABLE_EXTENSIONS = ["bmp", "gif", "giff", "jpeg", "jpg", "pct", "pic", "psd", "png", "tif", "tiff"];

var destFolder, sourceFolder;

// Select the source folder
sourceFolder = Folder.selectDialog( 'Select the SOURCE folder...', '~' );
//sourceFolder = new Folder("C:/Users//Desktop/1");

if(sourceFolder != null)
{
// Select the destination folder
destFolder = Folder.selectDialog( 'Select the DESTINATION folder...', '~' );       
//destFolder = new Folder("C:/Users//Desktop/2");
}

if(sourceFolder != null && destFolder != null)
{
//getting the list of the files from the input folder
var fileList = sourceFolder.getFiles();
var errorList;
var tracingPresets = app.tracingPresetsList;

for (var i=0; i {
if (fileList[i] instanceof File)
{
try
{               
var fileExt = String(fileList[i]).split (".").pop();
if(isTraceable(fileExt) != true)
continue;

// Trace the files by placing them in the document.

// Add a document in the app
var doc = app.documents.add(DocumentColorSpace.RGB,640,360);

    // Add a placed item
var p = doc.placedItems.add();
p.file = new File(fileList[i]);

// Trace the placed item
var t = p.trace();
myOpts = t.tracing.tracingOptions;
myOpts.cornerAngle = 180;
myOpts.fills = true;
myOpts.ignoreWhite = true;
myOpts.minArea = 0;
myOpts.pathFitting = 0;
myOpts.tracingModeType = 'TRACINGMODEBLACKANDWHITE';



// t.tracing.tracingOptions.loadFromPreset(tracingPresets[3]);

app.redraw();

var destFileName = fileList[i].name.substring(0, fileList[i].name.length - fileExt.length-1) + "_" +fileExt;
var outfile = new File(destFolder+"/"+destFileName);
doc.saveAs(outfile);
doc.close();
}
catch (err)
{
errorStr = ("Error while tracing "+ fileList[i].name  +".n" + (err.number & 0xFFFF) + ", " + err.description);
// alert(errorStr);
errorList += fileList[i].name + " ";
}
}
}
fileList = null;
alert("Batch process complete.");
}
else
{
alert("Batch process aborted.");
}

sourceFolder = null;
destFolder = null;

function isTraceable(ext)
{
var result = false;
for (var i=0; i {
if(ext == COLLECTABLE_EXTENSIONS[i])
{
result = true;
break;
}
}
return result;
}


Is it possible to use AI "selection sets" in script and scriptUI?

$
0
0

Wondering is there way to use those selection sets that found from Select menu in script?

SelectionSet.png

 

Using this list in ScriptUI where I can select them. This would help me to use selection while I'm in "dialog" type list. Anyone have solution?

SelectionSet_Browse.png

fitArtboardToSelectedArt and saveASSVG is not working

$
0
0

Hi Experts,

 

I have a problem in the below script, the script will execute the "fitArtboardToSelectedArt" function after Export the SVG file in output folder, After I opened the output folder files, not applying the fitartboardToSelectedArt options.

 

I want to apply the this:

Object-->Fit to Selected Art. And Export or saveAs SVG file.

 

Any one help me Where I am made the mistake please guide.

 

#target illustrator

 var myFolder = Folder.selectDialog( "Select a 'INPUT folder' with contains '*.svg' files" );
 if (!myFolder){
    alert("User cancel the process!");    }

var myOutFolder = Folder.selectDialog("Select the 'OUTPUT  folder'", "");
if (!myOutFolder){    alert("User cancel the process!");    }

if ( myFolder != null ) {
    var myFiles = [];    GetSubFolders(myFolder);    if ( myFiles.length > 0 ) {        for ( i=0; i < myFiles.length; i++ ) {            app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;            var myDoc =app.open(myFiles[i]);            var doc = app.activeDocument;            var mySaveName = doc.name;            doc.layers[0].hasSelectedArtwork = true;            doc.fitArtboardToSelectedArt();            SaveAsSVG(myOutFolder, mySaveName);            }        }    else{        alert("No file in the selected folder");        }    }


function SaveAsSVG(myOutFolder, mySaveName){
    var exportOptions = new ExportOptionsSVG();    var type = ExportType.SVG;    var fileSpec = new File(myOutFolder);    exportOptions.embedRasterImages = true;    exportOptions.embedAllFonts = false;    exportOptions.fontSubsetting = SVGFontSubsetting.GLYPHSUSED;    //app.activeDocument.saveAs(new File(myOutFolder+"/"+ mySaveName), exportOptions);    app.activeDocument.exportFile(new File(myOutFolder+"/"+ mySaveName), type, exportOptions);    }



//=================================== FUNCTIONS =========================================
function GetSubFolders(theFolder) {
     var myFileList = theFolder.getFiles();     for (var i = 0; i < myFileList.length; i++) {          var myFile = myFileList[i];          if (myFile instanceof Folder){               GetSubFolders(myFile);          }          else if (myFile instanceof File && myFile.name.match(/\.svg/i)) {               myFiles.push(myFile);          }     }
}
//---------

 

 

Before Run the Script original svg Image.

 

Before.png

 

After the run the script the output is below snapshots

 

After.png

Why this happend I don't know how to solve this problem.

 

 

thx,

csm_phil

 

Message was edited by: csm_phil

Use Javascript to select artwork on a particular artboard?

$
0
0

Is there a way to use Javascript to select all artwork on a particular artboard?

 

Or if you couldn't designate the selection based on the artboard index, another way i could see doing it would be to select all artwork within a bounding box? For example if i were to measure the artboardRect of an artboard and then set the selection to all pageItems within that bounding box?

 

Thanks in advance!

Ignore patterns and process swatches when pushing to array

$
0
0

How do i go about ignoring process colors and pattern swatches when pushing swatches to an array? So far i've been able to exclude swatches by name, but ColorType.CMYK doesn't seem to do it... Here's the snippet in question..

 

//Get Document Swatches


var swatchList = docRef.swatches;


var colorList = [];




for(var k=0; k< swatchList.length; k++) {    if (swatchList[k].name.toLowerCase() != "thru-cut" && swatchList[k].name.toLowerCase() != "[registration]"//    && swatchList[k].name.toLowerCase() != "[none]" && swatchList[k].name.toLowerCase() != "cut line" //    && swatchList[k] != ColorType.CMYK){             colorList.push(swatchList[k].name);           }       }

 

am i way off on the syntax for ColorType? While i'm at it.. is there a way to clean up this list to make things easier to add/remove in the future. ideally i think i'd have an array that just includes the swatches to ignore.. something like this:

 

var ignoredSwatches = ["thru-cut", "[registration]"]

for (var k=0; k<swatchList.length; k++) {     if swatchList[k].name.toLowerCase() != ignoredSwatches {          colorList.push(swatchList[k].name);          }     }

 

 

Thanks in advance, folks.

graphics.PenType.THEME-COLOR badly documented: which ones exist?

$
0
0

Using ScriptUI I'm defining a new brush color to match the Illustrator UI theme color for example with

myColor = w.graphics.newPen(w.graphics.PenType.THEME_COLOR, "appDialogBackground",1);

 

What prefined ones exist other then "appDialogBackground"?  In particular I am interested in using the one that is orange in dark UI and blue on light UI, used on focus rings for example

Any clues? Anybody from Adobe even know?

Viewing all 3671 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>