Quantcast
Channel: Adobe Community : Popular Discussions - Illustrator Scripting
Viewing all 12845 articles
Browse latest View live

A list of Illustrator menu commands we can call from JavaScript.

$
0
0

app.executeMenuCommand(StringFromListBelow); 


actualsize

Add Anchor Points2

AddArrowHeads2

Adjust Colors Dialog

Adjust3

Adobe Action Palette

Adobe Actions Batch

Adobe AI Device center

Adobe AI Save For Web

Adobe Apply Last Effect

Adobe Art Style Plugin Other libraries menu item

Adobe Bridge Browse

Adobe BrushManager Menu Item

Adobe Color Palette

Adobe Color Palette Secondary

Adobe Default Workspace

Adobe Flattening Preview

Adobe Gradient Palette

Adobe Harmony Palette

Adobe Illustrator Find Font Menu Item

Adobe Illustrator Smart Punctuation Menu Item

Adobe Last Effect

Adobe LinkPalette Menu Item

Adobe Manage Workspace

Adobe Minimal Workspace

Adobe New Fill Shortcut

Adobe New Stroke Shortcut

Adobe New Style Shortcut

Adobe New Swatch Shortcut Menu

Adobe New Symbol Shortcut

Adobe Optical Alignment Item

Adobe Paragraph Styles Palette

Adobe Save a Version

Adobe Save Workspace

Adobe Stroke Palette

Adobe Style Palette

Adobe SVG Interactivity Palette

Adobe Swatches Menu Item

Adobe Symbol Palette

Adobe Symbol Palette Plugin Other libraries menu item

Adobe Transparency Palette Menu Item

Adobe Update Link Shortcut

Adobe Variables Palette Menu Item

AdobeAlignObjects2

AdobeBrushMgr Other libraries menu item

AdobeBuiltInToolbox1

AdobeCheatSheetMenu

AdobeLayerPalette1

AdobeLayerPalette2

AdobeLayerPalette3

AdobeNavigator1

AdobeNavigator2

AdobePathfinderPalette1

AdobeSwatch_ Other libraries menu item

AdobeTransformObjects1

AI Bounding Box Toggle

AI Magic Wand

AI Object Mosaic Plug-in3

AI Place

AI Reset Bounding Box

ai_browse_for_script

AISlice Clip to Artboard

AISlice Combine

AISlice Create from Guides

AISlice Create from Selection

AISlice Delete All Slices

AISlice Divide

AISlice Duplicate

AISlice Feedback Menu

AISlice Lock Menu

AISlice Make Slice

AISlice Release Slice

AISlice Slice Options

alternate glyph palette plugin

alternate glyph palette plugin 2

Appearance of Black 1

Apply Last Filter

areatextoptions

arrangeicon

artboard

assignprofile

average

avgAndJoin

bringAllToFront

Brush Strokes menu item

cascade

centerAlign

Character Styles

Check Spelling

cleanup menu item

clear

clearguide

clearTrack

clearTypeScale

Clipping Masks menu item

close

closeAll

color

Colors3

Colors4

Colors5

Colors6

Colors7

Colors8

Colors9

compoundPath

control palette plugin

convertlegacyText

convertlegacyText1

convertlegacyText2

convertlegacyText3

convertlegacyText4

copy

Create Envelope Grid

cut

Define Pattern Menu Item

deselectall

discretHyphen

Distort2

doc-color-cmyk

doc-color-rgb

DocInfo1

document

DropShadow2

Dynamic Text

edge

Edit Custom Dictionary...

Edit Envelope Contents

editGraphData

editMask

EditOriginal Menu Item

editview

enterFocus

Envelope Options

exitFocus

Expand as Viewed

Expand Envelope

Expand Planet X

Expand Tracing

Expand3

expandStyle

export

faceSizeDown

faceSizeUp

File Handling & Clipboard 1

File Info

Find and Replace

Find Blending Mode menu item

Find Fill & Stroke menu item

Find Fill Color menu item

Find Link Block Series menu item

