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

Feedback on a new extension for Illustrator I've created called PowerScripts.

$
0
0

Hi Guys

 

I posted in Reddit and one of the users over there suggested this forum.

 

I've created a new Extension called PowerScripts for Adobe Illustrator and I would like you guys to download a trial and get your feedback (CC 2015+ and Windows only at this stage)

 

Its in BETA and still quite a bit of work to do, I'd say 98% done, but the last 2% is hard.

 

I've been in the print industry for 18 years and owned my own businesses plus worked for other companies. During that time I've written a lot of scripts for various apps to help speed up mundane pre-press tasks. Its all been a bit ad-hoc however I've spent a ton of time over the last 6 months putting together all the tools I've made over the years into an extension called PowerScripts.

 

Further down the track I was considering getting some other coders on board to also write scripts for PowerScripts since its basically a framework to create scripts easily. I'm not sure how I will go about this.

 

Quite frankly its a lot of hard work and a bit nerve racking trying to release a commercial product, I know these tools have worked well for me and other businesses who have tried them, but its another thing making them public! In fact asking you guys to check it out is even scarier - be kind!

 

You can view the extension here http://www.o2creative.co.nz/powerscripts.php and request a trial here.  I have do manually process this because I don't have online serial generation running yet)

 

 

Since this is the geeky crowd

  • Full JavaScript ICC color engine with V2 ICC support and basic V4 ICC Profile support in JavaScript (Only runs in CEP at this stage)
  • Read ACE files
  • Custom UI controls in addition to HTML inputs, drag and drop file lists, datatables, Color Pickers etc
  • All scripts are in an XML file, which is used the for UI, HTML in a CDATA tag used to create the tabs / inputs
  • All UI form data is passed to the script as a object, such as args.width, args.resizeArtboard.
  • A toolbox class which makes a ton of stuff easier, Apply fills , create clipping marks etc.
  • A chainable selection class which is like Jquery for Illustrator. selection.select(document.selection).scale(0.5).removeStroke().fillCMYK(0,0,40,0).rotate( 45).group('group name').clipInside('savedSelectionName').alignTo(artboard,'top','center')
  • Cached scripts
  • A packager which can distribute scripts via automatic downloads and signs them.
  • Scripts can have multi-language support
  • 20,000 lines of code excluding the scripts
  • Tons more

 

Benefits if you are the dev

  • Really quick to create scripts
  • Everything you need in one XML file
  • HTML UI - CSS, JavaScript and pre-built controls.
  • UI values are automatically passed to the script
  • Selection buttons, allows the user to select and remember selection.
  • User can save default settings (no special code needed)
  • Cookies so your scripts can remember 'stuff'
  • Library of code

 

I welcome your feedback

  • What scripts you like and would find useful
  • Problems and where things don't work.
  • Suggestions for improvements.
  • Ideas for new features and new scripts
  • General thoughts

 

If you have any questions, happy to answer them.

 

Glenn Wilton

o2creative.co.nz


Layer color typenames - any way to call these out in a script?

$
0
0

I have marginal experience with coding and no experience with Javascript at all, but I'm trying to write a layer setup script in ExtendScript Toolkit to save time when starting a new document. I know that I can set layerColor as a new RGB color by using red/green/blue values. However, this results in the layer having a "custom" color in Illustrator, as opposed to one of the predefined colors, e.g. light blue, light red, green, etc, even if the "custom" defined values match the values of the predefined color. That's not really a problem per se, but I was curious if there is a way to set the RGB value for layerColor to one of the predefined colors using a "typename" value, which I found in the Illustrator Scripting Reference for Javascript.

 

I tried to do that, but no matter that I put in for the typename value, Illustrator sets the layer color to black. Not "custom" black, but predefined black, so it seems to be doing something partially like I want it to. I'm wondering if there's a reference somewhere to tell me what typename string I could put in to get Illustrator to pick the corresponding predefined layer color? Or, is it just defaulting to predefined black because it doesn't understand what I've entered for the typename value?

 

