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

Script to resize text to fit box

$
0
0

I currently have a box area and I need to have text fit into that box and retain it's proportions either height or width.

I can partially accomplish this by setting my type and doing an envelope distort (Alt + Ctrl + C) my results are this:

Screen Shot 2019-02-15 at 10.52.43 AM.png

The problem with this is that the text is stretched out and forced to fit.  In some cases this would be fine but not in my specific case.  Here is an example of it being just two characters.

 

Screen Shot 2019-02-15 at 10.55.13 AM.png

I would need it to be like this:  Screen Shot 2019-02-15 at 10.57.45 AM.png

I need it to be that if fits either height or width but not forced to do both.  I'm using illustrator cc 2019.

Any ideas how this can be accomplished?


Script sometimes "gets ahead of itself". How to pause between steps?

$
0
0

I had lots of help with this script and it works great… most of the time. Sometimes though, it seems to start resizing and scaling the artboard  before the "trace" step is complete causing some traced elements to lose their proper relative position. Is there a way to "pause" until the trace process is completed before continuing the script? I looked for something in ESTK but found nothing.

 

Of course, any other critiques to make this script better are welcome.

 

var doc = app.activeDocument;   
var pItems = doc.pathItems; 
var Selected = doc.selection[0] 
var Tracing_Preset = '[Default]';   
var sel = doc.selection;   
var f =15; //percent of current size 


//~ Trace Fingerprint 

for(var i = 0; i<sel.length; i++){     if(sel[i] == '[RasterItem ]'){         var pic = sel[i].trace();         pic.tracing.tracingOptions.loadFromPreset(Tracing_Preset);         pic.tracing.expandTracing().selected = true;         }   
}   
//Scale Fingerprint 
for ( var i = 0; i < pItems.length; i++ ) {     pItems[i].resize( f,f,true,true,true,true,f,Transformation.DOCUMENTORIGIN ); 
}; 


//~ Fit Artboard to Fingerprint 
function fitArtboards() { 
     if (app.documents.length == 0) {           alert('Open a document before running this script');                return;      } else {           for (var i = 0; i < documents.length; i++ ) {                app.activeDocument = documents[i];                app.activeDocument.artboards[0].artboardRect = app.activeDocument.geometricBounds;                redraw();           }      } 
} 

fitArtboards(); 

Illustrator VBA scripting 101 - via Excel

$
0
0

This post will attempt to introduce newcomers to Illustrator Visual Basic Scripting (well, not actually vbs, but rather tru VBA, Visual Basic for Applications). I personally prefer vba over bvs for a number of reasons. First, I always have Excel and Illustrator open, so it makes sense for me use it to drive Ai. Second, I usually need to transfer data between the two programs. Third...I love the Excel IDE...ok, let's get right into it.

 

 

- Open Excel

- hit Alt+F11, to bring up the editor

- in the Tools menu, click on References...

- add a reference to "Adobe Illustrator CS5 Type Library"

- in the Personal.xls (or in any other book) add a Module. Personal is a global workbook that is always available. If you don't see it, go back to Excel and record a macro, anything will do. That will create the Personal file.

- and type the following in that module

- we have to continue the tradition and do the "HelloWorld" script

 

Sub helloWorld()    Dim iapp As New Illustrator.Application    Dim idoc As Illustrator.Document    Dim iframe As Illustrator.TextFrame        Set idoc = iapp.ActiveDocument    Set iframe = idoc.TextFrames.Add        iframe.Contents = "Hello World from Excel VBA!!"        Set iframe = Nothing    Set idoc = Nothing    Set iapp = Nothing
End Sub

 

- save Personal book

- open Illustrator and create a new document first

- to run, move the cursor anywhere inside the Sub...End Sub and hit F5

 

that's it for now...in the following posts we'll move the text to the middle of the page, create new documents, get data from an Excel Range to Illustrator, get data from Illustrator text frame to an Excel Range...and more, hopefully.

 

questions? comments?

Drawing a rectangle of exact size of the artboard?

$
0
0

Has anybody written a JS script to to draw a rectangle on an active document which would be exact size as the document's artboard?

I find it very inaccurate and cumbersome trying to draw such rectangle by hand.

 

Please let me know where such JS code can be found. I have not done any Illustrator scripting beyond the "Hello world".

 

Thanks

franK

How to hide a named Group?

$
0
0

I want to hide a named group in Javascript. I've tried this (and other things), but no go. What is (are) my errors?

 

var idoc = app.activeDocument;  
var myGroup = idoc.groupItems.getByName('Bookmark_Ill');
myGroup.visible = 0;

 

This is the hierarchy of the file. All items in the "Text" layer are groups. "Bookmark_Ill" is a named group.

Where can I find Adobe Illustrator 2018 scripts?

$
0
0

I’m looking for a website where I can find scripts others have created that I can use in Adobe Illustrator 2018.

Change position of layer to top left of the art board using script

$
0
0

Hi guys, i just want to ask how to change the position of the layer to top left in the art board using script. I have a code here that i found through searching but it will only change the position to the center of the art board and i tried changing it to make the position to top left but i cant seem to make it right. can you guys please help me. it would be a huge help, The code is below.

