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

Call c++ with JSX

$
0
0

Hi all,

 

I was advised that I could call c++ libraries if I wanted to use some command that DOM didn't offer. I wanted to give it a try with the "select all" command but I never figured it out.

I found the .h file that seems to include the "select all" function but I have no clue on how to call it from JSX, does someone has an idea on how to do that ?

 

Thanks in advance for any help on that topic.

 

Loic


Illustrator Actions (Unlock All Layers) not persistent

$
0
0

Hi all

I hope this is the right section to post this.

But like the title says I have problems with Actions and the Unlock All Layers. As soon we shut down Illustrator and start it up again this part is gone. Reloading the saved Action will solve the problem, as long you don't restart Illustrator again.

This is what the action looks like when it is loaded:

Screen Shot 2011-10-04 at 10.47.51.jpg

This it like it is when Illustrator has restarted:

Screen Shot 2011-10-04 at 10.48.13.jpg

This has been tested on different operating systems and in CS4 and CS5.

Any idea how to solve this?

GroupItems are returning as Layers??

$
0
0

I have a layer that contains two clipping groups (groups with a clip mask and other art).  When I call layer.groupItems it returns an empty array.  When I call layer.layers it returns the two clipping groups.  I need to know if these layers are clipping groups, but if they are coming back as layers how can I figure that out?

removing paths

$
0
0

How can I select all paths with fill black 100% and remove them?

I tried the "script" below, but it doesn't give faults and the result stays the same (-> no remove of the items)

 

 

#target illustrator
var docRef=app.activeDocument;

for(i=0;i<docRef.pageItems.length; i++ ) {
    var pathRef = docRef.pageItems[i];
    if (pathRef.fillColor.black == 100) {
        pathRef.selected = true;
        pathRef.remove(i);
    };
};

 

 

I also tried: pathRef.remove(); but also here, the result is the same....

Generate artboards

$
0
0

Hi, why do I get  an error on the following sccript?

 

#target illustrator

var _doc = app.activeDocument;

var _msg = "Generate artBords";

var _count = Number(Window.prompt ("Enter Number of artboards max 100", 10, _msg));

var _size = Number(Window.prompt ("Enter artboard Size ", 50, _msg));

var _margin = Number(Window.prompt ("Enter artboard Margins ", 10, _msg));

 

var _artBoards =_doc.artboards;

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

    var _newRect = [];

    _newRect[0] =   i * ( _size + _margin );

    _newRect[1] = Math.floor(i/5) * ( _size + _margin );

    _newRect[2] = _newRect[0] + _size;

    _newRect[3] = _newRect[1] + _size;

 

 

  $.writeln("newArtBoard: " + _newRect);

 

//var _newArtBoard = _artBoards.add(_newRect);

app.activeDocument.artboards.add( _newRect );

 

 

}

Changing decimal values to fractions

$
0
0

Does anyone know of a good way to convert decimal values to fractions for use in inch measurements? I have a script that works great but it returns values like 5.5638 and I'd rather it return the closest fraction answer like 5 9/16. 1/16ths would be great, but I'd settle for 1/8ths.

 

I started trying to come up with a large if with lots of > and < conditions, but I figured if anyone has already done this it might be better not to reinvent the wheel.

 

Thanks.

Exporting an .ai file to a bitmap file

$
0
0

In Illustrator Scripting (VBscripting), how can you export an ai file to a bitmap file?

 

In Illustrator you can open an ai file and by selecting the Export option you have a choice of formats and one of them is BMP.  How can this be done in scripting?  I did look at the AIExportType, but BMP is not in the list.

 

aiJPEG = 1

aiPhotoshop = 2

aiSVG = 3

aiPNG8 = 4

aiPNG24 = 5

aiGIF = 6

aiFlash = 7

aiAutoCAD = 8

 

I will also need to do this same method by Exporting to an eps file.

 

The task is the following:

 

When a client uploads an image file, we need to automatically export the file to bmp and to esp, thus having 3 files (original upload, bmp, and esp).  The file types that we are exporting, so far, will be ai, esp, and pdf (more to follow I am sure).

 

We also need to get information about each file.

Is it vector or a bitmap?

Color:  RGB, CMYK, or Pantone?

Is there text or curves or both?

What is the DPI resolution?

What is the image size?

 

Any help would be beneficial.

 

Thanks,

 

Tom

 

 

 

 

 

 

 

 

 

 

 

 

live trace (vectorisation de l'image)

$
0
0

i would like to live trace (vectoriser) a pdf drawing but i can't open the dialog box live trace(vectorisation de l'image) on version 17,1  could you help ?

p.s. my illustrator is french version but i understand english writing


How to select the outermost pathPoints in Compound or Grouped pathItems?

$
0
0

Hello Hiroyuki, Carlos and AISComm.,

 

i have an number of paths in a group each filled with single colors.

3) I hoped there is a way to select the outermost pathPoints on the perimeter of the group?

 

The following script i just found by wysiwygbill at: http://forums.adobe.com/message/3046178#3046178  ..,he writes: "..it's supposed to return the outermost bounds of the group". So it may save time in adapting it to select the points at the outermost bounds.

Please let me know if this is helpful and can be done?

 

Thanks as always, for your valued help and effective coding,

Jeff

 

 

function getRealVisibleBounds(grp) {

     var outerBounds = [];

     for(var i = grp.pageItems.length - 1; i >= 0;i--)  {

          var bounds = [];

          if(grp.pageItems[i].typename == 'GroupItem') {

               bounds =  getRealVisibleBounds(grp.pageItems[i]);

          }

          else if((grp.pageItems[i].typename == 'PathItem' || grp.pageItems[i].typename == 'CompoundPathItem')

               && (grp.pageItems[i].clipping || !grp.clipped)) {

               bounds = grp.pageItems[i].visibleBounds;

          }

          if (bounds.length > 0) {

               outerBounds = maxBounds(outerBounds,bounds);

          }

     }

     return (outerBounds.length == 0) ? null : outerBounds;

}

 

function maxBounds(ary1,ary2) {

     var res = [];

     if(ary1.length == 0)

          res = ary2;

     else if(ary2.length == 0)

          res = ary1;

     else {

          res[0] = Math.min(ary1[0],ary2[0]);

          res[1] = Math.max(ary1[1],ary2[1]);

          res[2] = Math.max(ary1[2],ary2[2]);

          res[3] = Math.min(ary1[3],ary2[3]);

     }

     return res;

}

 