Find Next

Find Opacity menu item

Find Reselect menu item

Find Stroke Color menu item

Find Stroke Weight menu item

Find Style menu item

Find Symbol Instance menu item

fitall

fitHeadline

fitin

Flash Text

FlattenTransparency1

Gradient Feedback

graphDesigns

group

guidegridPref

helpcontent

hide

hide2

hideApp

hideOthers

highlightFont

highlightFont2

hyphenPref

ink

Input Text

internal palettes posing as plug-in menus-attributes

internal palettes posing as plug-in menus-character

internal palettes posing as plug-in menus-info

internal palettes posing as plug-in menus-opentype

internal palettes posing as plug-in menus-paragraph

internal palettes posing as plug-in menus-tab

Inverse menu item

join

justify

justifyAll

justifyCenter

justifyRight

KBSC Menu Item

keyboardPref

Knife Tool2

Last Filter

leftAlign

Live 3DExtrude

Live 3DRevolve

Live 3DRotate

Live AddArrowHeads2

Live Color Dialog

Live Deform Arc

Live Deform Arc Lower

Live Deform Arc Upper

Live Deform Arch

Live Deform Bulge

Live Deform Fish

Live Deform Fisheye

Live Deform Flag

Live Deform Inflate

Live Deform Rise

Live Deform Shell Lower

Live Deform Shell Upper

Live Deform Squeeze

Live Deform Twist

Live Deform Wave

Live DropShadow2

Live Ellipse

Live Feather

Live Free Distort

Live Inner Glow

Live Offset Path

Live Outer Glow

Live Outline Object

Live Outline Stroke

Live Pathfinder Add

Live Pathfinder Crop

Live Pathfinder Divide

Live Pathfinder Exclude

Live Pathfinder Hard Mix

Live Pathfinder Intersect

Live Pathfinder Merge

Live Pathfinder Minus Back

Live Pathfinder Outline

Live Pathfinder Soft Mix

Live Pathfinder Subtract

Live Pathfinder Trap

Live Pathfinder Trim

Live Pucker & Bloat

Live Rasterize

Live Rasterize Effect Setting

Live Rectangle

Live Roughen

Live Round3

Live Rounded Rectangle

Live Scribble and Tweak

Live Scribble Fill

Live Transform

Live Twist

Live Zig Zag

lock

lock2

lockguide

LowerCase Change Case Item

Make and Convert to Live Paint

Make and Expand

Make Envelope

make mesh

Make Planet X

Make Text Wrap

Make Tracing

Make Warp

makeguide

makeMask

Marge Planet X

minimizeWindow

navigateToNextDocument

navigateToNextDocumentGroup

navigateToPreviousDocument

navigateToPreviousDocumentGroup

new

newFromTemplate

newview

newwindow

noCompoundPath

OffsetPath2

OffsetPath3

open

outline

Overprint2

pagetiling

Paint Tracing

paste

pasteBack

pasteFront

pasteInAllArtboard

pasteInPlace

PathBlend Expand

PathBlend Make

PathBlend Options

PathBlendRelease

PathBlend Replace Spine

PathBlend Reverse Spine

PathBlend Reverse Stack

PDF Presets

Planet X Options

pluginPref

preference

preview

Print

Print Presets

proofColors

proof-custom

proof-document

proof-mac-rgb

proof-monitor-rgb

proof-win-rgb

Punk2

quit

raster

Rasterize 8 menu item

redo

Registration...

Release Envelope

Release Planet X

Release Text Wrap

Release Tracing

releaseCropMarks

releaseguide

releaseMask

releaseThreadedTextSelection

Remove Anchor Points menu

removeThreading

repeatPathfinder

Replace Colors Dialog

revert

rightAlign

Roughen3

Round3

Rows and Columns....

ruler

rulerCoordinateSystem

Saturate3

save

Save for Office

saveacopy

saveas

saveasTemplate

Scribble3

selectall

selectallinartboard

Selection Hat 1

Selection Hat 10

Selection Hat 11

Selection Hat 2

