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

TextRange.horizontalScale cannot be set to 100%?

$
0
0

I'm on 19.2.1 and if I have a TextFrameItem selected, app.activeDocument.selection[0].textRange.horizontalScale = 100 returns 100, but does not actually get applied to the TextFrameItem. Many other values work, just not 100. The closest I can get is 100.01.

 

Am I missing something?


Find text Tint Value

$
0
0

Hi All,

 

I need to check whether any character have opacity.  I tried the following codings, but it shows all characters as error.

 

var myframe = app.activeDocument.textFrames; 
for(i=0; i<myframe.length; i++) 
{     var myCharacters = myframe[i].characters;     for(j=0; j<myCharacters.length; j++)     {          if(myCharacters[j].opacity != 100)          {              alert("Error: Check some text has opacity")              }         }     } 

 

Regards,

Karthi

How change setting of Preference of Illustrator by Script?

$
0
0

How turn on or turn off setting in Preference -> Type -> Enable Missing Glyph Protection by Script?

Thank you.

How delete a Action Set in Illustrator by Script?

$
0
0

this my code Load and unload a Action in Illustrator. But Action Set [Test_Set_Action] still exist after unload .

oIllustrator.loadAction("C:\Test_Set_Action.aia")

oIllustrator.unloadAction("Test_Set_Action", "CVCMYK")

How delete a Action Set [Test_Set_Action] after unload by Script?

Or check [Test_Set_Action]  still exist?

Bridge to Illustrator

$
0
0

Hello everyone,

 

I am working on a file saving script. I am trying to figure out how to send information from bridge to my illustrator script. I need to know the file path that is active in bridge, I can do this in a bridge script by app.document.presentationPath; I am just trying to send that information to use in illustrator for my file saving.

 

#target "illustrator-60.064"

 

var targetApp = BridgeTalk.getSpecifier( "bridge-5.064");

if( targetApp ) {

 

var bt = new BridgeTalk;

bt.target = targetApp;

bt.body = app.document.presentationPath; //error

 

bt.send();

 

}

 

alert (bt);

 

I'm new to bridgetalk I have never used it, I know I am using it wrong hence the error lol, if anyone could get me on track it would be greatly appreciated.

 

Thanks!!

Turn selected AI sublayers into top-level layers?

$
0
0
Hi, all!

I wanted to ask if by chance any of the scripting gurus here happen to have written an AI script that will take a number of selected sublayers/sub-sublayers and move them so they become top-level layers?
I am really needing this very badly, given that After Effects can only handle AI layers as separate entities. So I find myself moving tens, even hundreds of nested sublayers to the top level all the time.
Is it possible this script exists already?

How do I Change Swatch Names in Illustrator CC 2015?

$
0
0

First, I know nothing about scripting or writing code.  That being stated, I am trying to use a script to change the swatch names in a PDF file in Illustrator CC 2015 for the PC.  Below is what I have cobbled together.  When the script hits the doc.swatches line I receive a "i is undefined."  I also changed the name of the swatches for the privacy purposes.  Thank you.

 

var docs = File.openDialog("Select Files to Open", "*.pdf", true);

 

var idx = 0;

 

for (idx = 0; idx < docs.length; ++idx) {

 

    var doc = app.open(docs[idx]);

 

    var myCounter = 0;

 

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

 

        doc.layers[myCounter].locked = false;

 

    }

 

        doc.swatches[i].name = doc.swatches[i].name.split('SwatchA').join('AlphaSwatch'); 

      

        doc.swatches[i].name = doc.swatches[i].name.split('SwatchB').join('BetaSwatch');

 

 

}

Link location switch

$
0
0

I am using a script that will allow me to change an illustrator asset link location from my high res asset library to low res asset library or thumb drive and back. I would like to change the script to change the thumb drive to a Box Sync folder. I am able to get the link path to switch from my HR or LR library to Box Sync, but not back from Box Syn to HR or LR.

 

I am running Mac OS 10.11.4 with Illustrator CC 2015 18.0.0.

 

Here is my two scripts. First is my thumb drive that works and then my Box Sync that works only one way.

 

setUSBLinkto "HD TD00"