Hopefully that made some kind of sense; I don't have much background in describing coding accurately!

 

Screen Shot 2017-02-09 at 12.00.44 PM.pngScreen Shot 2017-02-09 at 12.01.10 PM.png

app.executeMenuCommand() problems

$
0
0

I'm using AI CC 2017 and it has been brought to my attention that my app.executeMenuCommand("doc-color-cmyk"); doesn't work some times when my script is ran.

 

#target illustrator

function test(){

    var doc = app.activeDocument;

    app.executeMenuCommand("doc-color-rgb");

    app.redraw();

};

test();

 

I tested the above snippet and sure enough, nothing happens.

Then, I went to the menu item and hovered over it to reveal the CMYK/RGB menu items in the document color space (without choosing one even), and it now works.

 

Is this the same thing that's happening with the Actions not registering the recorded scripts menu items?

It is not acceptable when they have to show this item, however rare it might be!

 

I went by with actions for this purpose, but having this come up was a rather unwelcome 'surprise'.

Setting Scale Corners in a script

$
0
0

I'm writing a script to fit an object into a specific sized box. I'm using:

 

artwork[0].resize(scale, scale ,1,1,1,1,scale);

 

in order to change the size. Everything seems to be working fine except if I have the "Scale Corners" check box in the Transform palette turned off. Then, of course, it doesn't scale the corners!

 

I can't figure out of there is a way to either, override that in the script or change the setting and then change it back when its done.

 

I tried:

 

getBooleanPreference("Scale Corners");

 

to see if I could get to it that way, but it doesn't match up with what is shown as selected!

 

Any ideas?

find fonts in illustrator files pdf, eps, ai illustrator javascript

$
0
0

Hi Friends

 

any can help me . I need code for find fonts of the files >pdf. eps. .ai using illustrator javascript without indesign.

Export selected items as PNG, SVG in different dimensions in AI CS6 and older

$
0
0

1) In latest Illustrator versions we have exportSelectionAsPNG method, it exports PNG with 100% scale, but what value should be passed in "options" parameters if I want export different scale?

 

2) In Illustrator CSx we haven't even exportSelectionAsPNG.

How can I export selected items (SymbolItem/PathItem/etc)?

I readen Illustrator ExtendScript reference, looken at C/C++ source code of Illustrator SDK, and even tried reverse-engineering of Illustrator DLLs, but didn't yet found any way to do this simply.

I found only 2 ways to do it tricky - via creating artboard and duplicate art, and via creating layer and duplicate art.

 

2.2) Way with artboard is preffered for me, but there is a problem. My new artboard is creating inside first of document's artboards, when I set x=0 and y=0 it uses coordinates of my first artboard, i.e. new artboard creates as a nested artboard, and nested artboard when exporting have non-transparent background, and I don't see any way to create new artboard outside 1st artboard, only set x < 0 and y > 0, but it is dirty trick, I even cannot determine what first artboard's 0,0 origin isn't document's 0,0 origin actually.

 

Thank you.

Cannot change font of ScriptUI controls

$
0
0

For example, following script:

 

var w = new Window('dialog');
var myStatic = w.add('statictext', undefined, "Hello World!");

//myStatic.graphics.font = "Arial-Bold:24";
//myStatic.graphics.font = "Verdana:16";
//myStatic.graphics.font = "Tahoma:24";


//myStatic.graphics.font = ScriptUI.newFont ("Tahoma", "Bold", 30);


//myStatic.graphics.font = ScriptUI.newFont (myStatic.graphics.font.name, "Bold", myStatic.graphics.font.size);


//myStatic.graphics.font.size = 30;

w.show();

 

All commented lines are my different behaviours to change a font of statictext, or at least its size. All them do not working in my AI CC 2015.

 