Selection Hat 3

Selection Hat 4

Selection Hat 5

Selection Hat 6

Selection Hat 7

Selection Hat 8

Selection Hat 9

selectionPref

sendBackward

sendForward

sendToBack

sendToFront

Sentence case Change Case Item

setBarDesign

setCropMarks

setGraphStyle

setIconDesign

Show Gaps Planet X

Show Perspective Grid

Show Preprocessed Image

showAll

showAllWindows

ShowArtwork

showgrid

showguide

showHiddenChar

ShowNoArtwork

ShowNoImage

ShowOriginalImage

ShowPaths

ShowPathsAndTransparentArtwork

showtemplate

ShowTransparentImage

simplify menu item

sizeStepDown

sizeStepUp

snapgrid

Snapomatic on-off menu item

snappoint

snapPref

spacing

Stray Points menu item

Style Palette

SWFPresets

switchSelTool

switchUnits

systemInfo

Text Objects menu item

Text Wrap Options...

textpathtype3d

textpathtypeGravity

textpathtypeOptions

textpathtypeRainbow

textpathtypeSkew

textpathtypestairs

textthreads

threadTextCreate

tile

Title Case Change Case Item

toggleAutoHyphen

toggleLineComposer

Tracing Options

TracingPresets

tracking

Transform3

transformagain

transformmove

transformreflect

transformrotate

transformscale

transformshear

Transparency Presets

TransparencyGrid Menu Item

TrimMark2

Twirl Tool2

type-horizontal

type-vertical

undo

ungroup

unitundoPref

unlockAll

UpperCase Change Case Item

userInterfacePref

view1

view10

view2

view3

view4

view5

view6

view7

view8

view9

Welcome screen menu item

ZigZag2

zoomin

zoomin2

zoomout


Saving documents via Scripts: Get current file name and set save path/file type

$
0
0

I am writing a script that will:

 

-Make all layers invisible

-Make a layer named "background" visible

-Delete all the invisible layers

-Save the docment as an EPS file (leaving the original document untouched)

 

I am new to scripts and so have based my script by copying code from other scripts.

 

Here is my code:

 

var doc = app.activeDocument;

var name = doc.name;

 

 

var hide = function (){ // hide all layers (based on http://forums.adobe.com/thread/644267)

     var L=doc.layers.length;

     for (j=0;j<L;j++){  doc.layers[j].visible=false; }

}

hide();

 

 

// loop through all layers

for (var i = 0; i < doc.layers.length; i++) {

 

 

 

 

 

              // Create the illusrtratorSaveOptions object to set the AI options

    var saveOpts = new IllustratorSaveOptions();

 

    // Setting IllustratorSaveOptions properties.

    saveOpts.embedLinkedFiles = true;

    saveOpts.fontSubsetThreshold = 0.0

    saveOpts.pdfCompatible = true

 

 

 

 

 

 

//Set up Variable to access layer name

          var currentLayer = app.activeDocument.layers[i];

 

// Loop through the layers and make the back ground layer visible

          if (currentLayer.name == "Background") {

                    docName = name + currentLayer.name+".eps";

                    currentLayer.visible = true;

                    }

 

 

}

 

 

// Delete Invisible Layers (based on http://www.cartotalk.com/index.php?showtopic=7491)

var myDoc=app.activeDocument;

var layerCount=myDoc.layers.length;

for (var ii = layerCount - 1; ii >= 0; ii--) {

    var currentLayer = myDoc.layers[ii];

    currentLayer.locked = false;

    var subCount = currentLayer.layers.length;

    for (var ss =subCount -1; ss >= 0; ss--){

        var subLayer = currentLayer.layers[ss];

        subLayer.locked = false;

        if (subLayer.visible == false){

            subLayer.visible = true;

            subLayer.remove();

            }

        }

    if (currentLayer.visible == false){

        currentLayer.visible = true;

        currentLayer.remove();

        }

    }

 

// Save Out Document with New Name

 

var saveName = new File ( doc.path + "/" + docName );