setLoResLinkto "CG Master_LR"

setHiResLinkto "CG Master_HR"

setNewExt1to ".tif"

setNewExt1Smallto "-sm.tif"

setErrorListto {}

setLinkInspectto {}

tellapplication "Adobe Illustrator"

  activate

  setuser interaction leveltointeract with all

  display dialog "Please chose link mode" buttons {"HiRes", "LoRes", "ThumbDrive"} default button 2

 

  ifthebutton returnedoftheresultis "HiRes" then

 

 

  setErrorListtoErrorList& myLinkSwitch(document 1, LoResLink, HiResLink, 3, NewExt1)

  setErrorListtoErrorList& myLinkSwitch(document 1, USBLink, HiResLink, 3, NewExt1)

 

 

  elseifbutton returnedoftheresultis "LoRes" then

 

  setErrorListtoErrorList& myLinkSwitch(document 1, HiResLink, LoResLink& ":Assets", 2, NewExt1Small)

  setErrorListtoErrorList& myLinkSwitch(document 1, USBLink, LoResLink, 2, NewExt1Small)

 

  else

 

  setErrorListtoErrorList& myLinkSwitch(document 1, LoResLink, USBLink, 2, NewExt1Small)

  setErrorListtoErrorList& myLinkSwitch(document 1, HiResLink, USBLink& ":Assets", 2, NewExt1Small)

 

  endif

 

  setuser interaction leveltointeract with all

  setErrorListtomyremoveDuplicates(ErrorList)

  ifErrorListisnot {} then

  setLinkInspectto (choose from listErrorListwith prompt "Reveal The Files" withmultiple selections allowed)

  endif

  --display dialog "The following files were not relinked:" & return & ErrorList

  ifLinkInspectisnot {} then

  try

  repeatwithalbiefrom 1 tocountofLinkInspect

  tellapplication "Finder"

  activate

  delay 0.5

  revealitemalbieofLinkInspect

  endtell

  endrepeat

  endtry

  endif

endtell

 

 

 

 

ongetBaseName2(fName, Char)

  tellapplication "System Events"

  setNoExtto {}

  setZto 0

  setBaseNametoreverseofeveryitemoffName

  repeatwithidxfrom 1 tocountofBaseName

  ifitemidxofBaseNameisCharthen

  exitrepeat

  else

  setZtoZ + 1

  endif

  endrepeat

  returnitems 1 thru ((countofBaseName) - 1 - Z) ofreverseofBaseNameasstring

  endtell

 

endgetBaseName2

 

onFolderPathtoList(myPath, TrimFront, TrimBack)

 

  setFolderPathto {}

  setoldDelimiterstoAppleScript'stext item delimiters-- always preserve original delimiters

  setAppleScript'stext item delimitersto {":"}

  setpathItemstotext itemsof (myPathastext)

  setTFto (TrimFrontasnumber) + 1

  setTBto ((countofpathItems) - TrimBackasinteger) asinteger

  setAppleScript'stext item delimiterstooldDelimiters

  returnitemsTFthruTBofpathItemsaslist

endFolderPathtoList

 

 

 

 

ontrim_line(this_text, trim_chars, trim_indicator)

  -- 0 = beginning, 1 = end, 2 = both

  setxtothelengthofthetrim_chars

  -- TRIM BEGINNING

  ifthetrim_indicatorisin {0, 2} then

  repeatwhilethis_textbegins withthetrim_chars

  try

  setthis_texttocharacters (x + 1) thru -1 ofthis_textasstring

  onerror

  -- the text contains nothing but the trim characters

  return ""

  endtry

  endrepeat

  endif

  -- TRIM ENDING

  ifthetrim_indicatorisin {1, 2} then

  repeatwhilethis_textends withthetrim_chars

  try

  setthis_texttocharacters 1 thru -(x + 1) ofthis_textasstring

  onerror

  -- the text contains nothing but the trim characters

  return ""

  endtry

  endrepeat

  endif

  returnthis_text

endtrim_line

 