I note what whole UI in my AI have not system UI look&feel, but AI's custom, i.e. dark background, gray text and etc. Is it matter? How to workaround it?

What the heck is with the weak JPG Export options??

$
0
0

It's all in the title.. Why are there only 11 weaksauce options for jpg export!? no color model options, no output resolution options, no compression options....

 

I'm sincerely hoping this is another case of "adobe just didn't document the rest of the options"...

 

Anybody have any insight? Trying to export a document as jpg with the following settings:

 

RGB

maximum quality (10)

progressive

300ppi


Creating a dynamic action to use with app.doScript() method.

$
0
0

Since building dynamic actions is a topic unto itself, we often search for a reference thread to show somebody how to do this - and we often do so while trying to discuss work which is already involved and has nothing to do with actions or loading and playing them. Therefore I'm creating this thread to show an example and I'll paste the url to it when such questions arise.

 

Sometimes in Illustrator scripting we need to accomplish tasks which (sometimes counterintuitively) do not have scripting access via the DOM.

Fortunately since Illustrator CS6, they gave us the ability to play an action from a script with the app.doScript() command - which is not at all the same as Indesign's function of the same name. This one lets you play an action that exists inside the Actions panel. Immediately this may seem disappointing as users cannot be counted on to have specific actions at any given time.

However, they also gave the ability to load and remove actions from .aia action files. Your .aia file just needs to be somewhere and app.loadAction() can read it right into the Actions panel. Same with app.unloadAction(setName, actionName) - where (thanks to qwertyfly) using (setName, "") an empty string argument for the action name will remove the entire set. And when you try to remove an action that does not exist, well, it throws an error - which is how you can check for making absolutely sure that an action set is completely removed.

This may seem like a lot of work - to write a file, read it, play it and then discard it, often to do something that you'd think scripting should do in the first place.

 

Sometimes the action alone is enough to satisfy an objective - such as changing the document color mode. Other times it is necessary to alter actions in order to get use out of them - such as when you try to create a routine for saving a high-resolution "Export" JPG that is different in output and options form the "Save for Web" JPG. You may want to change some of the parameters such as resolution or the actual destination of the file.

Here is how you can do this.

 

First, record your action as you would normally: record a new set with a new action, call them what you need and then in the Actions flyout menu, save out a .aia file where you can find it. You can open the file in a text editor and read the contents - they are lines of special Actions 'code' which contains some cryptic text.

There are lines which look like a bunch of gibberish characters, they are hex-encoded strings for some parameter item which are strings, and they contain above them a number to signify the amount of characters inside the encoded string. (this is important later because this number also needs to be set properly when you put your own value in there) Other parameter items are simple numbers, but their keys are still obscured.

The truth is, while the string parameters are hexadecimal-encoded, the keys are both hexadecimal and decimal encoded! So if you wanted to know the special 4-letter keys, you'll have to run those through two decoder routines.

 

Next, you will need to put this entire string into your script and use some string-replacement or string-building to put your own data in those places of the action string where they matter. For example, putting your own file path into a save action.

 

And, after that you need to write a procedure for writing this new altered string to the file system and loading it into your Actions panel. Mind you, to leave things "as they were" you would need to remove the .aia file and the action that you have loaded.

 

Let's try with the save-a-jpeg workaround!

Here is the .aia string which is recorded from an Export JPEG action.

 

Screen Shot 2017-02-10 at 3.04.33 PM.png

/version 3

/name [ 8

  5475746f7269616c

]

/isOpen 1

/actionCount 1

