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

[Q] Is object size available in Perspective Grid (for avoiding Illustrator crash)

$
0
0

Hi all,

 

I think there's a crash bug on Illustrator when it resized more than maximum size on Perspective Grid.

 

I'm trying to work around the issue by checking object size before resize() call.

But I think I'm not getting the size to check.

 

Steps to reproduce the crash with Illustrator CC 2017 (21.1.0) on Win 7.

1) Open new doc

2) Show Perspective Grid

3) Select Ellipse tool

4) Add Ellipse near Vanishing Point of Perspective Grid as maximum size

5) Run script to resize 150%

 

Expected result

Ignored.

 

Actual result

Illustrator crash

 

Note that Illustrator UI operation does not cause crash. Only from script cause crash.

 

The reason I thought it is max size is from following screenshot.

The size tool tips is showing "W: 313766.85pt" and it does not bigger by position.

 

My question is that how can I get the size in script.

So I can avoid the resize() operation.

I'm not sure it is exposed in script.

 

 

20170807_Ai_Resize_01.png

 

 

20170807_Ai_Resize_02.png

 

Test code

// select obejct before run

var _t = activeDocument.selection[0];

 

// I'd like to get above size "W: 313766.85pt" in script

$.writeln("left = ", _t.length );

$.writeln("width = ", _t.width );

$.writeln("top = ", _t.top );

$.writeln("height = ", _t.height );

$.writeln("controlBounds = ", _t.controlBounds );

$.writeln("geometricBounds = ", _t.geometricBounds );

$.writeln("position = ", _t.position );

$.writeln("visibleBounds = ", _t.visibleBounds );

 

_t.resize(200,200); // cause crash

Output:

 

left = 5737.29393172847

width = 26

top = 2497.26831054688

height = 2868.41697923552

controlBounds = 4.5,3492.33313502452,31.5,-375.265221663346

geometricBounds = 5,2497.26836299477,31,-371.148616240749

position = 5,2497.26836299477

visibleBounds = 5,2497.26831054688,31,-371.148834228516

 

Thank you,

Naoki


Export SVG for WEB script

$
0
0

Hello, I am writing an automation script for Illustrator CC 2017. The goal of the script is to take an .ai file and export it as an SVG file for the web...
These are the EXACT settings I need the SVG to be exported with...

ExportSettings.png

 

My Exported SVG file needs to be encoded as follows :

<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 1440 1440">  <defs>    <style>      .cls-1, .cls-519, .cls-52, .cls-8 {        fill: none;      }      .cls-2 {        isolation: isolate;      }      .cls-3 {        fill: #96c0e1;      }      .cls-3, .cls-4, .cls-5 {        mix-blend-mode: overlay;      }      .cls-4 {        fill: #73a353;      }      .cls-5 {        fill: #9fb3b6;      }      .cls-520, .cls-6 {        fill: #a1a1a1;

 

 

However the output File looks like this :

<?xml version="1.0" encoding="iso-8859-1"?><!-- Generator: Adobe Illustrator 21.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0)  --><svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"  viewBox="0 0 1440 1440" style="enable-background:new 0 0 1440 1440;" xml:space="preserve"><filter  id="AI_GaussianBlur_4">  <feGaussianBlur  stdDeviation="4"></feGaussianBlur></filter><g id="CLASS2">  <path style="fill:#96C0E1;" d="M1258.797,1037.885c6.219-0.21,12.669-3.228,11.681-10.547c-1.569-11.581-21.712-4.747-27.9-2.616  c-7.572,2.609-14.153,7.072-20.066,12.472c0,0.006-0.003,0.006-0.006,0.01c-0.753,0.662-1.694,1.178-1.941,2.147  c0.472,0.019,0.941,0.019,1.413,0.009c5.74-0.125,11.369-1.391,17.078-1.841C1245.65,1037,1252.209,1038.109,1258.797,1037.885z  M1233.94,1035.49c-2.487,0.003-4.972,0.663-7.769,1.066c8.538-7.416,18.363-11.356,29.069-13.225  c2.616-0.456,5.372-0.406,8.034-0.225c3.291,0.225,4.891,1.872,5.222,4.75c0.431,3.769-0.616,6.262-3.866,7.05  c-3.247,0.784-6.7,0.969-10.063,0.969C1247.694,1035.887,1240.816,1035.49,1233.94,1035.49z"/>

 

My function looks like this :


function exportSVG(){
    var doc = activeDocument;    var file = new File("/Users/uv/Desktop/dd-fileintake-engine/scripts/test.svg")    var options = new ExportOptionsSVG();    var type = ExportType.SVG;    options.embedRasterImages = true;    options.fontType = SVGFontType.SVGFONT;    options.DTD = SVGDTDVersion.SVG1_1;    options.cssProperties = SVGCSSPropertyLocation.STYLEELEMENTS;    doc.exportFile(file, type, options);
 }