onremoveDuplicates(lst)

  locallst, itemRef, res, itm

  try

  iflst'sclassisnotlistthenerror "not a list." number -1704

  scriptk

  propertyl : lst

  propertyres : {}

  endscript

  repeatwithitemRefink'sl

  setitmtoitemRef'scontents

  -- note: minor speed optimisation when removing duplicates

  -- from ordered lists: assemble new list in reverse so

  -- 'contains' operator checks most recent item first

  ifk'sresdoes notcontain {itm} then¬

  setk'sres'sbeginningtoitm

  endrepeat

  returnk'sres'sreverse

  onerroreMsgnumbereNum

  error "Can't removeDuplicates: " & eMsgnumbereNum

  endtry

endremoveDuplicates

 

 

onotherTrim(StringToTrim, TheDelimiter, TheDirection)

  setTheResultto {}

  setStringToTrimtoStringToTrimasstring

  ifTheDirectionis 0 then

  setZtoreverseofeverycharacterofStringToTrimasstring

  repeatwithfrfrom 1 tocountofZ

  ifitemfrofZisTheDelimiterthen

  exitrepeat

  else

  setendofTheResulttoitemfrofZ

 

  endif

  endrepeat

  setTheResulttoreverseofTheResultasstring

  else

  --Forward Goes Here

  endif

endotherTrim

 

onCharacterCheck(TheString, CheckCharacter)

  setCheckSumto 0

  setTheStringtoeverycharacterofTheString

  repeatwithfrfrom 1 tocountofTheString

  ifitemfrofTheStringisCheckCharacterthen

  setCheckSumtoCheckSum + 1

  endif

  endrepeat

  returnCheckSum

endCharacterCheck

 

onLinkSwitch(TheDoc, DriveOld, DrivNew, TheTrim, FileEnd)

  tellapplication "Adobe Illustrator"

  setuser interaction leveltonever interact

  tellTheDoc

  setDocLinkstoeveryplaced item

  settempErrorto {}

  repeatwithAvafrom 1 tocountofDocLinks

  setnewlinkto {}

  setpathcounttocountofmyFolderPathtoList(file pathofitemAvaofDocLinks, 0, 0)

  setNewNametomyFolderPathtoList(file pathofitemAvaofDocLinks, pathcount - 1, 0) asstring

  setNewNametomygetBaseName2(NewName, ".")

  setNewNametomygetBaseName2(NewName, "-")

  setPathCheckto (myFolderPathtoList(file pathofitemAvaofDocLinks, 0, 1))

 

 

  ifitem 1 ofPathCheckisDriveOldthen

  setendofnewlinktoDrivNew& ":"

  repeatwithEnzofromTheTrimtocountofPathCheck

  setendofnewlinktoitemEnzoofPathCheck

  setendofnewlinkto ":"

 

  endrepeat

  setnewlinktonewlink& NewName& FileEndasstring

 

  try

  setfile pathofitemAvaofDocLinkstonewlink

 

  try

  setnameofitemAvaofDocLinkstoNewName& NewExt1asstring

  endtry

  onerror

  setendoftempErrortofile pathofitemAvaofDocLinksasstring

  endtry

  else

  setxtocountofmyFolderPathtoList(file pathofitemAvaofDocLinksasstring, 0, 0)

  --return my FolderPathtoList(file path of item Ava of DocLinks & return as string, x - 2, 1)

 

 

  ifmyFolderPathtoList(file pathofitemAvaofDocLinksasstring, x - 2, 1) asstringisnot "ALT" then

  setendoftempErrortofile pathofitemAvaofDocLinksasstring

  endif

 

 

  endif

  endrepeat

  returntempError

  endtell

  setuser interaction leveltointeract with all

  endtell

endLinkSwitch

 

 

 

Box Sync Script:

 

setBoxSyncto "Mac OSX:Users:artist:Box%20Sync:CG%20Master_LR"

setLoResLinkto "CG Master_LR"

setHiResLinkto "CG Master_HR"

setNewExt1to ".tif"

setNewExt1Smallto "-sm.tif"

setErrorListto {}

setLinkInspectto {}