doc.saveAs( saveName, saveOpts );

 

 

 

Everything works fine except:

1) It saves the document with the name AdobeIllustratorBackground as opposed to the name of the document

 

Also, I am not sure how to tell the script to save as EPS and to specify the save location.

 

Could some one give me some pointers?          Thanks!

getSelected() returns pageItem's strokeColor or fillColor but not both

$
0
0

Hi All,

 

I'm having trouble writing a script to tell me which swatches are used in the active document and I think the problem comes down to the Swatches method getSelected(), see code below. I'm storing a list of all the pageItems and the swatches in the activeDocument. Then I select each pageItem and use getSelected which should return an array of swatches for my selection. However I've noticed it only returns the strokeColor or fillColor of the pathItems for example. Is there a way to fix this? Any help would be greatly appreciated

 

var _pageItems = app.activeDocument.pageItems;
var _pageItemsLength = _pageItems.length;
if (_pageItemsLength > 0)
{  var _placedItemFileSwatches = app.activeDocument.swatches;  for (var i = 0; i < _pageItemsLength; i++)  {    _pageItems[i].layer.visible = true;    if (_pageItems[i].name != "")    {      app.activeDocument.selection = [_pageItems[i]];      var _selectedSwatches = _placedItemFileSwatches.getSelected();      var _selectedSwatchesLength = _selectedSwatches.length;      for (var j = 0; j < _selectedSwatchesLength; j++)      {        if (_selectedSwatches[j] != "")        {          alert("Swatch '{0}' is assigned to pageItem '{1}'".fmt(_selectedSwatches[j].name, _pageItems[i].name) );        }      }    }  }
}

Anti-aliasing Type Optimized/Art Optimized on PNG export

$
0
0

Hello there,

 

I'm modifying a javascript that makes an export of each layer contained in an Illustrator document and I want to specify the method used for anti-aliasing (either Type Optimized or Art Optimized). Similarly to the option under the "Image size" tab in the "Save for the Web" panel.

 

I didn't find any antiAliasingMethod property in the ExportOptionsPNG24 properties (only an antiAliasing property that accepts boolean). So I wonder if it is actually possible to do it through scripting?

 

Many thanks,

D

Does anybody have a script for resizing objects to round numbers?

$
0
0

I have a halftone from Phantasm but I need each dot to be a round number, ie 3mm, not 3.452mm. I've found scripts for rounding text sizes but I've been unsuccessful in adapting them to resizing multiple objects at once.

 

Does anybody have a solution?

Thanks

Applescript - return value from 'do Javascript'

$
0
0

I'm running a javascript via Applescript, and I want to return a value back to the calling applescript. When I try the following test:

 

tell application "Adobe Illustrator"

set theScript to "return 'Test';"

set theResult to do Javascript theScript

end tell

 

I get a message "'Illegal 'return' outside of a function body".

 

Is there a way to return a value back to the applescript?

How to divide all textFrames in one-character-per-textFrame?

$
0
0

Hello:

 

How to divide all textFrames in one-character-per-textFrame?

 

Example: the textFrame "Letters" will be divided in 7 textFrames: "L", "e", "t", "t", "e", "r", "s".

 

Help, please.

Selecting objects by fill color

$
0
0

Hi guys

Is possible to select objects by color in CMYK using JavaScript?

All I want to group several objects with the same fill color.

 

Many thanks for your time...

 

Please see the picture bellow...

 

2.jpg


Split Text into Layers

$
0
0

I was wondering if anyone is aware of a script that is able to do the same as this photoshop one http://www.agasyanc.ru/text-splitter, I would use that one in photoshop but its not working in CS6.

 

I  was hoping to find a script that will seperate the text into layers  ready for export to After Effects to be used in Kinetic Typography  pieces

 

thank you

Convert .ai to .doc

$
0
0

Hi,

 

Can it be possible to convert .ai file into .doc file or any tool which will do this conversion.

 

Thanks,

Shail

Illustrator Script - Export to PNG with options.

$
0
0