If some one could please explain to me what I am doing wrong with the options object I would greatly appreciate it !!!
Thank you all for your time !

illustrator javascript for "Identify overset text in a text frame and reduce the font size"

$
0
0

HI All

I have a illustrator document contain lot of  text frames. Some of the text frames content over-set text.( half portion of text is hidden)

I already using the java script to change the text frame height I have attached script and screen shot for your reference.

 

image.JPG

 

 

 

 

var includeExtraLines = 0.5;

 

if(documents.length > 0) {

    doc = activeDocument;

    mySelection = activeDocument.selection;

 

    // If there are enough to process

    if (mySelection instanceof Array)

    {

        // For each of the selected items

        for(i=0; i<mySelection.length; i++) {

            // That are textFrames

            if (mySelection[i].typename == "TextFrame" && mySelection[i].kind == TextType.AREATEXT ) {

                obj = mySelection[i];

               

                // We only want to do this on rectangular text areas

                // TODO: Take care of rotation issues from MakePointType script

                if( obj.textPath.pathPoints.length == 4 ) {

                    objTop = obj.top;

                    objLeft = obj.left;

                   

                    // Make the new point type object and locate it

                    // Make sure the new object is in the same Z stacking order as the original

                    copy1 = obj.duplicate(obj, ElementPlacement.PLACEBEFORE);

                    //copy1.move(obj, ElementPlacement.PLACEBEFORE);

 

                    // now make the text box much bigger, but not absurdly big

                    // TODO: This could be better approximated by itterating thru all the WORDS in the textFrame and

                    // comparing it to all the WORDS in each of the visible text LINES. Then apply the difference / total words to the scaling

                    if( copy1.height * 10 < 2000 ) {

                        copy1.textPath.height = copy1.height * 10;

                    } else {

                        copy1.textPath.height = 2000;

                    }

               

                    howManyLines = copy1.lines.length;

 

                    outlineObject = copy1.duplicate();

                    outlineObject = outlineObject.createOutline();

                   

                    targetHeight = outlineObject.height + includeExtraLines * (outlineObject.height / howManyLines );

 

                    // Now assign y-axis depth of the point text to the area text box

                    rect = obj.parent.pathItems.rectangle(copy1.textPath.top, copy1.textPath.left, obj.width, targetHeight);

                    copy2 = obj.parent.textFrames.areaText(rect);

                    copy2.selected = true;

                    rect.selected = true;

 

                    // Always delete these intermediate objects

                    outlineObject.remove();

                    copy1.remove();

                   

                    // Now take care of the end and original objects

                    obj.textRange.duplicate(copy2);   

                    obj.remove();   

                }

            }

        }

    }

}

 

 

 

 

But I need to reduce the overset  text frame font size.

 

 

 

 

Please advise me

Thanks in advance.

 

Ashok

About CharacterAttributes.AlternateGlyphs

$
0
0

Hi!

 

I have a question about CharacterAttributes.AlternateGlyphs.

 

There is a sample  file containing 3 Japanese Kanji.

 

1st : Glyphs form set to default

2nd: Glyphs form set to Expert

3rd:  Glyphs form set to JIS90 Forms

 

I want to know which alternate glyph  applied to the 3 Japanese Kanji.

So I use " IllTxtFrame.Characters.Item(i).CharacterAttributes.AlternateGlyphs " to get the alternate glyph.

But the result show me that the alternate glyphs applied to the 3 Japanese Kanji are default forms.

 

I can not understand why they are same. Is my way wrong?

Please give me some advices to get the alternate glyph applied to character.

 

Best regards.

Need illustrator javascript to Check and fix the dynamically over flow text

$
0
0

I want to dynamically fit over flow text in a specific txt frame in Illustrator by changing the font size. Is there a way to do this with JavaScript and set a minimum font size that does this action and in case there is still text is over flow show a pop

Batch Remove Guides If they Exists

$
0
0

Hello guys,

I am using Illustrator CC 2017 and I have a bunch of files which may or may not have guides.

After going through various threads, I came up with a script to remove Guides automatically if they exist but somehow it is getting stuck while saving the file.

 

Here is the javascript

 

sourceFolder = Folder.selectDialog();

// filesToProcess = sourceFolder.getFiles("*.ai");

var TypeList = prompt("Enter file types to act on","ai,eps,pdf","File Types");  

var reg = new RegExp("\.(" + TypeList.replace(/,/g, '|') + ")$", 'i');  

var filesToProcess = sourceFolder.getFiles(reg);

 