/action-1 {

  /name [ 11

  4578706f7274204a504547

  ]

  /keyIndex 0

  /colorIndex 0

  /isOpen 1

  /eventCount 1

  /event-1 {

  /useRulersIn1stQuadrant 0

  /internalName (adobe_exportDocument)

  /localizedName [ 9

  4578706f7274204173

  ]

  /isOpen 1

  /isOn 1

  /hasDialog 1

  /showDialog 0

  /parameterCount 7

  /parameter-1 {

  /key 1885434477

  /showInPalette 0

  /type (raw)

  /value < 100

  0a00000001000000030000000200000000002c01020000000000000001000000

  69006d006100670065006d006100700000006f00630000000000000000000000

  0000000000000000000000000000000000000000000000000000000000000000

  00000100

  >

  /size 100

  }

  /parameter-2 {

  /key 1851878757

  /showInPalette 4294967295

  /type (ustring)

  /value [ 25

  2f55736572732f566173696c7948616c6c2f4465736b746f70

  ]

  }

  /parameter-3 {

  /key 1718775156

  /showInPalette 4294967295

  /type (ustring)

  /value [ 16

  4a5045472066696c6520666f726d6174

  ]

  }

  /parameter-4 {

  /key 1702392942

  /showInPalette 4294967295

  /type (ustring)

  /value [ 12

  6a70672c6a70652c6a706567

  ]

  }

  /parameter-5 {

  /key 1936548194

  /showInPalette 4294967295

  /type (boolean)

  /value 1

  }

  /parameter-6 {

  /key 1935764588

  /showInPalette 4294967295

  /type (boolean)

  /value 1

  }

  /parameter-7 {

  /key 1936875886

  /showInPalette 4294967295

  /type (ustring)

  /value [ 1

  32

  ]

  }

  }

}

 

We can see many parameters and their various cryptic blocks, but what you want to do is decode as many /type (ustring) elements as possible to get a sense of what the action is doing. At this website, you can do this fairly easily although tediously: Convert Hexadecimal To String Online

For example: "4a5045472066696c6520666f726d6174" turns into "JPEG file format".

In this action example, I am not worried about changing the other parameters dynamically - I'm assuming the settings used in my action are suitable for my purposes such as resolution being 300 for all time. The part I'd like to change is my file path so that my JPEG goes to the right place.

/value [ 25
2f55736572732f566173696c7948616c6c2f4465736b746f70
]

This line yields: "/Users/VasilyHall/Desktop"

So this is the line I'll need to replace.

 

Before anything else - here is how I'd embed the action string with ease. Using a text editor like Sublime text which lets you put many cursors down at one time, I can paste the action string in and find every nextline character. Then it's easy to highlight each line and put quotes around it as well as a comma in the end, or plusses - depending if you want to store the string as an array or a plain string in the script.

Screen Shot 2017-02-10 at 3.16.48 PM.png

I find the plusses a little cluttering so I opt to use this format:
var actionString = [     "string",

     "string"

].join("\n");

 

So my dynamic portion of the string which will be used with string replacement would look like this:

 

"  /value [ {{number_of_characters}}",

"  {{hex_encoded_path}}",

"  ]",

 

When the action is ready to be dispatched, a string replacement would look like this:

var myNewPath = Folder.myDocuments.toString() + "/Destination";

var myNewPathEncoded = hexEncode(myNewPath); // find a hex encode function via google
var thisActionString = actionString.replace("{{hex_encoded_path}}", myNewPathEncoded).replace("{{number_of_characters}}", myNewPath.length);

 

Now it's time to write the file.

var f = File(actionFileLocation);

f.open('w');

f.write(thisActionString);

f.close();

 

And now it's time to load the action.

app.loadAction(actionFileLocation);

 

Now we can play the action.

app.doScript("Export JPEG", "Tutorial");

 

This should save your jpeg, and as of this writing, this is the only way to get the JPEG export which isn't the Save-for-Web variety.

But, let us not forget the cleanup.

 

Remove the .aia file:

f.remove();

 

Remove the single-use dynamic action:

app.unloadAction("Tutorial", "");

 

There you have it: building dynamic actions to do simple and non-simple things, which regular scripting just can't do.

Select part of point text objects matching a regex expression

$
0
0