tellapplication "Adobe Illustrator"

  activate

  setuser interaction leveltointeract with all

  display dialog "Please chose link mode" buttons {"HiRes", "LoRes", "BoxSync"} default button 2

 

  ifthebutton returnedoftheresultis "HiRes" then

 

 

  setErrorListtoErrorList& myLinkSwitch(document 1, LoResLink, HiResLink, 3, NewExt1)

  setErrorListtoErrorList& myLinkSwitch(document 1, BoxSync, HiResLink, 3, NewExt1)

 

 

  elseifbutton returnedoftheresultis "LoRes" then

 

  setErrorListtoErrorList& myLinkSwitch(document 1, HiResLink, LoResLink& ":Assets", 2, NewExt1Small)

  setErrorListtoErrorList& myLinkSwitch(document 1, BoxSync, LoResLink, 2, NewExt1Small)

 

  elseifbutton returnedoftheresultis "BoxSync" then

 

  setErrorListtoErrorList& myLinkSwitch(document 1, LoResLink, BoxSync, 2, NewExt1Small)

  setErrorListtoErrorList& myLinkSwitch(document 1, HiResLink, BoxSync& ":Assets", 2, NewExt1Small)

 

  endif

 

  setuser interaction leveltointeract with all

  setErrorListtomyremoveDuplicates(ErrorList)

  ifErrorListisnot {} then

  setLinkInspectto (choose from listErrorListwith prompt "Reveal The Files" withmultiple selections allowed)

  endif

  --display dialog "The following files were not relinked:" & return & ErrorList

  ifLinkInspectisnot {} then

  try

  repeatwithalbiefrom 1 tocountofLinkInspect

  tellapplication "Finder"

  activate

  delay 0.5

  revealitemalbieofLinkInspect

  endtell

  endrepeat

  endtry

  endif

endtell

 

 

 

 

ongetBaseName2(fName, Char)

  tellapplication "System Events"

  setNoExtto {}

  setZto 0

  setBaseNametoreverseofeveryitemoffName

  repeatwithidxfrom 1 tocountofBaseName

  ifitemidxofBaseNameisCharthen

  exitrepeat

  else

  setZtoZ + 1

  endif

  endrepeat

  returnitems 1 thru ((countofBaseName) - 1 - Z) ofreverseofBaseNameasstring

  endtell

 

endgetBaseName2

 

onFolderPathtoList(myPath, TrimFront, TrimBack)

 

  setFolderPathto {}

  setoldDelimiterstoAppleScript'stext item delimiters-- always preserve original delimiters

  setAppleScript'stext item delimitersto {":"}

  setpathItemstotext itemsof (myPathastext)

  setTFto (TrimFrontasnumber) + 1

  setTBto ((countofpathItems) - TrimBackasinteger) asinteger

  setAppleScript'stext item delimiterstooldDelimiters

  returnitemsTFthruTBofpathItemsaslist

endFolderPathtoList

 

 

 

 

ontrim_line(this_text, trim_chars, trim_indicator)

  -- 0 = beginning, 1 = end, 2 = both

  setxtothelengthofthetrim_chars

  -- TRIM BEGINNING

  ifthetrim_indicatorisin {0, 2} then

  repeatwhilethis_textbegins withthetrim_chars

  try

  setthis_texttocharacters (x + 1) thru -1 ofthis_textasstring

  onerror

  -- the text contains nothing but the trim characters

  return ""

  endtry

  endrepeat

  endif

  -- TRIM ENDING

  ifthetrim_indicatorisin {1, 2} then

  repeatwhilethis_textends withthetrim_chars

  try

  setthis_texttocharacters 1 thru -(x + 1) ofthis_textasstring

  onerror

  -- the text contains nothing but the trim characters

  return ""

  endtry

  endrepeat

  endif

  returnthis_text

endtrim_line

 

onremoveDuplicates(lst)

  locallst, itemRef, res, itm

  try

  iflst'sclassisnotlistthenerror "not a list." number -1704

  scriptk

  propertyl : lst

  propertyres : {}

  endscript

  repeatwithitemRefink'sl

  setitmtoitemRef'scontents

  -- note: minor speed optimisation when removing duplicates

  -- from ordered lists: assemble new list in reverse so

  -- 'contains' operator checks most recent item first

  ifk'sresdoes notcontain {itm} then¬

  setk'sres'sbeginningtoitm

  endrepeat

  returnk'sres'sreverse

  onerroreMsgnumbereNum

  error "Can't removeDuplicates: " & eMsgnumbereNum

  endtry