// Increment through the files

for (i=0; i < filesToProcess.length; i++) {

 

app.open(filesToProcess[i]);

var myDoc=app.activeDocument;

 

 

// Remove Guides

for(var i = myDoc.pathItems.length-1; i >= 0; i--) {

var p = myDoc.pathItems[i];

if (p.guides == true) {

p.remove();

}

}

 

// Save

var mySaveOptions = new IllustratorSaveOptions();

mySaveOptions.pdfCompatible = true;

myDoc.saveAs(filesToProcess[i],mySaveOptions);

 

myDoc.close();

}

 

here is the link to the test Illustrator file  https://drive.google.com/open?id=0B8FDkTEOTC4POUNpLXFtSUl0YzQ

 

it would be really great if someone could help me fix it.

Thanks

Get all alternate glyphs

$
0
0

Hi.

 

About alternate glyphs, is it possible to get all alternate glyphs from one character?

 

Best regard.

Script to auto attach to artboard.

$
0
0

Hi i have a Layer "Corner Marks" that i would like to automatically fit to the outside bounds of the artboard (the 4 corners.). the Marks are auto inserted but seem to be offset from the artboard a little bit. Thanks everyone.

 

From (All 4 Corners)

Screen Shot 2017-08-08 at 11.13.14 AM.png

I would like to go to (All 4 COrners)

Screen Shot 2017-08-08 at 11.18.30 AM.png


how can i get crop marks Indesign script to work in illustrator?

$
0
0

Is this even possible without editing the whole thing?  What i'm trying to do is get the same exact function thats in this script.  I'll post it below incase some of you dont have it.

 