Hello! I'm looking for a way to run through a bunch of point text objects and select part of the string in each text object based on a regex expression. I found this awesome script that can do a regex find/replace, but my end goal is not to replace, but to apply a given character style to part of the string.

 

For example, I have two point text objects:

 

first / second / third

one / two / three

 

And I want to be able to select "/ second /" and "/ two /" to be able to apply a different character style to that part of each point text object. Also, i'm not sure that you can have parts of two different point text objects selected at the same time, so the script might need to apply the active text style to the matched string parts as it passes through them.

 

Is this impossible?

 

Thanks!

How to add in item to menu of Illustrator to activate script instead of File - Scripts menu?

$
0
0

I wrote a script and installed it to Presets, but in real work I find in veeeeery inconvenient to activate script with File > Scripts.

I don't need my own panel or toolbar, just menu item for File (or another) menu, or some else more convenient than File > Scripts.

I was seen in web some like "app.menus", but for InDesign, and there are no same in docs of Illustrator.

How to solve my problem?

ps

Illustrator CC2015, but I wish make my script compatible with CS6 or even lower.

Exporting X,Y coordinate of the center point of objects (Ai)

$
0
0

Hello all,

 

I have an illustrator document (Illustrator CC) with thousands of objects. I would like to export the X,Y coordinate of the center point of each objects --> either one by one or as one. Would you have any guidelines what os the best way doing this?

The aim is to use these objects in XML based format ( SVG) and manipulate them individually within HTML5.

 

If you have any suggestions for existing scripts would be delighted to learn where I can find them.

 

Look forward to your suggestions.

artg

Exporting X,Y coordinate of the center point of objects (Ai)

$
0
0

Hello all,

 

I have an illustrator document (Illustrator CC) with thousands of objects. I would like to export the X,Y coordinate of the center point of each objects --> either one by one or as one. Would you have any guidelines what os the best way doing this?

The aim is to use these objects in XML based format ( SVG) and manipulate them individually within HTML5.

 

Look forward to your suggestions.

artg

Cutting a circle

$
0
0

Hi all,

 

I need to make shapes like this based on a value for graph purposes - usually I would just create a cutting shape based on trig (this shape representing around 60%) and subtract it from the path - I have about 30 graphs to do and I need to base it on a variable, and I want to use script - I'm sure there must be a better way, and I'm hoping you guys have the answer.

 

Thanks in advance

 

Dave

cut.png

Undefined PDF Presets in Illustrator CS5

$
0
0

I'm encountering a problem when attempting to retrieve a list of PDF preset names in both AppleScript and JavaScript. Here are the steps I'm performing:

 

1) Launch Illustrator

 

2) Run the following AppleScript:

 

     tell application "Adobe Illustrator"

          PDF presets

     end tell

 

or JavaScript:

 

     app.PDFPresetsList;

 

When I run the AppleScript, I receive an error: "Adobe Illustrator got an error: an Illustrator error occurred: 1128353350 ('FNAC')" number 1200.  (Sometimes, 'ACVI' is listed instead of 'FNAC'.)

 

When I run the JavaScript, I receive: "Result: undefined"

 

If I retrieve Illustrator's properties via AppleScript, I can see that the PDF presets property appears as 'missing value'.

 

The only workaround I've found is to manually go to Illustrator and choose "Edit > Adobe PDF Presets", and then immediately click "OK" to close the window.  Whatever this does seems to fix the problem, and if I run the scripts again, they produce the correct results until Illustrator is relaunched, at which time the problem begins again.  I'm wondering if anyone else is experiencing this, and if anyone has come up with any other workarounds, preferably one that doesn't require manual work.

 

Much appreciated.

 

-Ben


How to export a selection?

$
0
0

Hi!

 

I looked at the scripting documentation about the ExtendScript API and can't find anything.

 

Do you know how to export a selection?

 

The "exportFile" is working fine for a document but there is no option for the selection

exportFile(svgFile, ExportType.SVG, exportOptions);

 