endremoveDuplicates

 

 

onotherTrim(StringToTrim, TheDelimiter, TheDirection)

  setTheResultto {}

  setStringToTrimtoStringToTrimasstring

  ifTheDirectionis 0 then

  setZtoreverseofeverycharacterofStringToTrimasstring

  repeatwithfrfrom 1 tocountofZ

  ifitemfrofZisTheDelimiterthen

  exitrepeat

  else

  setendofTheResulttoitemfrofZ

 

  endif

  endrepeat

  setTheResulttoreverseofTheResultasstring

  else

  --Forward Goes Here

  endif

endotherTrim

 

onCharacterCheck(TheString, CheckCharacter)

  setCheckSumto 0

  setTheStringtoeverycharacterofTheString

  repeatwithfrfrom 1 tocountofTheString

  ifitemfrofTheStringisCheckCharacterthen

  setCheckSumtoCheckSum + 1

  endif

  endrepeat

  returnCheckSum

endCharacterCheck

 

onLinkSwitch(TheDoc, DriveOld, DrivNew, TheTrim, FileEnd)

  tellapplication "Adobe Illustrator"

  setuser interaction leveltonever interact

  tellTheDoc

  setDocLinkstoeveryplaced item

  settempErrorto {}

  repeatwithAvafrom 1 tocountofDocLinks

  setnewlinkto {}

  setpathcounttocountofmyFolderPathtoList(file pathofitemAvaofDocLinks, 0, 0)

  setNewNametomyFolderPathtoList(file pathofitemAvaofDocLinks, pathcount - 1, 0) asstring

  setNewNametomygetBaseName2(NewName, ".")

  setNewNametomygetBaseName2(NewName, "-")

  setPathCheckto (myFolderPathtoList(file pathofitemAvaofDocLinks, 0, 1))

 

 

  ifitem 1 ofPathCheckisDriveOldthen

  setendofnewlinktoDrivNew& ":"

  repeatwithEnzofromTheTrimtocountofPathCheck

  setendofnewlinktoitemEnzoofPathCheck

  setendofnewlinkto ":"

 

  endrepeat

  setnewlinktonewlink& NewName& FileEndasstring

 

  try

  setfile pathofitemAvaofDocLinkstonewlink

 

  try

  setnameofitemAvaofDocLinkstoNewName& NewExt1asstring

  endtry

  onerror

  setendoftempErrortofile pathofitemAvaofDocLinksasstring

  endtry

  else

  setxtocountofmyFolderPathtoList(file pathofitemAvaofDocLinksasstring, 0, 0)

  --return my FolderPathtoList(file path of item Ava of DocLinks & return as string, x - 2, 1)

 

 

  ifmyFolderPathtoList(file pathofitemAvaofDocLinksasstring, x - 2, 1) asstringisnot "ALT" then

  setendoftempErrortofile pathofitemAvaofDocLinksasstring

  endif

 

 

  endif

  endrepeat

  returntempError

  endtell

  setuser interaction leveltointeract with all

  endtell

endLinkSwitch


How to Open Print Window via Javascript ( Normally we are using Ctrl-P shortcut in illustrator )

"Add Used Colors": is there javascript for this?

$
0
0

I currently have a javascript which amends swatches, but first I need it to "Add Used Colors" to generate the swatches from objects in the document. Is there javascript for this?

Does Illustrator CS5 support function loadAction?

$
0
0

I try find:

Illustrator CS6 can load and unload action by:

oIllustrator.loadAction("C:\Set_Action.aia")

oIllustrator.unloadAction("Set_Action", "")

But with Illustrator CS5 i can't find these Function.

Does Illustrator CS5 support function loadAction?

convert 1 text frame to 2 threaded ones

$
0
0

Hello gays!

Please, can anyone help me to write a script which converts a text frame with text inside to 2 threaded 2-columned text frames residing on different artboards? The size of the columned frames is equal but each time varies, so maybe the script can ask for the size? The gutter size is 3 mm, the font size should be 12 pt, the interline distance 14 pt. Thank you!