main();
function main(){    //Make certain that user interaction (display of dialogs, etc.) is turned on.    app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;    if (app.documents.length != 0){        if (app.selection.length > 0){            switch(app.selection[0].constructor.name){                case "Rectangle":                case "Oval":                case "Polygon":                case "GraphicLine":                case "Group":                case "TextFrame":                case "Button":                    myDisplayDialog();                    break;                default:                               alert("Please select a page item and try again.");                    break;            }        }        else{            alert("Please select an object and try again.");        }    }    else{        alert("Please open a document, select an object, and try again.");    }
}
function myDisplayDialog(){    var myDialog = app.dialogs.add({name:"CropMarks"});    with(myDialog){        with(dialogColumns.add()){            var myCropMarksGroup = enablingGroups.add({staticLabel:"Crop Marks", checkedState:true});            with (myCropMarksGroup){                with(borderPanels.add()){                    staticTexts.add({staticLabel:"Options:"});                    with (dialogColumns.add()){                        staticTexts.add({staticLabel:"Length:"});                        staticTexts.add({staticLabel:"Offset:"});                        staticTexts.add({staticLabel:"Stroke Weight:"});                    }                    with (dialogColumns.add()){                        var myCropMarkLengthField = measurementEditboxes.add({editValue:6, editUnits:MeasurementUnits.points});                        var myCropMarkOffsetField = measurementEditboxes.add({editValue:3, editUnits:MeasurementUnits.points});                        var myCropMarkWidthField = measurementEditboxes.add({editValue:.25, editUnits:MeasurementUnits.points});                    }                }            }            var myRegMarksGroup = enablingGroups.add({staticLabel:"Registration Marks", checkedState:true});            with (myRegMarksGroup){                with(borderPanels.add()){                    staticTexts.add({staticLabel:"Options:"});                    with (dialogColumns.add()){                        staticTexts.add({staticLabel:"Inside Radius:"});                        staticTexts.add({staticLabel:"Outside Radius:"});                        staticTexts.add({staticLabel:"Offset:"});                    }                    with (dialogColumns.add()){                        var myRegMarkInnerRadiusField = measurementEditboxes.add({editValue:2, editUnits:MeasurementUnits.points});                        var myRegMarkOuterRadiusField = measurementEditboxes.add({editValue:4,editUnits:MeasurementUnits.points});                        var myRegMarkOffsetField = measurementEditboxes.add({editValue:3, editUnits:MeasurementUnits.points});                    }                }            }            with(borderPanels.add()){                staticTexts.add({staticLabel:"Draw Marks Around:"});                var myRangeButtons = radiobuttonGroups.add();                with(myRangeButtons){                    radiobuttonControls.add({staticLabel:"Each Object", checkedState:true});                    radiobuttonControls.add({staticLabel:"Entire Selection"});                }            }        }    }    var myReturn = myDialog.show();    if (myReturn == true){        //Get the values from the dialog box.        var myDoCropMarks = myCropMarksGroup.checkedState;        var myDoRegMarks = myRegMarksGroup.checkedState;        var myCropMarkLength = myCropMarkLengthField.editValue;        var myCropMarkOffset = myCropMarkOffsetField.editValue;        var myCropMarkWidth = myCropMarkWidthField.editValue;        var myRegMarkInnerRadius = myRegMarkInnerRadiusField.editValue;        var myRegMarkOuterRadius = myRegMarkOuterRadiusField.editValue;        var myRegMarkOffset = myRegMarkOffsetField.editValue;        var myRange = myRangeButtons.selectedButton;        myDialog.destroy();        //"||" is logical OR in JavaScript.        if ((myDoCropMarks != false) || (myDoRegMarks != false)){            myDrawPrintersMarks(myRange, myDoCropMarks, myDoRegMarks, myCropMarkLength, myCropMarkOffset, myCropMarkWidth, myRegMarkInnerRadius, myRegMarkOuterRadius, myRegMarkOffset);        }        else{            alert("No printers marks were selected.");        }    }    else{        myDialog.destroy();    }
}
function myDrawPrintersMarks(myRange, myDoCropMarks, myDoRegMarks, myCropMarkLength, myCropMarkOffset, myCropMarkWidth, myRegMarkInnerRadius, myRegMarkOuterRadius, myRegMarkOffset){    var myBounds, myX1, myY1, myX2, myY2, myObject;    var myDocument = app.activeDocument;    var myOldRulerOrigin = myDocument.viewPreferences.rulerOrigin;    myDocument.viewPreferences.rulerOrigin = RulerOrigin.spreadOrigin;    //Save the current measurement units.    var myOldXUnits = myDocument.viewPreferences.horizontalMeasurementUnits;    var myOldYUnits = myDocument.viewPreferences.verticalMeasurementUnits;    //Set the measurement units to points.    myDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.points;    myDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.points;    //Create a layer to hold the printers marks (if it does not already exist).    var myLayer = myDocument.layers.item("myCropMarks");    try{        myLayerName = myLayer.name;    }    catch (myError){        var myLayer = myDocument.layers.add({name:"myCropMarks"});    }    //Get references to the Registration color and the None swatch.    var myRegistrationColor = myDocument.colors.item("Registration");    var myNoneSwatch = myDocument.swatches.item("None");    //Process the objects in the selection.           myBounds = myDocument.selection[0].visibleBounds;    for(var myCounter = 0; myCounter < myDocument.selection.length; myCounter ++){        myObject = myDocument.selection[myCounter];        myBounds = myObject.visibleBounds;        //Set up some initial bounding box values.        if ((myRange != 0)&&(myCounter==0)){            myX1 = myBounds[1];            myY1 = myBounds[0];            myX2 = myBounds[3];            myY2 = myBounds[2];        }        if(myRange == 0){            if (myDoCropMarks == true){                myDrawCropMarks (myBounds[1], myBounds[0], myBounds[3], myBounds[2], myCropMarkLength, myCropMarkOffset, myCropMarkWidth, myRegistrationColor, myNoneSwatch, myLayer);            }            if (myDoRegMarks == true){                myDrawRegMarks (myBounds[1], myBounds[0], myBounds[3], myBounds[2], myRegMarkOffset, myRegMarkInnerRadius, myRegMarkOuterRadius, myCropMarkWidth,myRegistrationColor, myNoneSwatch, myLayer);            }        }        else{            //Compare the bounds values to the stored bounds.            //If a given bounds value is less than (for x1 and y1) or            //greater than (for x2 and y2) the stored value,            //then replace the stored value with the bounds value.            if (myBounds[0] < myY1){                myY1 = myBounds[0];            }            if (myBounds[1] < myX1){                myX1 = myBounds[1];            }            if (myBounds[2] > myY2){                myY2 = myBounds[2];            }            if (myBounds[3] > myX2){                myX2 = myBounds[3];            }        }    }    if(myRange != 0){        if (myDoCropMarks == true){            myDrawCropMarks (myX1, myY1, myX2, myY2, myCropMarkLength, myCropMarkOffset, myCropMarkWidth,myRegistrationColor, myNoneSwatch, myLayer);        }        if (myDoRegMarks == true){            myDrawRegMarks (myX1, myY1, myX2, myY2, myRegMarkOffset, myRegMarkInnerRadius, myRegMarkOuterRadius, myCropMarkWidth, myRegistrationColor, myNoneSwatch, myLayer);        }    }    myDocument.viewPreferences.rulerOrigin = myOldRulerOrigin;    //Set the measurement units back to their original state.    myDocument.viewPreferences.horizontalMeasurementUnits = myOldXUnits;    myDocument.viewPreferences.verticalMeasurementUnits = myOldYUnits;
}
function myDrawCropMarks (myX1, myY1, myX2, myY2, myCropMarkLength, myCropMarkOffset, myCropMarkWidth, myRegistrationColor, myNoneSwatch, myLayer){    //Upper left crop mark pair.    myDrawLine([myY1, myX1-myCropMarkOffset, myY1, myX1-(myCropMarkOffset + myCropMarkLength)], myCropMarkWidth, myRegistrationColor, myNoneSwatch, myLayer);    myDrawLine([myY1-myCropMarkOffset, myX1, myY1-(myCropMarkOffset+myCropMarkLength), myX1], myCropMarkWidth, myRegistrationColor, myNoneSwatch, myLayer);    //Lower left crop mark pair.    myDrawLine([myY2, myX1-myCropMarkOffset, myY2, myX1-(myCropMarkOffset+myCropMarkLength)], myCropMarkWidth, myRegistrationColor, myNoneSwatch, myLayer);    myDrawLine([myY2+myCropMarkOffset, myX1, myY2+myCropMarkOffset+myCropMarkLength, myX1], myCropMarkWidth, myRegistrationColor, myNoneSwatch, myLayer);    //Upper right crop mark pair.    myDrawLine([myY1, myX2+myCropMarkOffset, myY1, myX2+myCropMarkOffset+myCropMarkLength], myCropMarkWidth, myRegistrationColor, myNoneSwatch, myLayer);    myDrawLine([myY1-myCropMarkOffset, myX2, myY1-(myCropMarkOffset+myCropMarkLength), myX2], myCropMarkWidth, myRegistrationColor, myNoneSwatch, myLayer);    //Lower left crop mark pair.    myDrawLine([myY2, myX2+myCropMarkOffset, myY2, myX2+myCropMarkOffset+myCropMarkLength], myCropMarkWidth, myRegistrationColor, myNoneSwatch, myLayer);    myDrawLine([myY2+myCropMarkOffset, myX2, myY2+myCropMarkOffset+myCropMarkLength, myX2], myCropMarkWidth, myRegistrationColor, myNoneSwatch, myLayer);
}

function myDrawRegMarks (myX1, myY1, myX2, myY2, myRegMarkOffset, myRegMarkInnerRadius, myRegMarkOuterRadius, myCropMarkWidth, myRegistrationColor, myNoneSwatch, myLayer){
    var myBounds    var myXCenter = myX1 + ((myX2 - myX1)/2);    var myYCenter = myY1 + ((myY2 - myY1)/2);    var myTargetCenter = myRegMarkOffset+(myRegMarkOuterRadius);    //Top registration target.    myBounds = [myY1-(myTargetCenter+myRegMarkInnerRadius), myXCenter-myRegMarkInnerRadius, (myY1-myTargetCenter)+myRegMarkInnerRadius, myXCenter + myRegMarkInnerRadius];    myDrawTarget(myBounds, myCropMarkWidth, myRegistrationColor, myNoneSwatch, myLayer);    myBounds = [myY1-(myTargetCenter+myRegMarkOuterRadius), myXCenter, (myY1-myTargetCenter)+myRegMarkOuterRadius, myXCenter]    myDrawLine(myBounds, myCropMarkWidth, myRegistrationColor, myNoneSwatch, myLayer);    myBounds = [myY1-myTargetCenter, myXCenter-myRegMarkOuterRadius, myY1-myTargetCenter, myXCenter+myRegMarkOuterRadius]    myDrawLine(myBounds, myCropMarkWidth, myRegistrationColor, myNoneSwatch, myLayer);    //Left registration target.    myBounds = [myYCenter-myRegMarkInnerRadius, myX1-(myTargetCenter+myRegMarkInnerRadius), myYCenter+myRegMarkInnerRadius, (myX1 - myTargetCenter) + myRegMarkInnerRadius];    myDrawTarget(myBounds, myCropMarkWidth, myRegistrationColor, myNoneSwatch, myLayer);    myBounds = [myYCenter, myX1-(myTargetCenter+myRegMarkOuterRadius), myYCenter, myX1 -myRegMarkOffset]    myDrawLine(myBounds, myCropMarkWidth, myRegistrationColor, myNoneSwatch, myLayer);    myBounds = [myYCenter-myRegMarkOuterRadius, myX1-myTargetCenter, myYCenter+myRegMarkOuterRadius, myX1-myTargetCenter]    myDrawLine(myBounds, myCropMarkWidth, myRegistrationColor, myNoneSwatch, myLayer);    //Bottom registration target.    myBounds = [myY2+(myTargetCenter-myRegMarkInnerRadius), myXCenter-myRegMarkInnerRadius, myY2+ myTargetCenter+myRegMarkInnerRadius, myXCenter + myRegMarkInnerRadius];    myDrawTarget(myBounds, myCropMarkWidth, myRegistrationColor, myNoneSwatch, myLayer);    myBounds = [myY2+myRegMarkOffset, myXCenter, myY2+myTargetCenter+myRegMarkOuterRadius, myXCenter]    myDrawLine(myBounds, myCropMarkWidth, myRegistrationColor, myNoneSwatch, myLayer);    myBounds = [myY2+myTargetCenter, myXCenter-myRegMarkOuterRadius, myY2 + myTargetCenter, myXCenter+myRegMarkOuterRadius]    myDrawLine(myBounds, myCropMarkWidth, myRegistrationColor, myNoneSwatch, myLayer);    //Right registration target.    myBounds = [myYCenter-myRegMarkInnerRadius, myX2+(myTargetCenter-myRegMarkInnerRadius), myYCenter+myRegMarkInnerRadius, myX2 + myTargetCenter + myRegMarkInnerRadius];    myDrawTarget(myBounds, myCropMarkWidth, myRegistrationColor, myNoneSwatch, myLayer);    myBounds = [myYCenter, myX2+myRegMarkOffset, myYCenter, myX2+myTargetCenter+myRegMarkOuterRadius]    myDrawLine(myBounds, myCropMarkWidth, myRegistrationColor, myNoneSwatch, myLayer);    myBounds = [myYCenter-myRegMarkOuterRadius, myX2+myTargetCenter, myYCenter+myRegMarkOuterRadius, myX2+myTargetCenter]    myDrawLine(myBounds, myCropMarkWidth, myRegistrationColor, myNoneSwatch, myLayer);

}
function myDrawLine(myBounds, myStrokeWeight, myRegistrationColor, myNoneSwatch, myLayer){
    app.activeWindow.activeSpread.graphicLines.add(myLayer, undefined, undefined,{strokeWeight:myStrokeWeight, fillColor:myNoneSwatch, strokeColor:myRegistrationColor, geometricBounds:myBounds})
}
function myDrawTarget(myBounds, myStrokeWeight, myRegistrationColor, myNoneSwatch, myLayer){    app.activeWindow.activeSpread.ovals.add(myLayer, undefined, undefined, {strokeWeight:myStrokeWeight, fillColor:myNoneSwatch, strokeColor:myRegistrationColor, geometricBounds:myBounds})
}

Undo does not work with bridge talk

$
0
0

With script ui, by clicking the button.


I use bridge talk to run the script
I want to use the undo function in exception handling when an error occurs
I think that it is not working.

 

Does it not work within bridge talk?

 

I think whether to consider the whole processing at bridge talk as one operation
I tried undo in onclick after an error was returned
An error occurred without an app object.

 

Whichever method is impossible?

 

 clCreateBtn.onClick = function(){  var bt = new BridgeTalk();  bt.target = "Illustrator";  bt.body = uneval(illustratorCreateLayer) + "(" + args+ ")";   bt.onResult = function(res) {   var result = eval(res.body);   if(result == "1"){    alert("error");    undo();          // app error no object!!!    return;   }   alert("ok");  }  bt.send();
 }

 function illustratorCreateLayer(){
   var doc = activeDocument;  try{     // etc process  }catch(e){   undo();           // not working!!!   return "1";  }  return "0";
 }

 

line at 11or25.

Please tell me if there is a solution.

Best regard.

I'm already tired of seeing [an Illustrator error occurred: 1346458189 ('PARM')]

$
0
0

In response to this error, you can hide the window with the tab key,

In exception processing, you can reopen the file

Although we have made various correspondences, this error still occurs.

 

I am tired anymore.

 

As for the bug of this illustrator, is there still any response from the official?

Clearly, this error is often encountered.

 

I am trying to automate various batches and script ui etc

Due to this mysterious error, the burden of correspondence here is too much.

 

How is everyone responding about this bug?

 

My environment is below.

Windows 8.1 64bit

illustrator CC 2014

Javascript

 

Is not it coming out with the latest CC 2017?

If you can guarantee that the existing part is not affected just by adding the function

I'd like to update it ...

Because I use it in business, I can not update it if I can not guarantee it.

 

Best regard.

script to move and copy an object with opacity mask

$
0
0

I have script which can help me to move and copy an object, but I just found that it can not copy the object with opacity mask.

it is there anyone have any idea to solve this problem.

maybe we can used adobe action, but it only can copy 1 time, however, usually  we need copy more than 10 times..

 

function dup(sel,item,qty,tran1,tran2){   for (var i=0; i<[qty]; i++){   sel[item].duplicate();   sel[item].translate(tran1,tran2);   }

Is there a way to batch rename artboards in Illustrator CC?

$
0
0

Is there a way to batch rename artboards in Illustrator CC?

I have 20 different artbords that i want to rename with a specific name and number!

/Pål

Saving non-Anti-Aliased PNGs from Illustrator

$
0
0

We have many EPS files which we want to process into very precise bitmap formats.

 

I have a square artboard (and man, was generating that automatically a scripting exercise far in advance of how complex it should be...) that I would like to export with no anti-aliasing.

 

Doing this via File-->Export-->Save For Web (Legacy) generates a correctly non-anti aliased bitmap provided that you set the anti-aliasing dropdown to "none".

 

Doing the same thing by seting pngExportOptions.antiAliasing to false, then calling doc.exportFile demonstrably produces an anti-aliased image.

 

You can waste more time by messing around with ExportOptionsTIFF in the misguided belief that it's "AntiAliasingMethod.None" might do the trick. It doesn't appear to do anything either.

 

There is, of course, an unanswered, 2 year old question about this as the top hit on google.

 

Side note, we have experimented for some time over the past years with using the "professional" tools photoshop and illustrator to handle our scripted bitmap and vector image processing, instead of using ghostscript, pyimage, imagemagick, etc, and I have to conclude that their scripting support is just a complete joke.

 

What am I missing, aside from the fact that I'm wasting my time trying to use a "professional" solution?

Erzeugung PDF mit individuellen Eigenschaften - Code - VBA

$
0
0

Hallo,

 

ich bin dabei mit VBA-Code über Excel eine PDF Datei zu erzeugen. Über den angefügten Code ist es mir möglich beim öffnen die Lesezeichen/Bookmarks anzeigen zu lassen.

Allerdings verzweifel ich bei zusätzlichen Eigenschaften. Ich weiß zwar wie ich die PDF doppelseitig abspeicher, allerdings nützt es mir nichts, weil ich ja immer wieder eine neue erzeuge. Ich bräuchte hier also einen gleichwertigen Code wie mein angefügter. Zudem soll automatisch das Menü nicht angezeigt werden. Auch hier habe ich keine passende Funktion gefunden. Der VBA Code ist optional, ich würde mich ebenfalls über Lösungen freuen, die mit anderen Sprachen oder Programmen geschrieben sind. Wichtig ist nur, dass der Prozess in der Erzeugung der PDF-Datei mit eingebunden werden kann.  Eine ausführliche Lösung wäre dann hilfreich weil ich die Objekt-Erzeugung eines Adobe Dokument bisher nur mit Vba hatte.

 

Sub propbs()

 

Dim AVDocu As Object

Dim strArgument2 As String

 

Set gApp = CreateObject("AcroExch.app")

Set AVDocu = CreateObject("AcroExch.AVDoc")

Set PDDocu = CreateObject("AcroExch.PDDoc")

 

strArgument2 = ("C:\Datei.pdf")

AVDocu.Open strArgument2, strArgument2

Set PDDocu = AVDocu.GetPDDoc

PDDocu.SetPageMode (3)

PDDocu.SetView (1)

 

savFull = PDDocu.Save(1, "C:\Datei.pdf")

 

AVDocu.Close (True)

gApp.Exit

Set AcroApp = Nothing

Set AVDocu = Nothing

Set gApp = Nothing

End Sub


Batch Processing a Find Font in Document

$
0
0

I am wanting to have a script that will look in a folder/directory and...

 

- Open each .pdf file in that directory one at a time and do the following

     - Find Font in Document

          - Arial

     - Replace With Font From System

          - Courier New

- Save the file with default Illustrator PDF save settings in same location (in other words I don't need it to be saved as another file)

 

I would love to do this with minimal or no interaction from the user.

 

Any ideas if this is possible? Keeping in mind that each file will have 1,000's of text frames with the Arial font that need to be changed to Courier New.

 

Any help would be greatly appreciated!

Accessing font information through script

$
0
0

For some reason I have the hardest time finding good Documentation on building Adobe extensions. All I am trying to do is access the available fonts for the user in illustrator, and have a way to let them know if they are from google fonts or not. any links to docs about access font information and working with the font picker?

app.redo() and app.redraw() delete manually operated Polygon object's undo history

$
0
0

Hi all,

 

On Illustrator CC 2017, there's some particular case become blocker.

I'm trying to work around path.

 

If there's anything I'm missing, please let me know.

I appropriate any feed backs.

 

Issue:

 

Manually operated Undo history got over written at following operation in script.

1) It is only Polygon object

  All other object seems fine.

 

2) Undo history is by only manual operation

  ex1) Placing Polygon object 10 time by mouse causes issue.

  ex2) Placing Polygon object 10 time by script does not causes issue.

 

3) Redo issue is by only scripting

Illustrator UI works fine.

 

4) app.redraw() is actual trigger to delete undo history

  If it is called from CEP plugin CSInterface.evalScript(), it seems has same issue.

  My target environment is CEP plugin.

 

