Highlighted

Script for Proofing Template

Explorer ,
Nov 28, 2016

Copy link to clipboard

Copied

Was wondering if it would be possible to create a Script that would take a Selection or image and re-size it proportionally into an 11"w x 8.5" H document and place it Centered in a 10.5" x 6" box located at the top of the page. If possible if it can detect the size as being less than 10.5" x 6" then don't scale, but if larger scale down to fit Proportionately.... Then Provide a dialog box that would let me enter my job # and today's date in a pre-determined location. I've attached a sample of what I'm trying to accomplish for the finished look. I'm also Assuming the base elements will need to reference a file (or template) that would contain the proofing information if so we'll call it "Proof_Temp.ai"

Huge thanks in advance for anyone that can assist...

Proof Sample.jpg

Topics

Scripting

Views

1.4K

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Script for Proofing Template

Explorer ,
Nov 28, 2016

Copy link to clipboard

Copied

Was wondering if it would be possible to create a Script that would take a Selection or image and re-size it proportionally into an 11"w x 8.5" H document and place it Centered in a 10.5" x 6" box located at the top of the page. If possible if it can detect the size as being less than 10.5" x 6" then don't scale, but if larger scale down to fit Proportionately.... Then Provide a dialog box that would let me enter my job # and today's date in a pre-determined location. I've attached a sample of what I'm trying to accomplish for the finished look. I'm also Assuming the base elements will need to reference a file (or template) that would contain the proofing information if so we'll call it "Proof_Temp.ai"

Huge thanks in advance for anyone that can assist...

Proof Sample.jpg

Topics

Scripting

Views

1.4K

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Adobe Community Professional ,
Nov 28, 2016

Copy link to clipboard

Copied

Yes. All of that is completely doable. In fact I've done very similar tasks many times.

Do you have any code written that we can help with? We're more than happy to answer questions or help debug your code, but if you want the code written for you, I'd encourage you to hire any of the fantastic professionals around here who donate their time to help everyone learn together. 😃

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Adobe Community Professional ,
Nov 28, 2016

Copy link to clipboard

Copied

Indeed, it would seem like this workflow enhancement would yield monetary savings to whomever utilizes it, and depending on the volume of work, this value could be substantial..

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Explorer ,
Nov 28, 2016

Copy link to clipboard

Copied

I understand your point.. However, we are a relatively small shop and I was just looking for a way to improve our overall look to customers when proofing... I've seen several large companies use a proof template when sending proofs... Was just hoping there was something that someone had already done that was similar and I could modify to our particular needs...

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Adobe Community Professional ,
Nov 28, 2016

Copy link to clipboard

Copied

Understandable. But you would still be using something that a professional created. Like I said. We would all be very glad to help with any issues you have along the way or even show you how to write the processes or connect them all together.. But if you're looking for someone to do it for you, you should reimburse them.

Even if it's a small shop, it sounds like the ROI would be worth it so a compelling case could be made for a small investment. To be clear, I'm not saying that you should pay me to do it. I'm merely saying that everyone here is volunteering to help and it's important to respect the effort someone put into gaining the knowledge necessary to complete the task for you.

But again, I can't stress enough how willing we are to help you along the way if you decide to write the code.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Adobe Community Professional ,
Nov 28, 2016

Copy link to clipboard

Copied

Then this would be an excellent opportunity to join us and gain amazing scripting knowledge! Due to every different workflow having unique features which require the need for customized, specialized scripts, there isn't a large amount of one-size-fits-all scripts to accomplish these tasks. You already have a first step outlined - that is the mapping of your process, now you need to take all those steps and write down the code requirements. For example for your very first step, you would need to figure out what kind of code will let you grab hold of a selection, and after that what code would create a new document of a particular size, etc.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Explorer ,
Nov 28, 2016

Copy link to clipboard

Copied

Silly-V... I would love to gain more knowledge... is there a good location/resource that list the commands available... I'm 100% games for giving it a shot... just haven't found a good resource that tells me how to word the commands appropriately... I know what I need it to do... just missing the actual languages...