Hi everyone.

 

I would like some help on this script I currently have if anyone is able to.

 

What the script does - Exports multiple layers into single PNG images. Script is made with combination of scripts I've found over the net, and Actions I've composed.

 

What my problem is - PNG images are exported in low quality.

 

Basically, every image exported via this script is working fine, however the quality that it is exported into is much lower than that as you would export it manually via "File Export."

 

Can you help me with -the scripting code needed to implement so that the export quality is the same as you would do it manually?



Thank you for taking the time on this, I really appreciate any help and feed back.



-Arddy.


Resource - An extract of the code used to export is just below. This is the last part of my script and as I've said, I don't own this particular part it is something I found over the web.

 

   run_export: function() {

 

 

  var num_exported = 0;

  var options;

 

  if ( this.format =='PNG 8' ) {

     options = new ExportOptionsPNG8();

     options.antiAliasing = true;

     options.transparency = this.transparency;

     options.artBoardClipping = true;

     options.horizontalScale = this.scaling;

     options.verticalScale = this.scaling;   

           

  } else if ( this.format == 'PNG 24' ) {

     options = new ExportOptionsPNG24();

     options.antiAliasing = true;

     options.transparency = this.transparency;

     options.artBoardClipping = true;

     options.horizontalScale = this.scaling;

     options.verticalScale = this.scaling;   

    

  } else if ( this.format == 'PDF' ) {

            options = new PDFSaveOptions();

            options.compatibility = PDFCompatibility.ACROBAT5;

            options.generateThumbnails = true;

            options.preserveEditability = false;

    

  } else if ( this.format == 'JPG' ) {

     options = new ExportOptionsJPEG();

     options.antiAliasing = true;

     options.artBoardClipping = true;

     options.horizontalScale = this.scaling;

     options.verticalScale = this.scaling;   

    

  } else if ( this.format == 'EPS' ) {

            options = new EPSSaveOptions();

            options.embedLinkedFiles = true;

            options.includeDocumentThumbnails = true;

     options.saveMultipleArtboards = true;

  }

    

  var starting_artboard = 0;

  var num_artboards =  aDoc.artboards.length;

 

  if ( this.export_code == 'layers' ) {

     starting_artboard = aDoc.artboards.getActiveArtboardIndex();

     num_artboards = starting_artboard + 1;

  }

 

  for (var i = starting_artboard; i < num_artboards; i++ ) {

    

            var artboardName = aDoc.artboards[i].name;

            starting_artboard = aDoc.artboards.setActiveArtboardIndex(i);

    

            // Process this artbarod if we're exporting only a single one (layers mode) or if it doesn't have generic name or minus

            if ( this.export_code == 'layers' || ! ( artboardName.match(  /^artboard/i ) || artboardName.match( /^\-/ ) )) {

 

  // if exporting artboard by artboard, export layers as is

  if ( this.export_code == 'artboards' ) {

                   

     var base_filename = this.base_path + "/" + this.prefix + artboardName + this.suffix

 

 

     if ( this.format.match( /^PNG/ )) {               

  var destFile = new File( base_filename + '.png' );  

  var export_type = this.format == 'PNG 8' ? ExportType.PNG8 : ExportType.PNG24;

  aDoc.exportFile(destFile, export_type , options);

 

             } else if ( this.format.match( /^JPG/ )) {

                 var destFile = new File( base_filename + '.jpg' );  

                 var export_type = ExportType.JPEG;

                 aDoc.exportFile(destFile, export_type , options);

 

             } else if ( this.format.match( /^EPS/ )) {

 

 

  // dumb. specify a filename, saveAs saves as something else

  // so after we save it, we have to rename it to what we want.

  var eps_real_filename = base_filename + '_' + artboardName + '.eps'

 

                 var destFile = new File( base_filename + '.eps' );  

                 options.artboardRange = (i+1).toString();

                 aDoc.saveAs( destFile, options );

 

  var epsFile = new File ( eps_real_filename );

  if ( epsFile.exists ) {

     epsFile.copy( base_filename + '.eps'  );

                            epsFile.remove();

  }

 

     } else if ( this.format.match( /^PDF/ )) {

  var destFile = new File( base_filename + '.pdf' );  

  options.artboardRange = (i+1).toString();

  aDoc.saveAs( destFile, options )

     }      

                   

     // export layers as individual files

  } else if ( this.export_code == 'layers' || this.export_code = 'both' ) {

    

     for ( var j=0; j < aDoc.layers.length; j++ ) {

 

  this.hide_all_layers();

 

  var layer = aDoc.layers[j];

  var lyr_name = layer.name;

 

  if ( ! ( lyr_name.match( /^\+/ ) || lyr_name.match( /nyt_exporter_info/ ) || lyr_name.match( /^\-/) || lyr_name.match( /^Layer / ) )) {

    

     var base_filename;

    

     if ( this.export_code == 'layers' ) {

  base_filename = this.base_path + "/" + this.prefix + lyr_name + this.suffix

 

     } else if ( this.export_code == 'both' ) {

  base_filename = this.base_path + "/" + this.prefix + artboardName + '-' + lyr_name + this.suffix

 

 

     }

    

     layer.visible = true;

    

     if ( this.format.match( /^PNG/ )) {

  var destFile = new File( base_filename + '.png' );  

  var export_type = this.format == 'PNG 8' ? ExportType.PNG8 : ExportType.PNG24;

  aDoc.exportFile(destFile, export_type , options);

 

     } else if ( this.format.match( /^JPG/ )) {

  var destFile = new File( base_filename + '.jpg' );  

  var export_type = ExportType.JPEG;

  aDoc.exportFile(destFile, export_type , options);

 

     } else if ( this.format.match( /^EPS/ )) {

 

  var eps_real_filename = base_filename + '_' + artboardName + '.eps'

 

  var destFile = new File( base_filename + '.eps' );  

  options.artboardRange = (i+1).toString();

  aDoc.saveAs( destFile, options )

 

  var epsFile = new File ( eps_real_filename );

  if ( epsFile.exists ) {

     epsFile.copy( base_filename + '.eps'  );

     epsFile.remove();

    

  }

 

 

     } else if ( this.format.match( /^PDF/ )) {

  var destFile = new File( base_filename + '.pdf' );  

  options.artboardRange = (i+1).toString();

  aDoc.saveAs( destFile, options )

     }

    

     num_exported++;

    

     this.dlg.progLabel.text = 'Exported ' + num_exported + ' of ' + this.num_to_export;

     this.dlg.progBar.value = num_exported / this.num_to_export * 100;

    

     this.dlg.update();       

  }

 

     }

  }

     }

        }  

 

  this.prefs_xml.nyt_base_path    = this.base_path;

  this.prefs_xml.nyt_scaling      = this.scaling;

  this.prefs_xml.nyt_prefix       = this.prefix;

  this.prefs_xml.nyt_suffix       = this.suffix;

  this.prefs_xml.nyt_transparency = this.transparency;

  this.prefs_xml.nyt_format       = this.format;

  this.prefs_xml.nyt_export_code  = this.export_code;

   

  this.png_info_lyr.textFrames[0].contents = this.prefs_xml.toXMLString();

  this.dlg.close();

 

 

  //end run_export

    },

   

    hide_all_layers: function() {

  var export_count = 0;

 

  var n = aDoc.layers.length;

 

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

    

     layer = aDoc.layers[i];

    

     lyr_name = layer.name;

    

     // any layers that start with + are always turned on

     if ( lyr_name.match( /^\+/ ) ) {

  layer.visible = true;

 

     // any layers that start with -, have default layer name, or named "nyt_exporter_info" are skipped

     } else if ( lyr_name.match( /nyt_exporter_info/ ) || lyr_name.match( /^Layer /) || lyr_name.match( /^\-/ ) ){

  layer.visible = false;

 

     // everything else we should export

     } else {

  layer.visible = false;

  export_count++;

     }

  }

  return export_count;

    },

   

    get_num_layers_to_export: function() {

 

 

  var num_to_export = 0;

  var num_layers = aDoc.layers.length;

 

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

    

     var layer = aDoc.layers[i];     

     var lyr_name = layer.name;

    

     // any layers that start with + are always turned on

     if ( lyr_name.match( /^\+/ ) ) {

 

     } else if ( lyr_name.match( /nyt_exporter_info/ ) || lyr_name.match( /^Layer /) || lyr_name.match( /^\-/ ) ){

 

     } else {

  num_to_export++;

     }

  }

 

  return num_to_export;

    },

   

    get_num_artboards_to_export: function() {

 

  var num_artboards = aDoc.artboards.length;

  var num_to_export = 0;

 

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

           

            var artboardName = aDoc.artboards[i].name;

            if ( ! ( artboardName.match(  /^artboard/i ) || artboardName.match( /^\-/ ) )){

                num_to_export++;

            }

  }

 

  return num_to_export;

 

    },

   

   

    show_all_layers: function() {

  var n = aDoc.layers.length;

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

     layer = aDoc.layers[i];

     layer.visible = true;

  }

    },

   

};

 

 

 

 

 

 