Test code

#target illustrator

 

 

 

// open document before run

 

 

 

/*

// Following script operation works, but manual placing polygons have issue.

// Place 10 polygon (Hexagon)

for(var i = 0; i < 10; i++){

    $.writeln("polygon: " + i);

    var a = 100 + i * 20;

    activeDocument.pathItems.polygon(a, -a, 10, 6);  // Hexagon

    app.redraw();

    $.sleep(1000);

}

*/

 

 

 

for(var i = 0; i < 5; i++){

    app.undo();

    $.writeln("undo:" + i);

    app.redraw();  // no change

    $.sleep(1000);

}

 

 

 

app.redraw();

 

 

 

 

 

for(var i = 0; i < 5; i++){ // Only first redo works

    app.redo();

    // app.executeMenuCommand("redo"); // same behavior

    $.writeln("redo:" + i);

    app.redraw(); // problem on Polygon redo // commenting out works, but document view won't be updated

    $.sleep(1000);

 

}

 

 

 

app.redraw();

 

Thank you,

Naoki

Make/Release Clipping Mask via Script

$
0
0

Hi, y'all

 

There is a way to reach the command "Make/Release Clipping Mask" in the Layer window via script?

 

What I'm trying to achieve is to create a rectangle using the size of my artboard, name it "CLIP", put it on the top of my active Layer and set it as my mask.

 