function positionVisible(grp,x,y)

{

     var bounds = getRealVisibleBounds(grp);

     var newX = x + (grp.left - bounds[0]);

     var newY = y + (grp.top - bounds[1]);

     grp.position = [newX,newY];

}

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.

Script to work around Illustrator bugs

$
0
0

Newbee here,   We are working in Illustrator CS5.  I have put together some scripts & Actions to automate several parts of our work.

     I'll start with what we have now.  Plus what we have now works on both Mac & PC & if there is a way to work around these BUGS it will need to work on both the Mac's & PC's.

 

1)  We have an .ai file (our default format) that we can open up & inside some text will automatically fill in when we run a script. (see custom script at bottom) Some text boxes will fill in the date based on the present date on our computer, some text boxes will fill in a name based on the name of the electronic .ai file.

Screen shot 2012-10-10 at 4.33.22 PM.jpg

 

See red boxes.

Screen shot 2012-10-10 at 4.33.40 PM.jpg

 

One difficulty that I worked out is, sometimes in one of the fields in the file, it needs to have a name consisting of only 4 sections (or 3 dashes). In example:  ILSLIM = 1,  EXAMPLE = 2, TEST = 3, & AA01 = 4.

Screen shot 2012-10-10 at 4.34.21 PM.jpg

So when this happens then the last dash in this one text box on our format (Not any of the other text boxes) will need the 3rd dash removed (now it is only 3 sections because TESTAA01 are now one).

Screen shot 2012-10-10 at 4.43.05 PM.jpg

So I created an Illustrator "Action" that will after the "ChangeFileNameDate" script is run, the "Action" will select the one text box & then run the "Find and Replace" to delete the 3rd dash as seen above.

 

 

NOW THE PROBLEMS!  (Illustrator bugs)

 

1)  In the Illustrator "Actions" when you record an "Action" & use the "Insert Menu Item..." to put a Script in, it will work.  BUT when you quit out of Illustrator & then relaunch it the custom Script will disappear. I looked into this & this is a known bug for years in Illustrator that is still not fixed.

http://js4ai.blogspot.com/2012/03/how-to-permanently-tie-script-to-action.html

Screen shot 2012-10-10 at 5.00.50 PM.jpg

 

Screen shot 2012-10-10 at 5.01.19 PM.jpg

 

Screen shot 2012-10-10 at 5.01.33 PM.jpg

Works untill you quit out & relaunch.

 

BEFORE QUIT.

Screen shot 2012-10-10 at 5.01.41 PM.jpg

AFTER RELAUNCH.

Screen shot 2012-10-10 at 5.05.03 PM.jpg

 

SO the only work around I can get to work for now is to "Insert Menu Item..." "Other Script..." & this will stay even after relaunch BUT then every time we run the "Action" we have to manually select the script. (CRAP)

Screen shot 2012-10-10 at 5.13.54 PM.jpg

Screen shot 2012-10-10 at 5.14.08 PM.jpg

Still here after relaunch.

Screen shot 2012-10-10 at 5.14.25 PM.jpg

 

PLUS A BUG with recording the "Find and Replace".  In case you do not know, when you save "Actions" in Illustrator you can; save any of the actions that require a dialog box; 1) to either have the dialog box come up so you can enter whatever you need into it or 2) you can have the dialog box NOT come up & the action will just do what it had in it when you recorded it.  This feature is turned on or off by clicking the box next to the check mark on or off (see pic).

Screen shot 2012-10-11 at 9.17.08 AM.jpg

 

So the BUG is, for my "Actions" that use the "Find and Replace" to delete the dash to work for some reason I have to have the first "Find and Replace" steps dialog botton ON so that the "Find and Replace" dialog box will open up.

 

     Let me explain, when you record to use the "Find and Replace" it will work fine even with the dialog box option clicked off; but if you quit Illustrator & then relaunch it & try to run the "Actions" that have the "Find and Replace" in them then Illustrator will crash.  So the only work around that I found for this CRAPPY BUG is to simply have the 1st "Find and Replace" in the recorded "Action" with the dialog box set to on (to open up when Action is run) & then we have to manually close it.  We don't have to type anything inside of it.  We simply have to have it open & then close.  Then for some reason the rest of the recorded "Actions" will run with out the dialog boxes opening with the deleteing of the 3rd dash as like when I 1st recorded it.

 

     So basically, if I want the "Actions" to work at this point I would have to do this;  every time I relaunch Illustrator I would need to manually load the custom script into the "Actions" & I would need to open & close the "Find and Replace" box.  This is CRAP the whole point of "Actions" & Scripts are so I can do everything MANUALLY, NO.  We should be able to have it work for us!

 

OR maybe this would be the best solution!


     If inside the "ChangeFileNameDate" custom script it could simply open & then close the "Find and Replace" box (that would solve the crashing with "Find and Replace" in "actions")  then the custom script could cause the "Action" to play instead of the "Action" causing the custom script to play.  Then all we would have to do is drag down to the custom script from "File" & run that.  No crashing, No babysitting.

 

DOES ANYONE KNOW HOW OR IF THIS IS POSSIBLE?  To add to the attached script:

1)  At the beginning to open & close the "Find and Replace" box.

2)  At the end to cause a saved "action" to run.

 

WE WOULD BE SO VERY, INCREDIBLY, EXTREMELY GRATEFUL!

 

 