I want to do the same thing as within the menu (but without the dialogs)

Screenshot 2017-02-16 at 17.59.30.png

 

I also found that some people are duplicating the selection on another document and exporting it, but in my case this process is too "heavy", you see things opening / moving / closing and it's blocking the UI, that's is not possible for us as we are doing an Illustrator extension.

 

Thank you!

Batch Rename Everything

$
0
0

Hello, I want to batch rename everything.

What I want to do is similar to this script:

GitHub - shspage/illustrator-scripts: JavaScript scripts for Adobe Illustrator CSx.

This script collects every textframe to a pop-up window and let you modify the text and replace it.

 

What I want to do is you run a script in a document, open a pop-up window, and it contains the document's tree.

Something like this:

 

  • Layer 1
  • Layer 2
    • PathItem 1
    • PathItem 2
    • GroupItem 1
      • PathItem 3
      • PathItem 4
    • PathItem 5
  • Layer 3

 

And you can modify them like this:

 

layer 1

mainLayer

--rect

--circle

--mainGroup

----icon 1

----icon 2

--stuff

lastLayer

 

Here is some code I go so far:

(function() {  var allLayersName = "";  //store document's tree  var level = 0;  //store item's order  for (var i = 0; i < app.activeDocument.layers.length; i++) {  //loop throught all top layers    loopThroughAllItems(app.activeDocument.layers[i], level);  //go into layers, this is a recursive function  }  alert(allLayersName); //display document's tree  function loopThroughAllItems(elem, level) {    if(elem.typename == "GroupItem" || elem.typename == "Layer") {      allLayersName += Array(level).join("--") + elem.name + "\n";  //Array(level).join("--") means repeat "--" string level times, level = 2 you get "----"      level++;      for (var i = 0; i < elem.length; i++) {  //this line is where I stuck because illustrator doesn't have this kind of api        return loopThroughAllItems(elem.index(i), level);  //I think this line is also not gonna work XDD      }    } else {      if(elem.parent.index(elem.pareent.length-1) == elem) {  //detect if it is last element inside a group or layer        allLayersName += "--".repeat(level) + elem.name + "\n";        level--;  //decrease level so you get proper order      } else {        allLayersName += "--".repeat(level) + elem.name + "\n";  //there is still some items inside the group or layer      }    }  }})();

 

I stuck at line 12, 13 because illustrator doesn't have that api.

I don't know how to get a groupItem or layer's child in proper order.

 

Please Help~

Finger joints

$
0
0

Hello,

i am looking for a script to create a simple box with Finger Joints for laser cutting, any suggestions?

Input box, Width, Height, Depth, Finger width, Material thickness , Units

(My scripting knowledge  is not so good yet... The screenshot is from a plugin available  only for Corel)

Thanks a lot!

simple-box-finger-joints2.jpg

how to delete active artboard using illustrator cs6 javascript

$
0
0

Hi this hariprasad,

 

 

var myDoc = app.open(inputFile);

var ab = myDoc.artboards.getActiveArtboardIndex();   

myDoc.artboards[ab].remove();

 

i am using the above code to delete active artboard using javascript

but i am getting an illustrator error occured 1128549443 ('CDLC') error

 

any please help me how to delete active artboard using javascript in illustrator cs6

SVG and JS problem

$
0
0

i am making a world map in SVG and i have to make such dialog boxes with some contact info and stuff... the text in the boxes are typography elements and every country has its own dialog box

 

for instance norway: dialog-no

 

and they are all grouped

 

 

 

then i go into javascript

 

and use this code

 

$("#norway").click(function(){

 

 

    $("#dialog-no").show(); 

 

 

    });

 

to show the boxes, but when i click inspect it says that the id of the norway country is something with polygon #norway .st7

 

so i tried type that inside the click function, but still nothing appears! what the heck is wrong here?

Viewing all 3671 articles
Browse latest View live


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