Example bellow:

clip.PNG

 

Any help will be appreciated.

how to get a specific function to repeat through all artboards in a document?

$
0
0

Greetings,

 

with my limited knowledge I've made (or rather clumsily hacked together) a script that I use for exporting proof pdf's from illustrator that will simply draw a rectangle with a thin stroke around my document and save a pdf, then delete the rectangle and resave the .AI file (this last part is just to speed things up, so I can keep working on my ai file afterwards).

 

This all works perfectly fine on a document with only one artboard, however the whole thing falls apart if I want to make a multipage pdf with more than one artboards.
I need it to do the same actions but instead of just drawing the rectangle once I want it to draw it around every artboard in my document.
I realise this is probably easily achieved by looping through my artboards I just don't know how to go about it.

 

I've included the script I'm using in full below, it probably has quite a few redundant bits here or there, but hopefully you can make sense of it 

 

 

 

var idoc = app.activeDocument; 
var width = idoc.width;
var height = idoc.height;
newCMYKColor = new CMYKColor;
newCMYKColor.black = 100;
newCMYKColor.cyan = 0;
newCMYKColor.magenta = 0;
newCMYKColor.yellow = 0;   
var CurrentPath = activeDocument.path;
var folderPDF = Folder(CurrentPath);
if(!folderPDF.exists) folderPDF.create();