//////////////////////////////////////////////////////////// english //
// ----------------------
// -=> WR-DateAndTime <=-
// ----------------------
//
// A Javascript for Adobe Illustrator
// by Wolfgang Reszel (ai-js@rumborak.de)
//
// Version 0.9 from 22.9.2011
//
// This script inserts the actual date or the actual time to a
// predefined position in the document.
//
// To define the position, you'll have to create an textobject and
// execute this script while the object is selected. The whole object
// has to be selected and not words or letters. You can mark more
// objects, if you select each object separate and execute
// the script on it.
//
// With the placeholders {DATE} and {TIME} you are able to define a
// particular point, where the date or the time should be replaced.
// If there is no placeholder in the textobject
// "{FILENAME}{FILEEXT} ({DATE}, {TIME})" will be used as standard placeholders.
//
// To update the date and time execute this script without any object
// selected.
//
// There are some additional placeholders:
//   {FILE}     - complete document-filename with path
//   {FILEPATH} - only the documents filepath
//   {FILENAME} - the filename of the document
//   {FILEEXT}  - the file extension of the document inclusive dot
//
// On my system this script can't see the path of the document, when
// it was opened directly from windows Explorer (double click).
//
// In Illustrator CS it is now possible to edit a DateAndTime-Object.
//
// To enable the english messages and date-format change the "de"
// into "en" in line 90.
//
// Sorry for my bad english. For any corrections send an email to:
// ai-js@rumborak.de
//
//////////////////////////////////////////////////////////// Deutsch //
// ----------------------
// -=> WR-DateAndTime <=-
// ----------------------
//
// Ein Javascript fuer Adobe Illustrator
// von Wolfgang Reszel (ai-js@rumborak.de)
//
// Version 0.9 vom 30.9.2011
//
// Dieses Skript fuegt das aktuelle Datum und die aktuelle Uhrzeit an
// eine vorher bestimmte Stelle im Dokument ein.
//
// Um eine Stelle zu bestimmen, muss man ein Textobjekt erzeugen, es
// markieren und dann dieses Skript aufrufen. Es muss das gesamte Objekt
// ausgewaehlt sein, nicht etwa Buchstaben oder Woerter. Es lassen sich
// nacheinander auch mehrere Objekte als Datum/Uhrzeit markieren.
//
// Mit den Platzhaltern {DATE} und {TIME} (in geschweiften Klammern)
// kann man bestimmen, wo genau im Text das Datum und die Uhrzeit
// erscheinen soll. Sind die Platzhalter nicht vorhanden, wird
// automatisch "{FILENAME}{FILEEXT} ({DATE} - {TIME})" verwendet.
//
// Zum Aktualisieren des Datums/Uhrzeit muss man dieses Skript aufrufen
// wenn kein Objekt ausgewaehlt ist.
//
// Es gibt noch einige zusaetzliche Platzhalter:
//   {FILE}     - kompletter Dateiname mit Pfad
//   {FILEPATH} - nur der Verzeichnispfad des Dokuments
//   {FILENAME} - der Dateiname des Dokuments
//   {FILEEXT}  - die Dateiendung des Dokuments inklusive Punkt
//
// Auf meinem System kann der Pfad nicht ermittelt werden, wenn das
// Dokument vom Windows Explorer geoeffnet wird (Doppel-Klick).
//
// InÿIllustrator CSÿkann man nun ein Datum/Uhrzeit-Objekt bearbeiten.
//
// Um dieses Skript mit deutschen Meldungen und Datumsformat zu
// versehen, muss in Zeile 90 das "en" durch ein "de" ersetzt werden.
//
// Verbesserungsvorschlaege an: ai-js@rumborak.de
//

//$.bp();

// -------------------------------------------------------------------

var language="en";   // "de" fuer Deutsch

// -------------------------------------------------------------------

var WR="WR-DateAndTime v0.9\n\n";

var AIversion=version.slice(0,2);

if (language == "de") {

  var format_preset = "{FILENAME}{FILEEXT} ({DATE} - {TIME})";  var MSG_unsetmark = WR+"Dieses Objekt ist als aktuelles Datum/Uhrzeit markiert, soll die Markierung aufgehoben werden?";  var MSG_setmark = WR+"Soll dieses Textobjekt als aktuelles Datum/Uhrzeit markiert werden?";  var MSG_askformat = WR+"Soll das Textobjekt als Datum/Uhrzeit formatiert werden? Formate:\n{DATE}, {TIME}, {FILE}, {FILEPATH}, {FILENAME} und {FILEEXT}:"  var MSG_editformat = WR+"Datums-/Uhrzeitformat bearbeiten (Leer = entfernen). Formate:\n{DATE}, {TIME}, {FILE}, {FILEPATH}, {FILENAME} und {FILEEXT}:"  var MSG_notexto = WR+"Kein Textobjekt!";  var MSG_selectedmany = "Zum Markieren als aktuelles Datum/Uhrzeit darf nur ein Textobjekt ausgew\xE4hlt sein und falls Sie die Daten aktualisieren wollen, darf kein Objekt ausgew\xE4hlt sein.";  var MSG_nodocs = WR+"Kein Dokument ge\xF6ffnet."  var Timeformat = 24;  var TimeSep = ":";  var AM = " am";  var PM = " pm";  var Dateformat = "dd.mm.yyyy";

} else {

  var format_preset = "{FILENAME} ({DATE}, {TIME})";  var MSG_unsetmark = WR+"This object is marked as actual date'n'time, do you want to remove the mark?";  var MSG_setmark = WR+"Do you want to mark the selected textobject as actual date'n'time?";  var MSG_askformat = WR+"Do you want to mark the textobject as actual date'n'time? Formats:\n{DATE}, {TIME}, {FILE}, {FILEPATH}, {FILENAME} and {FILEEXT}:"  var MSG_editformat = WR+"Edit date'n'time (empty = remove). Formats:\n{DATE}, {TIME}, {FILE}, {FILEPATH}, {FILENAME} and {FILEEXT}:"  var MSG_notexto = WR+"No textobject!";  var MSG_selectedmany = "To mark as actual date'n'time, you have to select only one textobject. If you want to update the date'n'time-objects, there must be no object selected.";  var MSG_nodocs = WR+"You have no open document."  var Timeformat = 12;  var TimeSep = ":";  var AM = " am";  var PM = " pm";  var Dateformat = "yyyymmdd";

}

var error=0;

if (documents.length<1) {  error++;  alert(MSG_nodocs)
}

if (error < 1) {  date_n_time();
}

function TodayDate()
{
  var Today = new Date();  var Day = Today.getDate();  var Month = Today.getMonth() + 1;  var Year = Today.getYear();  var PreMon = ((Month < 10) ? "0" : "");  var PreDay = ((Day < 10) ? "0" : "");  if(Year < 999) Year += 1900;

 var theDate = Dateformat.replace(/dd/,PreDay+Day);
 theDate = theDate.replace(/mm/,PreMon+Month);
 theDate = theDate.replace(/d/,Day);
 theDate = theDate.replace(/m/,Month);
 theDate = theDate.replace(/yyyy/,Year);
 theDate = theDate.replace(/yy/,Year.toString().substr(2,2));

 return theDate;
}