CS6+ executeMenuCommand, pattern swatch

$
0
0

Hi all, I'm trying to create a Pattern Swatch out of the Selected Object, so I'm using

 

app.executeMenuCommand ('Define Pattern Menu Item');

 

this successfully adds the swatch to the swatches panel, but it also brings up the Pattern Options Panel and goes into "Pattern Editing Mode" where in the UI one could either click on "Cancel", "Done" or "Exit Editing Mode" buttons...

 

the problem is I can't exit out of the Pattern Editing Mode, has anyone discovered if there is a MenuCommand for it?

 

thanks

convert textframe to two threaded textframes

$
0
0

Please, can anyone help me to write a script which converts a text frame with text inside to 2 threaded 2-columned text frames locating on different artboards?

The size of the textframes is the same but each time varies, so maybe the script can ask for the size.

The gutter size is 3 mm, the font size should be 12 pt, the interline distance 14 pt.

Sorry for bad English!

I guess the initial textframe should be scaled and converted to to 2-columned then another text frame created on a new artboard and then both threaded but I don't know from what to start...

how to read pdfpreset info

$
0
0

how to read/get the information of a pdfpreset using js?

e.g to get the compatibility and preserveEditability value of "ABC" preset.

 

Thanks much..


nobreak for digitcharacter

$
0
0

I have tried to write a simple script to avoid breaking digits and following units, for example, "15 ml" should be in one line, not "15" in one, and "ml" in the next.

Here is the code but I cannot realize how to attribute NoBreak property to the found text.

Can anybody help me?

 

var frames = app.activeDocument.textFrames; 

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

var text = frames[j].textRange; 

var haystack = text.contents; 

var needle = /[\d]\s[\a-z]/gi; 

var match; 

while(match = needle.exec(haystack)){ 

var start = needle.lastIndex - match[0].length; 

var end = match[0].length; 

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

characterAttributes.noBreak=true); <============ this line is incorrect

}

svg to pdf

$
0
0

i have 100 svg files in folder , in that svg files artboard size is 234,1mm and 171mm it should save as pdf in A4(297^210mm) format same as that of svg file name , and in some svg file the file is twice of the artboard 468.2mm and 342mm in that case it should save as A4 pdf with same file name for artboard size 234.1mm and 171mm with -1 for first page and for second page -2 , please anybody can you able to write script for this ?

How to get a XMPString, if do not open the file?

$
0
0

If open a file by illustrator ,we can get the xmp infomation,

like this:

    doc=app.activeDocument;

    var xmlString = new XML(doc.XMPString);

Can I get a XMPString by JS, and do not open the file?

 

Thanks much!

Text Replace ( i am getting error while replace Envelope Text ) Can anyone help me

$
0
0
var active_doc = app.activeDocument;
var dlg = new Window('dialog', 'TEXT REPLACE');    var gro =dlg.add('group');    gro.orientation = 'row';          var Orderno = gro.add('StaticText' ,{x:10,y:40,width:70,height:20});    Orderno.text = 'TEXT :';    var OrdernoValue = gro.add('EditText',{x:10,y:40,width:100,height:20},"");    OrdernoValue.text   = OrdernoValue.value;        var g_btn = dlg.add("group");    var btn_ok = g_btn.add("button", undefined, "Ok");    var btn_ccl = g_btn.add("button", undefined, "Cancel");    btn_ok.onClick = function()    {        if(Orderno)        {            dlg.close();        }        else        {            return;         }     }
dlg.show();
replace(/TEXT/gi,OrdernoValue.text);


function replace(search_string,replace_string)
{
var text_frames = active_doc.textFrames;

if (text_frames.length > 0)
{    for (var i = 0 ; i < text_frames.length; i++)      {          var this_text_frame = text_frames[i];                   var new_string = this_text_frame.contents.replace(search_string, replace_string);                      if (new_string != this_text_frame.contents)               {                    this_text_frame.contents = new_string;               }      }
}
}

CS6+ executeMenuCommand, Adobe Actions Batch

Viewing all 3671 articles
Browse latest View live


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