nyt_png_exporter.init();

Resolution check in illustrator

$
0
0

How to check the raster image resolution in illustrator through script?

Change Folder.current to location of script (.jsx) file?

$
0
0

All,

 

I'm trying to use some images in my ScriptUI dialog, but I want to use a "relative" path name, and I can't seem to get it to work.

For example, this myScript.jsx works just fine, but as you can see, I'm using an "absolute" path name to transparencyGrid.jpg:

 

var w = new Window ("dialog");
var f = new File ('~/Desktop/transparencyGrid.jpg');
w.add ("image", undefined, f); 
w.show ();

 

However, I want to be able to use a relative (to myScript.jsx) path to point at transparencyGrid.jpg, like this:

 

var w = new Window ("dialog");
var f = new File ('../../../transparencyGrid.jpg');
w.add ("image", undefined, f); 
w.show ();

 

But, I can't seem to get this to work because relative paths seem to be relative to the current folder, Folder.current, not the location of the currently executing script.

I say that because when I do this:

 

alert(Folder.current);

 

The only thing the alert message shows is a backslash (/), indicating to me that the current folder is the root of my OS, but I thought it would be the folder where myScript.jsx resides.

 

So, is there a way of setting Folder.current to the location of the actual script?

TIFF Import Options - Flatten Layers to a Single Image