function TodayTime()
{
  var Today = new Date();  var Hours = Today.getHours();  var Minutes = Today.getMinutes();  var Suffix = "";  if (Timeformat == 12) {    if (Hours >= 12 ) {
 Suffix = PM;
 } else {
 Suffix = AM;
 }
 if (Hours >= 13) {
 Hours = Hours - 12;
 }
 if (Hours < 1) {
 Hours = Hours + 12;
 }
 }  var PreHour = ((Hours < 10) ? "0" : "");  var PreMin = ((Minutes < 10) ? "0" : "");  return PreHour+Hours+TimeSep+PreMin+Minutes+Suffix;
}

function DateUpdate(Name) {
  var docpath = activeDocument.path.fsName;  var docname = activeDocument.name.replace(/(.*?)(?:\.([^.]+))?$/,'$1');  var extension = activeDocument.name.replace(/(.*?)(?:(\.[^.]+))?$/,'$2');  if (docpath.slice(2,3) == "\\") {    docsep = "\\";  } else {    docsep = ":";  }  var content = Name.slice(11);  var content = content.replace(/\{FILE\}/,docpath+docsep+docname);  var content = content.replace(/\{FILEPATH\}/,docpath);  var content = content.replace(/\{FILENAME\}/,docname);  var content = content.replace(/\{FILEEXT\}/,extension);  var content = content.replace(/\{DATE\}/,TodayDate());  var content = content.replace(/\{TIME\}/,TodayTime());  return content;
}

function date_n_time()
{
  if (selection.length == 1) {    if (selection[0].typename == "TextArtItem" || selection[0].typename == "TextFrame") {      if (selection[0].name.slice(0,11) == "actualDate:") {        dateformat = selection[0].name.slice(11);        Check = false;        if (AIversion == "10") {          Check = confirm( MSG_unsetmark );        } else {          dateformat = prompt(MSG_editformat, dateformat);        }        if(dateformat != "" && Check) {          selection[0].contents = selection[0].name.slice(11);          selection[0].name="";          selection[0].selected = false;        }        if(dateformat == "" && !Check) {          selection[0].name="";          selection[0].selected = false;        }        if(dateformat && dateformat !="" && !Check) {          selection[0].name="actualDate:"+dateformat;          selection[0].contents = DateUpdate(selection[0].name);        }      } else {        dateformat = selection[0].contents;        if(dateformat.search(/\{DATE\}/) == -1 && dateformat.search(/\{TIME\}/) == -1 && dateformat.search(/\{FILE[A-Z]*\}/) == -1) dateformat = format_preset;        Check = false;        if (AIversion == "10") {          Check = confirm( MSG_setmark );        } else {          dateformat = prompt(MSG_askformat, dateformat);        }        if (dateformat || Check) {          selection[0].name="actualDate:"+dateformat;          selection[0].contents = DateUpdate(selection[0].name);          selection[0].selected = false;        }      }    } else {      alert ( MSG_notexto );    }  } else if (selection.length > 1) {    alert ( MSG_selectedmany );  } else {    if (AIversion == "10") {      var textArtItems = activeDocument.textArtItems;      for (var i = 0 ; i < textArtItems.length; i++)      {        if (textArtItems[i].name.slice(0,11) == "actualDate:") {          textArtItems[i].selected = true;          textArtItems[i].contents = DateUpdate(textArtItems[i].name);        }      }    } else {      var textFrames = activeDocument.textFrames;      for (var i = 0 ; i < textFrames.length; i++)      {        if (textFrames[i].name.slice(0,11) == "actualDate:") {          textFrames[i].selected = true;          textFrames[i].contents = DateUpdate(textFrames[i].name);        }      }    }  }
}

All Group to Ungroup Script

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?

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

Is it possible to create a panel with JavaScript?

$
0
0

Hi friends

 

As I´m studying JavaScript and the user interface creation...would like to ask (more for curiosity):

 

Is it possible to create a new panel for Illustrator using JavaScript? Or this is only possible using C++?

 

(in the Window Class UI we have the "palette" creation method..so wondering the result of it too)

 

Thank you a lot

Gustavo


Illustrator script to open file in Photoshop

$
0
0

The Bridge SDK has a script to open a selected file in Photoshop.

Can this  be done from Illustrator instead?

 

It seems that the cross-dom function open() should work in either an illustrator or bridge script, yet the following does NOT work in Illustrator.

Fresh from the Bridge 5.1 SDK, it doesn't work in Bridge either, but that's for a different forum.

 

var t = app.activeDocument.fullName;

Photoshop.open(new File(t));

 

It provides me with Error 2: Photoshop is undefined.

 

So, any ideas on how to make this work?

This is all leading up to the real problem, which is to create a 150dpi jpg file, which Illustrator won't do.

 

Thanks All.

--Alex

Export selected artboards, PNG24 javaScript?

$
0
0

Hi All,

I'm trying to do some workflow enhancements. For our games we need to export to PNG at different resolutions for different mobile devices. I use a artboard per asset and currently manually export 3 times (using file/export/png with use artboards option), at 72 dpi, 144 dpi and 33.75 dpi.

 

I've been modifying a simple Javascript I downlaoded and have got it save to different fixed locations at different scales. All good. However exporting every artboard each time will cause issues with our version control system and take too long. It's not really a solution.

 

