Skip to main content
Participant
December 29, 2016
Question

Scripting: Prompt a Dialog Box to add text to part of my existing Script.

  • December 29, 2016
  • 3 replies
  • 2943 views

     I'm new with scripting and haven't had a lot to do with it, so i'm looking for a little help. I need to add to my companies existing Script Pallet, we have a script that creates our art into dies for us. So that they can be used for Debossing/Hotstamping items. But, we need the "Die" to have the Name of the job on it, so i'm trying to get a box to prompt up to add that text to the top of my die...I have got the box to come up but i can't get it to put the text on the art. Am I missing a link somewhere?

var newDieName = prompt ('Enter Job Number for New Die', " ","Creating Die");

var newDieName = newDieName.name;

            var die_num = thisDoc.textFrames.add();

            die_num.contents = "DJ" +(newDieName)+ ".01" + "-" + " " +magThick;

            die_num.moveToBeginning(rec_group1);

       

    var myParagraph = die_num.paragraphs[0];

            myParagraph.characterAttributes.size = 12;

            myParagraph.characterAttributes.textFont=app.textFonts.getByName("MyriadPro-Regular");

            myParagraph.characterAttributes.fillColor = orange;

       

//  Determines where the die number should be placed.

     die_num.top = -170;

     die_num.left = -54;

     die_num.filled = true;

     die_num.rotate(180);

     die_num.overprintFill = false;

//  End of die number creation

;

Please let me know if you need any other information; i will see want i can do to.

This topic has been closed for replies.

3 replies

Disposition_Dev
Legend
December 30, 2016

One issue I can see right off the bat.. these first 2 lines:

var newDieName = prompt ('Enter Job Number for New Die', " ","Creating Die");

var newDieName = newDieName.name;

The first line sets the variable newDieName equal to the result of the prompt window

Since the prompt returns a string, the second line doesn't work. there is no "name" property of a string.

You can get rid of that second line all together since the first one already does what you want.

pixxxelschubser
Community Expert
Community Expert
December 29, 2016

It seems you have trouble with your syntax. And I miss necessary parts in your code. Furthermore: the version of your Illustartor is absolutely required for the correct position of your die_num

If I understand you right, you need something like this

var thisDoc = activeDocument;

var rec_group1 = thisDoc.layers.getByName("rec_group1");

var magThick = "0,250";

var newDieName = prompt ('Enter Job Number for New Die', " ","Creating Die");

if (newDieName) {

var die_num = rec_group1.textFrames.add();

die_num.contents = "DJ" + newDieName + ".01" + "-" + " " + magThick;

die_num.moveToBeginning(rec_group1);

die_num.textRange.characterAttributes.size = 12;

die_num.textRange.characterAttributes.textFont=app.textFonts.getByName("MyriadPro-Regular");

die_num.textRange.characterAttributes.fillColor = thisDoc.swatches[4].color;

//  Determines where the die number should be placed.

die_num.top = -170;

die_num.left = -54;

die_num.filled = true;

die_num.overprintFill = false;

die_num.rotate(180);

//  End of die number creation

};

One question (if allowed) Where do you come from?

Have fun

Silly-V
Legend
December 29, 2016

In your code, what does rec_group1 ​reference to?

Out of curiosity, can you tell us what kind of "Scripting Palette" you guys are using?

Participant
December 29, 2016

i believe it refers to the first group of die's to the die name. The script reads 4 different die's out of 2 different groups, depending on the size of the art.