var docName = app.activeDocument.name.match(/^.*[^.ai]/i);
var myDoc = app.activeDocument.name.match();


        if (folderPDF) {            if ( app.documents.length > 0 ) {                var destFile = new File(folderPDF + '/' + docName + "_HR");                var sourceDoc = app.activeDocument;                               targetFile = getNewName();                targetFileAI = getNewNameAI();                pdfSaveOpts = getPDFOptions( );                illustratorSaveOpts = getAIOptions();                   var rectangle = idoc.pathItems.rectangle(0, 0, width, height);                rectangle.filled = false;                rectangle.strokeColor = newCMYKColor;                rectangle.strokeWidth = 1;                sourceDoc.saveAs( targetFile, pdfSaveOpts );                rectangle.remove()                    sourceDoc.saveAs( targetFileAI, illustratorSaveOpts );                               }            }       



function getNewName()
{
    var ext, docName, newName, saveInFile, docName;    docName = sourceDoc.name;    ext = '_HR_CMYK_PROOF_nobleed.pdf';    newName = "";           for ( var i = 0 ; docName[i] != "." ; i++ )    {        newName += docName[i];    }    newName += ext;    saveInFile = new File( folderPDF + '/' + newName );       return saveInFile;
}


function getNewNameAI()
{

    saveInFileAI = new File( folderPDF + '/' + sourceDoc.name );    return saveInFileAI;
}

function getPDFOptions()
{

    var pdfSaveOpts = new PDFSaveOptions();    pdfSaveOpts.pDFPreset = "Inferno Print File (no bleed)";    return pdfSaveOpts;
}


function getAIOptions()
{
    var illustratorSaveOpts = new IllustratorSaveOptions();    illustratorSaveOpts.pdfCompatible = false;    return illustratorSaveOpts;

}
Viewing all 3671 articles
Browse latest View live


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