So I need a way to either only export the current selected artboards (which I believe can't be done) or somewho show the artboard range dialog that the system uses. Either of those would be a good solution.

 

Can it be done?

I'm using CS5.

Here is where I'm at so far - please be kind, I'm a dabbler and not very experienced!

 

var docRef = app.activeDocument;
var num_artboards = docRef.artboards.length;
var getName = app.activeDocument.name;
var fileName = getName.slice(0, -3);


for (var i = 0; i < num_artboards; i++ )
{    var destFile = new File("/Users/malcolmreed/Desktop/tests/double/" + fileName + "_" + docRef.artboards[i].name + ".png");       var options = new ExportOptionsPNG24();    options.artBoardClipping = true;    options.matte = false;    options.horizontalScale = 200.0;    options.verticalScale = 200.0;    options.transparency = true;           docRef.artboards.setActiveArtboardIndex(i);       docRef.exportFile (destFile, ExportType.PNG24, options);   
}


for (var i = 0; i < num_artboards; i++ )
{    var destFile = new File("/Users/malcolmreed/Desktop/tests/standard/" + fileName + "_" + docRef.artboards[i].name + ".png");       var options = new ExportOptionsPNG24();    options.artBoardClipping = true;    options.matte = false;    options.horizontalScale = 100.0;    options.verticalScale = 100.0;    options.transparency = true;           docRef.artboards.setActiveArtboardIndex(i);       docRef.exportFile (destFile, ExportType.PNG24, options);
}

Break text area into text lines

$
0
0

I want to break text area with line breaks in it into seperate text lines using return as delineator. for example

 

"Line 1

Line 2

Line 3"

 

I would like as

 

"Line 1"

"Line 2"

"Line 3"

 

I could probably write something but curious if someone already wrote it. I found a few similar ones like

http://forums.adobe.com/thread/321610

 

but they seem to be broken for CC here is the script in case you're curious

 

/////////////////////////////////////////////////////////////////
//Divide TextFrame v.2.2 -- CS and up
//>=--------------------------------------
// Divides a multiline text field into separate textFrame objects.
// Basically, each line in the selected text object
// becomes it's own textFrame. Vertical Spacing of each new line is based on leading.
//
// This is the opposite of my "Join TextFrames" scripts which
// takes multiple lines and stitchs them back together into the same object.
// New in 2.1 now right and center justification is kept.
// New in 2.2 better error checking, and now will run on more than one text frame at a time.
//>=--------------------------------------
// JS code (c) copyright: John Wundes ( john@wundes.com ) www.wundes.com
//copyright full text here:  http://www.wundes.com/js4ai/copyright.txt
//////////////////////////////////////////////////////////////////


var doc = activeDocument;
var genError= "DivideTextFrame must be run on a point-text text-frame. ";
var ret_re = new RegExp("/[\x03]|[\f]|[\r\n]|[\r]|[\n]|[,]/");
if(doc){
        var docsel = doc.selection;        var sel = [];    //remember initial selection set         for(var itemCt=0, len = docsel.length ;itemCt<len;itemCt++){             if(docsel[itemCt].typename == "TextFrame"){                  sel.push(docsel[itemCt]);             }         }            if(sel.length){  //alert(sel.length+" items found.");            for(var itemCt=0, len = sel.length ;itemCt<len;itemCt++){                divide(sel[itemCt]);            }             }else{                alert(genError +"Please select a Text-Frame object. (Try ungrouping.)");        }      
}else{    alert(genError + "No document found.");
};

function divide(item){
             //get object position    var selWidth = item.width;
if(item.contents.indexOf("\n") != -1){          //alert("This IS already a single line object!");
}else{           //getObject justification    var justification = item.story.textRange.justification;             //make array          var lineArr = fieldToArray(item);          tfTop = item.top;          tfLeft = item.left;          item.contents = lineArr[0];          //for each array item, create a new text line          var tr = item.story.textRange;          var vSpacing = tr.leading;    var newTF;          for(j=1 ; j<lineArr.length ; j++){                    newTF = item.duplicate(doc, ElementPlacement.PLACEATBEGINNING);                    newTF.contents = lineArr[j];                    newTF.top = tfTop - (vSpacing*j);        if(justification == Justification.CENTER)        {             newTF.left = (tfLeft + (selWidth/2)) - (newTF.width/2);        }    else            if(justification == Justification.RIGHT)        {            newTF.left = (tfLeft + selWidth) - newTF.width;        }    else    {           newTF.left = tfLeft;    }                    newTF.selected = false;          }
}


function fieldToArray(myField) {                     retChars = new Array("\x03","\f","\r","\n");                    var tmpTxt = myField.contents.toString();                    for (all in retChars )                    {            tmpArr = tmpTxt.split(retChars[all]);                    }                     return tmpTxt.split(ret_re);          }    }

Applescript: Removing Groups and Layers

$
0
0

This should be a simple task, but I still haven't figured out how to do it.

 

I have a set of page items, and the are contained in groups inside of layers inside of layer inside of layers.

How can I remove the layers easily?

I looked at the reference guide, and attached the screenshot where it explains how to use the "delete" command to remove containers of objects.

But I still dont' understand how to order the command correctly:

delete page item of layer?

delete layer of page item?

delete page item of layer of page item?

None of these work.

For now, I've just used an action, but it would be helpful if I could do it within a script.

 

Any help is appreciated.

Thanks,

 

Ben

Screen shot 2009-12-21 at 10.08.25 PM.png

Now draw your own ScriptUIGraphics graphics! (1st testing)

$
0
0

Hey everyone, I've made this little system of drawing ScriptUIGraphics from your illustrator document.  Please be advised, the graphics resulting from this are not anti-aliased and look bad at medium sizes --> terrible at small sizes, but they may help with making some dynamic icons for some really specific scriptUI purposes.

 

 

Basically, you just draw something in an AI doc, run this window and use the function from it as well as the object resource string to recreate that drawing in your own scriptUI windows.

This method only uses straight lines and ellipses when it detects ellipses.  After seeing the quality of these drawings, I'm thinking for the prettier icons you'd surely want to embed images into your UI, but there may come a very very rare time when there exists a need for some dynamic image with many states, so this may be what it may end up perhaps being useful for.

 

Attached are screenshots with original drawing (artboard is 100x100px), the captured image drawn in window and last, pretty much the same- is the result drawn from object resource string.  The screenshots JPEGs have smoothed out the little icons, making them look actually better than they really are!

 

Edit: 

     Oh yes, I did need to mention: the colors used can be any color, spot/Lab included!  They just get changed to some version of RGB for rendering.

// ScriptUI Graphics Display by Vasily


function graphicsDisplay(){
    function itemShape(myShape){        // Going to test for circles.        var shapeKind={            isrectangle: null,            iscircle: null,            isellipse: null        };        if(myShape.typename=='PathItem' && myShape.pathPoints.length == 4){ // RECTANGLE CHECKER            //--------------------2 diagonals-------------------------            var recEquaDistOne = parseInt(Math.pow((myShape.pathPoints[0].anchor[0] - myShape.pathPoints[2].anchor[0]),2) +            Math.pow((myShape.pathPoints[0].anchor[1] - myShape.pathPoints[2].anchor[1]),2)); // diagonal            var recEquaDistTwo = parseInt(Math.pow((myShape.pathPoints[1].anchor[0] - myShape.pathPoints[3].anchor[0]),2) +            Math.pow((myShape.pathPoints[1].anchor[1] - myShape.pathPoints[3].anchor[1]),2)); // diagonal            //---------------------4 sides of rectangle---------------            var sideA = parseInt(Math.pow((myShape.pathPoints[0].anchor[0] - myShape.pathPoints[1].anchor[0]),2) +            Math.pow((myShape.pathPoints[0].anchor[1] - myShape.pathPoints[1].anchor[1]),2));             var sideB = parseInt(Math.pow((myShape.pathPoints[1].anchor[0] - myShape.pathPoints[2].anchor[0]),2) +            Math.pow((myShape.pathPoints[1].anchor[1] - myShape.pathPoints[2].anchor[1]),2));             var sideC = parseInt(Math.pow((myShape.pathPoints[2].anchor[0] - myShape.pathPoints[3].anchor[0]),2) +            Math.pow((myShape.pathPoints[2].anchor[1] - myShape.pathPoints[3].anchor[1]),2));             var sideD = parseInt(Math.pow((myShape.pathPoints[3].anchor[0] - myShape.pathPoints[0].anchor[0]),2) +            Math.pow((myShape.pathPoints[3].anchor[1] - myShape.pathPoints[0].anchor[1]),2));             if(recEquaDistOne == recEquaDistTwo){ // If two diagonals connecting opposite points are same length, it's a 90 degree box                               if((sideA == sideC) && (sideB == sideD)){                    for(var j=0; j<4; j++){                        var point = myShape.pathPoints[j];                                         if((point.leftDirection[0] == point.anchor[0]) &&                                (point.anchor[0] == point.rightDirection[0]) &&                                (point.leftDirection[1] == point.anchor[1]) &&                                (point.anchor[1] == point.rightDirection[1])){                                                                                   shapeKind.isrectangle = true;                            } else {                                shapeKind.isrectangle = false;                                break;                            }                        }                    }                }            }            if(myShape.pathPoints.length == 4){  // CIRCLE CHECKER                if(shapeKind.isrectangle == false || shapeKind.isrectangle == null){                    var circlePts = new Array();                    var circleSlopes = new Array();                    for (k=0; k<4; k++){                    var point = myShape.pathPoints[k];                     var leftHandleDist = parseInt(Math.pow((point.leftDirection[0] - point.anchor[0]),2) +                    Math.pow((point.leftDirection[1] - point.anchor[1]),2));                    var rightHandleDist = parseInt(Math.pow((point.rightDirection[0] - point.anchor[0]),2) +                    Math.pow((point.rightDirection[1] - point.anchor[1]),2));                    circlePts.push(leftHandleDist, rightHandleDist);                    var leftHandleSlope = ((point.leftDirection[0] - point.anchor[0])/(point.leftDirection[1] - point.anchor[1])).toFixed(2);                    var rightHandleSlope = ((point.rightDirection[0] - point.anchor[0])/(point.rightDirection[1] - point.anchor[1])).toFixed(2);                    circleSlopes.push(leftHandleSlope, rightHandleSlope);                }                for(var f=0; f<8; f++){ // Allows non-rotated circles.                    if(circleSlopes[f] == "-0.00"){                        circleSlopes[f] = "0.00";                    }                    if(circleSlopes[f] == "-Infinity"){                        circleSlopes[f] = "Infinity";                    }                }                var cirEquaDistOne = parseInt(Math.pow((myShape.pathPoints[0].anchor[0] - myShape.pathPoints[2].anchor[0]),2) +                Math.pow((myShape.pathPoints[0].anchor[1] - myShape.pathPoints[2].anchor[1]),2));                var cirEquaDistTwo = parseInt(Math.pow((myShape.pathPoints[1].anchor[0] - myShape.pathPoints[3].anchor[0]),2) +                Math.pow((myShape.pathPoints[1].anchor[1] - myShape.pathPoints[3].anchor[1]),2));                if(circleSlopes[0] != "NaN"){ // Filters out asymmetric rhombus  <><><>^^^^^^<><><>                    if((circlePts[0] == circlePts[1]) && // Filters out shapes with control handles not of equal distance from anchor point.                        (circlePts[1] == circlePts[2]) &&                        (circlePts[2] == circlePts[3]) &&                        (circlePts[3] == circlePts[4]) &&                        (circlePts[4] == circlePts[5]) &&                        (circlePts[5] == circlePts[6]) &&                        (circlePts[6] == circlePts[7]) &&                        (circlePts[7] == circlePts[0])){                        if((circleSlopes[0] == circleSlopes[1]) && // Filters out the equadistant 4-pointed Star shape (dismisses negative slopes).                            (circleSlopes[2] == circleSlopes[3]) &&                            (circleSlopes[4] == circleSlopes[5]) &&                            (circleSlopes[6] == circleSlopes[7])){                            if(cirEquaDistOne == cirEquaDistTwo){ // Filters out Ellipses (non-equadistant circles).                                // Filters out the very RARE 4-pointed star which has all control points in its center on top of each other!                                if(((myShape.pathPoints[0].leftDirection[0]).toFixed(2) != (myShape.pathPoints[1].leftDirection[0]).toFixed(2)) &&                                    ((myShape.pathPoints[0].leftDirection[1]).toFixed(2) != (myShape.pathPoints[1].leftDirection[1]).toFixed(2))){                                    shapeKind.iscircle = true;                                } else {                                    shapeKind.iscircle = false;                                }                            }                        }                    } else {                        if((circlePts[0]==circlePts[1]) &&                            (circlePts[2]==circlePts[3]) &&                            ((circlePts[4]==circlePts[5]) && (circlePts[4]==circlePts[1]) && (circlePts[5]==circlePts[1])) &&                            ((circlePts[6]==circlePts[7]) && (circlePts[6]==circlePts[2]) && (circlePts[7]==circlePts[3]))){                            shapeKind.isellipse=true;                        }    //~                     $.writeln(circlePts[0]+'\r'+circlePts[1]+'\r'+circlePts[2]+'\r'+circlePts[3]+'\r'+    //~                     circlePts[4]+'\r'+circlePts[5]+'\r'+circlePts[6]+'\r'+circlePts[7]);                    }                }            }        }        return shapeKind;    }    if(app.name=='Adobe Illustrator' && app.documents.length>0){        function round2(num){            return Math.round(num*100)/100;        }        function convertToUIRGB(color){            if(color=='[CMYKColor]'){                var c=color.cyan, m=color.magenta, y=color.yellow, k=color.black;                return [                    round2((1-(c/100))*(1-(k/100))),                    round2((1-(m/100))*(1-(k/100))),                    round2((1-(y/100))*(1-(k/100)))                ];            } else if(color=='[GrayColor]'){                var k=color.gray;                var grayValue=1-(Math.round(((k/100)*255)*100)/100)/255;                return [grayValue,grayValue,grayValue];            } else if(color=='[GradientColor]'){                $.writeln('Sorry, no gradient colors please.');                return [0,0,0];            } else if(color=='[PatternColor]'){                $.writeln('Sorry, no pattern colors please.');                return [0,0,0,];            } else if(color=='[SpotColor]'){                var clr=color.spot.getInternalColor();                if(color.spot.spotKind==SpotColorKind.SPOTCMYK){                    var c=clr[0], m=clr[1], y=clr[2], k=clr[3];                    return [                        round2((1-(c/100))*(1-(k/100))),                        round2((1-(m/100))*(1-(k/100))),                        round2((1-(y/100))*(1-(k/100)))                    ];                } else if(color.spot.spotKind==SpotColorKind.SPOTRGB){                    return [round2(clr[0]/255), round2(clr[1]/255), round2(clr[2]/255)];                } else if(color.spot.spotKind==SpotColorKind.SPOTLAB){                    var clr=color.spot.getInternalColor();                    var whiteRef={                        D65: {X: 95.047,Y: 100, Z: 108.883},                        D50: {X: 96.422,Y: 100, Z: 82.521},                    };                    var illuminant='D65';                    var Y = (clr[0]+16)/116;                    var X = clr[1]/500+Y;                    var Z = Y-clr[2]/200;                    if(Math.pow(Y,3) > 0.008856){Y=Math.pow(Y,3);}                    else {Y = (Y-16/116)/7.787;}                    if(Math.pow(X,3) > 0.008856){X=Math.pow(X,3);}                    else {X = (X-16/116)/7.787;}                    if(Math.pow(Z,3) > 0.008856){Z=Math.pow(Z,3);}                    else {Z = (Z-16/116)/7.787;}                    X*=whiteRef[illuminant].X,Y*=whiteRef[illuminant].Y,Z*=whiteRef[illuminant].Z;                    //alert(X+" "+Y+" "+Z);                    X/=100,Y/=100,Z/=100;                    R=X*3.2406+Y*-1.5372+Z*-0.4986;                    G=X*-0.9689+Y*1.8758+Z*0.0415;                    B=X*0.0557+Y*-0.2040+Z*1.0570;                    //alert(R+" "+G+" "+B);                    if(R > 0.0031308){R=(1.055*(Math.pow(R,(1/2.4))))-0.055;}                    else {R*= 12.92;}                    if(G > 0.0031308){G=(1.055*(Math.pow(G,(1/2.4))))-0.055;}                    else {G*= 12.92;}                    if(B > 0.0031308){B=(1.055*(Math.pow(B,(1/2.4))))-0.055;}                    else {B*= 12.92;}                    if(R<0){R=0} else if(R>1){R=1};                    if(G<0){G=0} else if(G>1){G=1};                    if(B<0){B=0} else if(B>1){B=1};                    return [round2(R),round2(G),round2(B)];                }            } else if(color=='[RGBColor]'){                return [round2(color.red/255), round2(color.green/255), round2(color.blue/255)];            }        }        function drawFromObjString(objString, canvasArea){           function round2(num){               return Math.round(num*100)/100;           }            var obj=eval(objString);            var canvas=canvasArea.graphics;            var counter=obj.total;            while(counter>=0){                for(all in obj){                    if(all.match(/\d{1,2}$/g) && all.match(/\d{1,2}$/g)==counter){                        var thisShp=obj[all];                        if(thisShp.ellipsePath!=true){                            var vectorPts=thisShp.pathPoints;                            canvas.newPath(); canvas.moveTo(thisShp.pathPoints[0][0],thisShp.pathPoints[0][1]);                            for(var j=0; j<vectorPts.length; j++){                                var thisAnchor=vectorPts[j];                                var x=thisAnchor[0], y=thisAnchor[1];                                canvas.lineTo(x,y);                            }                            if(thisShp.closed==true){                                canvas.closePath();                            }                        } else {                            var cirPts=thisShp.pathPoints;                            canvas.newPath();                            canvas.ellipsePath(cirPts[0], cirPts[1], cirPts[2], cirPts[3]);                            canvas.closePath();                        }                        if(thisShp.fillColor!=null){                            var clr=thisShp.fillColor;                            var myBrush=canvas.newBrush(canvas.BrushType.SOLID_COLOR,clr);                            canvas.fillPath(myBrush);                        }                        if(thisShp.strokeColor!=null){                            var clr=thisShp.strokeColor;                            var myPen=canvas.newPen(canvas.PenType.SOLID_COLOR,[clr[0],clr[1],clr[2],1], thisShp.strokeWidth);                            canvas.strokePath(myPen);                        }                    }                }                counter-=1;            }        }        var doc=app.activeDocument;        if(doc.height<=400 && doc.width<=600){            doc.rulerOrigin=[0,doc.height];            doc.coordinateSystem=CoordinateSystem.DOCUMENTCOORDINATESYSTEM;            var wDims=function(){                var dims={width: '', height: ''};                if(doc.width>220){                    dims.width = Math.round(doc.width);                } else {                    dims.width = 220;                }                if(doc.height>20){                    dims.height = Math.round(doc.height);                } else {                    dims.height = 20;                }                return dims;            }();            function drawCapture(vectors, dataDisplay, graphicDisplay){                // draws a preview and creates a drawing data object resource.                var drawData={total:0}; //Put drawing shapes here.  Properties: stroke (rgb color | null), fill (rgb color | null), pathPoints                var canvas=graphicDisplay.graphics;                for(var i=vectors.length-1; i>-1; i--){                    var thisShp=vectors[i];                    if((thisShp.filled || thisShp.stroked) && thisShp.editable==true){                        drawData.total++;                        drawData['shape_'+i]={};                        drawData['shape_'+i].fillColor=null;                        drawData['shape_'+i].strokeColor=null;                        drawData['shape_'+i].pathPoints=[];                        drawData['shape_'+i].ellipsePath=false;                        if(itemShape(thisShp).iscircle==true || itemShape(thisShp).isellipse==true || thisShp.name=='ellipse' ||                            thisShp.name=='circle' || thisShp.name=='cir'){                            drawData['shape_'+i].ellipsePath=true;                            drawData['shape_'+i].pathPoints=[thisShp.left, -thisShp.top, thisShp.width, thisShp.height];                            canvas.newPath();                            canvas.ellipsePath(thisShp.left, -thisShp.top, thisShp.width, thisShp.height);                        } else {                            var vectorPts=thisShp.pathPoints;                            canvas.newPath(); canvas.moveTo(Math.round(vectorPts[0].anchor[0]),-Math.round(vectorPts[0].anchor[1]));                            for(var j=0; j<vectorPts.length; j++){                                var thisAnchor=vectorPts[j].anchor;                                var x=Math.round(thisAnchor[0]), y=-Math.round(thisAnchor[1]);                                drawData['shape_'+i].pathPoints.push([x,y]);                                canvas.lineTo(x,y);                            }                        }                        if(thisShp.closed || drawData['shape_'+i].ellipsePath==true){                            drawData['shape_'+i].closed=true;                            if(drawData['shape_'+i].ellipsePath!=true){                                canvas.closePath();                            }                        } else {                            drawData['shape_'+i].closed=false;                        }                        if(thisShp.filled){                            var clr=thisShp.fillColor;                            var colorArray=convertToUIRGB(clr);                            var myBrush=canvas.newBrush(canvas.BrushType.SOLID_COLOR,colorArray);                            drawData['shape_'+i].fillColor=colorArray;                            canvas.fillPath(myBrush);                        }                        if(thisShp.stroked){                            var clr=thisShp.strokeColor;                            var colorArray=convertToUIRGB(clr);                            var myPen=canvas.newPen(canvas.PenType.SOLID_COLOR,[colorArray[0],colorArray[1],colorArray[2],1], Math.round(thisShp.strokeWidth));                            drawData['shape_'+i].strokeColor=colorArray;                            drawData['shape_'+i].strokeWidth=Math.round(thisShp.strokeWidth);                            canvas.strokePath(myPen);                        }                    }                }                return drawData;            }            function showDrawerFunc(objStringDisplay, wDims){                var w2=new Window('dialog','Drawer Function');                var containerG=w2.add('tabbedpanel');                    var funcG=containerG.add('tab',undefined,'Drawer Function');                        var dispE=funcG.add('edittext',undefined,funcSrc,{multiline:true}); dispE.size=[580,200];                        var selBtn=funcG.add('button',undefined,'Select All');                    var drawingG=containerG.add('tab',undefined,'Drawing:');                        var drawG=drawingG.add('group');                            var drawP=drawG.add('panel',undefined,''); drawP.size=[wDims.width, wDims.height];                var msgCntr=w2.add('panel',undefined,'Message Center:');                    var msgE=msgCntr.add('edittext',undefined,'',{multiline:true});msgE.size=[560,40];                var btnG=w2.add('group');                    var okBtn=btnG.add('button',undefined,'Ok',{name: 'ok'});                selBtn.onClick=function(){                    dispE.active=false; dispE.active=true;                }                drawG.onDraw=function(){                    if(objStringDisplay.text!=''){                        try{                            drawFromObjString(objStringDisplay.text, this);                        } catch(e){                            msgE.text=("Something isn't right:\r"+e);                        }                    } else {                        msgE.text=('You must first put a valid object string into the object string display area--> "Get Source Object String" button, 1st window, 1st tab.');                    }                }                w2.show();            }            function instructions(){                var w3=new Window('dialog','instructions');                var instructions=w3.add('edittext',undefined,'',{multiline:true}); instructions.size=[400,100];                instructions.text="1)  Have a document open, smaller than 600x400.\r\r"+                    "2)  Draw some stuff- use paths only, straight lines or ellipses only. To have script explicitly recognize ellipse, "+                    "label the path 'cir', 'circle', or 'ellipse'. Right now there's a function to detect ellipses, but it is coarse.\r\r"+                    "3)  Run this script and see if your drawing was captured below this box.\r\r"+                    "4)  Click the 'Get Object String' button and see the drawing instruction string appear.\r\r"+                    "5)  Click the 'View Drawer Function/Drawing' button to see the function used to draw scriptUI picture from"+                    " the object string and use other tab to see the drawing made with this function from that object string.\r\r"+                    "6)  Edit your string to see your picture change if needed!";                var okBtn=w3.add('button',undefined,'OK');                w3.show();            }            var funcSrc=drawFromObjString.toSource();            var dispWindow=function(){                var drawData;                var w=new Window('dialog','ScriptUI Graphics Display');                var panel=w.add('panel',undefined,''); panel.size=[wDims.width+6,wDims.height+6];                var list=w.add('edittext',undefined,'',{multiline:true}); list.size=[wDims.width,150];                var btnsG=w.add('group');                    var clickBtn=btnsG.add('button',undefined,'Get Source Object String');                    var selectBtn=btnsG.add('button',undefined,'Select All');                var btnG2=w.add('group');                    var funcBtn=btnG2.add('button',undefined,'See Drawer Function/Drawing');                    funcBtn.helpTip='Uses the Object String picture info to draw using ScriptUIGraphics lineTo commands.';                    var helpBtn=btnG2.add('button',undefined,'?'); helpBtn.size=[25,25];                panel.onDraw=function(){                    drawData=drawCapture(doc.pathItems, list, this);                }                clickBtn.addEventListener('mousedown',function(){                    list.text=drawData.toSource();                });                funcBtn.onClick=function(){                    showDrawerFunc(list, wDims);                };                helpBtn.onClick=function(){                    instructions();                }                selectBtn.onClick=function(){                    list.active=false; list.active=true;                }                var okBtn=w.add('button',undefined,'OK');                w.show();            }();        } else {            alert('Please use a document with main artboard no larger than 600x400.');        }    } else {        alert('Must run in Illustrator with at least 1 document open.');    }
}


graphicsDisplay();

Biohaz Drawing.JPGBiohaz Drawing-scriptUI.JPGBiohaz Drawing-scriptUI-result.JPG

Viewing all 12845 articles
Browse latest View live


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