Any help or direction is greatly appreciated....

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Adobe Community Professional ,
Nov 28, 2016

Copy link to clipboard

Copied

Illustrator Scripting | Adobe Developer Connection

Here you'll find a list of guides that reference specific versions of Illustrator and different languages available (javascript, applescript, and vbscript).

The examples are poor i think. But it will give you a great guide to determine the available objects, properties and methods. If you run into syntax issues or you just don't understand how to get or set some property, just let us know.

If you post a step by step list of what you need to get done, we can help you work through it step by step.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Adobe Community Professional ,
Nov 28, 2016

Copy link to clipboard

Copied

You have come to the right place!

Here you will find all the PDF documents for the commands:

http://www.adobe.com/devnet/illustrator/scripting.html

We mostly stick to "Javascript" here, as it's cross-platform.

However in addition to the PDF documentation, you will also find a built-in Object Model Viewer help window inside the ExtendScript Tool Kit program to be quite useful.

The ExtendScript ToolKit is what you have to download from here:

JavaScript development toolkit | Download Adobe ExtendScript Toolkit CC

(To access the OMV once inside, go to Help > Object Model Viewer.)

In addition to all this, you will find that they have supplied you with sample scripts that you can study and edit to experiment with.

This is going to be inside the Illustrator's app folder - on Windows this would be inside here:

C:\Program Files\Adobe\Adobe Illustrator CC 2017\Scripting\Sample Scripts

If you are starting out from absolute scratch regarding Javascript, you will find many many YouTube tutorials on the subject, which is both good and not-great, due to the fact that 99.99% of the JS tutorials out there focus on the web browser, Javascript living inside websites. In our purposes, this isn't the case, and past the very basic Javascript features, the web-centric information will be useless. On the same note, javascript for the web is continually developed with more features being added, which makes web JS even more different from Adobe's ExtendScript JS. Adobe's version of JS is from back when JS was at version 3 - so many of the current (version 5) native JS functions aren't even available. That's ok though- learning from the basics is great for getting a foundation in programming.

I personally many years ago used this tutorial to get into the game: https://www.lynda.com/JavaScript-tutorials/JavaScript-Essential-Training/81266-2.html

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Explorer ,
Dec 01, 2016

Copy link to clipboard

Copied

OK.. I've started by taking some elements of another script I found... and I've tried to modify to allow me to start by getting a dialog box that allows me to select what file to open... However I'm getting an error.. This was originally intended for opening a multi-page .pdf and I think I've changed it to select any file type...

Error 21: undefined is not an object.

Line: 18

-> var btnOK = btnGroup.add("button", undefined, "Open");

Thanks for any help... just trying to get step 1 of my project done...

*****************Script Below ***************************

#target illustrator

#targetengine session

// script.name = PROOF Template.jsx;

// script.description = Opens Image and Places on Proof Template;

//----------------------- START UI CODE, create user interface

var win = new Window ("dialog", "Open File for Proof Template");

var fileGroup = win.add("group"); // this is the group on the left, it holds the File button and the Font label note

var btnFile = fileGroup.add("button", undefined, "File..."); // button to select the PDF to open

var grpRight = win.add("group"); // group on the right, to hold everything else

var txtFile = grpRight.add("edittext",undefined);

var btnGroup = grpPanel.add("group");

var btnOk = btnGroup.add("button", undefined, "Open");

var btnCancel = btnGroup.add("button", undefined, "Cancel");

var lblStatus = grpRight.add("statictext",undefined,"Dynagraphics - PROOF Template");

win.orientation = pagesPanel.orientation = "row"; // two items fileGroup and grpRight

win.alignChildren = "right";

fileGroup.orientation = "column";

fileGroup.alignment = "top";

txtFile.alignment = ["fill","top"];

lblStatus.alignment = "left";

grpRight.orientation = "column";

btnGroup.orientation = "column";

btnOk.enabled = false; // disable this button until a valid file is supplied

txtFrom.characters = txtTo.characters = 3;

btnFile.active = true; // receive the first "Enter"