$
0
0

Hi All,

 

Running a script to open up files and convert to another type. When it gets to a TIFF type file a dialog window titled 'TIFF Import Options' is opening. This windows has an Options column that contains two radio selections for 'Convert Layers to Objects' and 'Flatten Layers to a Single Image'. How would I open the file with the 'flatten layers to a single image' set?

 

Thanks

How to get the start and end points of a line using javascript?

$
0
0

Hi,
I had a line selected in the active document. All I need is to get the starting and ending points of the line.  I had tried with 'geometricBounds', but, it couldn't satisfy me. It is just giving coordinates of the rectangular selection.

Am new in this. Thanks in advance.


Text Replacement script

$
0
0

Hello all,

 

I am very new to the scripting world but have an issue that I was unsuccessful in resolving myself through googling and searching around. It may be impossible due to illustrator's set up but I am looking for a script to find and replace strings of text throughout a document. I realize in indesign this would be easy as all get out, but due to other limitations I am forced to use Illustrator.

 

I would need the script to search and find strings in both text boxes and text objects (or 2 scripts could work). I would be looking for something to find and replace as well as style for instance, find AA and replace with AA(registration mark) and superscript the registration mark. I would need to be able to do this for multiple instances of this string on a document. Is something like this possible?

 

Thanks in advance!

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

Importing Color to Swatch Library from Text File

$
0
0

Hi,