var docRef = app.activeDocument;

 

   with (docRef) {

   rulerOrigin = [0,0];

   var docVB = visibleBounds;

 

   var transX = (width / 2) - ((docVB[0] + docVB[2]) / 2);

   var transY = (height / 2) - ((docVB[1] + docVB[3]) / 2);

  

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

   for (var j = 0; j < layers[i].pageItems.length;j++) {

   layers[i].pageItems[j].translate(transX, transY);

  }

  }

  }

After adding the cut property to the script, it crashes.

$
0
0

I'm cutting the layer and giving the crash after the script runs a bit. if (eheLayer.pageItems.length) { ehetLayer.pageItems[0].selected = true; app.cut(); } dest.hidden = true;


Toggling Create sub-folders in Export for Screens from a script

$
0
0

I have a fairly complex script that exports different things from an Illustrator document. I am using document.exportForScreens to easily export all artboards at once. However, I can't find a way to turn off Create sub-folders in the script. Is that possible?

Position on script seems to be off

$
0
0

Screen Shot 2019-02-20 at 11.20.14 AM.png

I have the above file and when I run my script.  The text appears all the way to the left.  The rulers show that 0, 0 is supposed to be at the beginning of the document.

This is my code:

 

var text = doc.textFrames.add();

text.position = [0,0];

text.textRange.size = 60;

text.textRange.characterAttributes.fillColor = col;

text.contents = "Scripting";

 

I have also tried

text.top = 0;

text.left = 0;

 

Neither of these work, the script type is positioned in the same place.  Any ideas what I'm doing wrong?

How Can I See Javascript Script Debugging In Adobe Illustrator CC 2015.0.0?

$
0
0

I have written a Javascript script to run in Illustrator so that it can create particular irregular polygon paths for me when I need it. Some of the lines being drawn are not what I was expecting and it's at this point that I would usually add some debugging lines into my code to see what's what. As far as I can tell, in Adobe Illustrator, I need to add the lines

 

$.write(myValue);

$.writeln(myValue);

 

In the past, when using previous version of Adobe Illustrator, I can recall a window appearing with my debugging in it. On this current version:

 

v2015.0.0

 

I cannot seem to find it anywhere. I have googled this question a bit and I have only come away more confused. How can I see my debugging for my simple script? Do I need a plugin? Can anyone recommend one?

 

Thanks,

Phedg1

Scripts that copy the width/height of the object to the clipboard

$
0
0

Could you create two scripts that copy the width/height (only a fractional number without "px") of the selected object (or group of objects) to the clipboard?

Script to select layer by name and change font

$
0
0

I'm trying to automate the conversion of some maps in Illustrator from one language to another. I already have a script that automatically replaces the English with my target language based on a word list (thanks to help here!), but I am having trouble figuring out how to select certain layers in the files and automatically change the font and font tracking on all text boxes in that layer.

 

I can't even get a script to select a layer by name...I'm not really experienced with scripting.

 

Can anyone point me in the right direction?

I have multiple layers with constant naming throughout (like "City Names" and "River Names") and I want to select each layer based on its name and then choose a font for everything on that layer as well as change the tracking to 0.

 

Thanks for any help you can give.

In need of a script for Adobe Illustrator to replace text characters

$
0
0

I'm trying to do something in Illustrator and, from what I've read, the only way to do it is with a script. The problem with that, however, is that I don't know the first thing about writing scripts for Illustrator, so I was hoping someone here could help.

 

What I'm trying to do is find a particular text character in one font and then replace it with an emoji from the free version of Font Awesome. The script should start with the letter A and work it's way through the entire alphabet until each character is replaced with a corresponding Font Awesome emoji.

 

In other words, after running the script, this string of characters (ABCDEFGHIJKLMNOPQRSTUVWXYZ) would instead show a series of Font Awesome emojis.

 

I don't know if it matters in creating the script, but the originating text that the script will be run on is in Arial.

 

Does anyone know of a script that can do this? If so, can you please point me to it so that I can give it a try?

 

Thanks :-)

How to find out the image size?

$
0
0

How to find out the image size values(Width and height) in illustrator CS3 using any script. I tried but i got only the document height and width. I need to find out the image BoundingBox value of width and height. Kindly advice me.


All Group to Ungroup Script

Sort artboards by name

$
0
0

We have over 50 artboards in most of our documents.  Is there a way to sort the artboards as listed in the artboards panel by name via script?

select by layer name

$
0
0

I need to select a specific layer or group by name.  What is the correct syntax to do this with Javascript?

Paste in place

$
0
0

I want to use Paste In Place function in Illustrator using Illustrator javascript. Now I am using app.paste() it will paste the content but the position may differs so i want to paste in exact place how I did copy.

Can anyone please help on this.

Illustrator Script code for removing selected items

$
0
0

Hello, I have an Illustrator script to go through certain functions and after it runs there are items selected that I need deleted. I cannot figure out the simple script to remove the selected items. I tried

 

var docSelected = app.activeDocument.selection;

docSelected.selected.remove();

 

but to no avail. Please help. I would greatly appreciate any tips and suggestions as I just need to know how to have the script to delete selected items. Thank you very much!

Viewing all 12845 articles
Browse latest View live


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