//------------------------ get the file

btnFile.onClick = function(){

  txtFile.text = ""; // clear previous File path if any

  btnOk.enabled = false; // disable the Ok button

  var fileRef = File.openDialog ("Select File...", "*.*"); // get the file

  fileRef = new File(fileRef.fsName.replace("file://",""));

  if(fileRef!= null && fileRef.exists) // check if it is valid file, it should be, unless after clicking a file, the name gets edited

  {

  txtFile.text = fileRef.fsName; // show the file Path here

  btnOk.enabled = true; // enable the Ok button

  txtTo.active = true; // move focus to change the last page to open

  }

}

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

btnOk.onClick = function(){

  doSomething(); // call main function.

  win.close(); // close when done

}

//------------------------ on leaving this text, check again if file exist, in case file path is typed instead of clicking the File...button

txtFile.onDeactivate = function(){

  //alert("on deactivate")

  var file = File(txtFile.text); // create a file based on the text edit control

  if (file.exists){ // and chekc for existance, if it does

  btnOk.enabled = true; // enable the Ok button

  }

  else { // if it does not exist

  btnOk.enabled = false; // disable the Ok button

  }

}

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

win.center ();

win.show();

//-------------------------END UI CODE

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Adobe Community Professional ,
Dec 01, 2016

Copy link to clipboard

Copied

Don't start editing codes or messing with ScriptUI just yet- if you're  beginner: you can use a simpler File.openDialog() command to open a file or a Folder.selectDialog() to choose a folder.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Adobe Community Professional ,
Dec 01, 2016

Copy link to clipboard

Copied

this line right here:

var btnGroup = grpPanel.add("group");

grpPanel is undefined. ergo, btnGroup is going to be undefined because you can't add a group to "undefined". the error message you're getting is saying "grpPanel is not an object".

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Explorer ,
Dec 01, 2016

Copy link to clipboard

Copied

Silly-V

I tried your command... definitely much simpler and to the point... However.. It does bring the dialog up and allows me to select a file... but never actually opens the file....  Sorry to Ask... is there an end of command or something that's missing..

#target illustrator

#targetengine session

// script.name = PROOF Template.jsx;

// script.description = Opens Image and Places on Proof Template;

File.openDialog()

Also Williamadowling... I tried removing that line but obviously prompted further errors... Is there a way to "Define" what's missing?

Thanks to both of you for your help....

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Adobe Community Professional ,
Dec 01, 2016

Copy link to clipboard

Copied

As Silly-V said, much of this is probably over your head if you're just starting out with all this. I still struggle with ScriptUI from time to time and I've been using it for a while. That said, I'll still answer your questions if you want because the knowledge can't hurt.

File.openDialog() returns a path to the file you selected. It's not an "open" command in terms of opening files, it just opens a dialog. So you have to save the return value of "File.openDialog()" to a variable and then do something with the variable like this:

var theFile = File.openDialog();

app.open(theFile);

Back to your question regarding the ScriptUI and undefined variables..

The script can't tell you what's missing. If it could, there wouldn't really be much need for programmers. Computers can't really infer what you want to happen, It can only tell you when it tries to do something that is missing. but anything that's missing beyond that point won't be known until the script fails at that point. It's up to you to be able to read the code and make sure that the necessary elements are there.

removing that line creates more errors because the subsequent lines attempt to access the variable "btnGroup". So removing the line doesn't fix a problem so much as transfer the problem elsewhere.

a potential fix is to declare a variable called "grpPanel" and give it a value. Another potential fix is to define "btnGroup" as a child of something that already does exist. but the best fix is to start from scratch. that way you're only working with variables you yourself created, and thus it's far easier to know what you have access to.

Editing existing code to work for your needs can be a very difficult thing to do and requires a really solid grasp of how to read the code and figure out exactly what it's doing. Most often, you're better off writing the code from scratch, as it's much easier to understand while you're developing it. You can take it logically from step to step and make sure that you've covered your bases. Start out by giving us a detailed step by step of your process, and then we can break it down into chunks of code.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...