I have a large list of custom colors in Excel that has the color name and CMYK breakdown of each color. I'm looking for a way to import this information to create a custom Color Swatch Library. That will have the name of the color and the CMYK breakdown. So that I can easily use in Illustrator and Photoshop. Is there any way or application in doing this with out manually entering the information and creating a new library?

 

Thanks!

Get broken file path of rasterItem

$
0
0

Hello there,

 

I made a little script to create an artboard for each selected image. The artboard should have the name of the image and should be in its position.

Everything is working fine for embedded and non embedded images. The problem I have, is that I don't know how to get the file path for embedded images (rasterItems) that have a broken link.

Those items do have the path property somewhere, since the ui shows them

and also the ai file contains them (Not quite sure if I can access that):

I read over here that the information is only stored in XMP, but I don't understand how to access it.

 

My script on Github

 

Relevant code:

var rasterItems = docRef.rasterItems;
for(var i = 0; i < rasterItems.length; i++) {    var item = rasterItems[i];    if(item.selected) {                    var filename = "RasterItemArtBoard";        try {            filename = item.file.name;        }        catch(e) {            // File does not exist            // TODO: Get name otherwise        }        filename = filename.substr(0, filename.lastIndexOf("."));        var artboard = docRef.artboards.add (item.geometricBounds);        artboard.name = filename;    }
}

 

So in the end, I need the filename of a broken file path and I have no idea how to access it.

I tried:

  • item.name
  • item.displayName
  • item.parent.name
  • item.note
  • item.uRL
  • reading the value from the error message

Saving documents via Scripts: Get current file name and set save path/file type

$
0
0

I am writing a script that will:

 

-Make all layers invisible

-Make a layer named "background" visible

-Delete all the invisible layers

-Save the docment as an EPS file (leaving the original document untouched)

 

I am new to scripts and so have based my script by copying code from other scripts.

 

Here is my code:

 

var doc = app.activeDocument;

var name = doc.name;

 

 

var hide = function (){ // hide all layers (based on http://forums.adobe.com/thread/644267)

     var L=doc.layers.length;

     for (j=0;j<L;j++){  doc.layers[j].visible=false; }

}

hide();

 

 

// loop through all layers

for (var i = 0; i < doc.layers.length; i++) {

 

 

 

 

 

              // Create the illusrtratorSaveOptions object to set the AI options

    var saveOpts = new IllustratorSaveOptions();

 

    // Setting IllustratorSaveOptions properties.

    saveOpts.embedLinkedFiles = true;

    saveOpts.fontSubsetThreshold = 0.0

    saveOpts.pdfCompatible = true

 

 

 

 

 

 

//Set up Variable to access layer name

          var currentLayer = app.activeDocument.layers[i];

 

// Loop through the layers and make the back ground layer visible

          if (currentLayer.name == "Background") {

                    docName = name + currentLayer.name+".eps";

                    currentLayer.visible = true;

                    }

 

 

}

 

 

// Delete Invisible Layers (based on http://www.cartotalk.com/index.php?showtopic=7491)

var myDoc=app.activeDocument;

var layerCount=myDoc.layers.length;

for (var ii = layerCount - 1; ii >= 0; ii--) {

    var currentLayer = myDoc.layers[ii];

    currentLayer.locked = false;

    var subCount = currentLayer.layers.length;

    for (var ss =subCount -1; ss >= 0; ss--){

        var subLayer = currentLayer.layers[ss];

        subLayer.locked = false;

        if (subLayer.visible == false){

            subLayer.visible = true;

            subLayer.remove();

            }

        }

    if (currentLayer.visible == false){

        currentLayer.visible = true;

        currentLayer.remove();

        }

    }

 

// Save Out Document with New Name

 

var saveName = new File ( doc.path + "/" + docName );

doc.saveAs( saveName, saveOpts );

 

 

 

Everything works fine except:

1) It saves the document with the name AdobeIllustratorBackground as opposed to the name of the document

 

Also, I am not sure how to tell the script to save as EPS and to specify the save location.

 

Could some one give me some pointers?          Thanks!

Viewing all 12845 articles
Browse latest View live


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