Copy link to clipboard
Copied
Hello everyone,
I've been trying to pull together the right info to use javascript to create a form to bring in particularsymbols from the symbol library based on the variables taken from the form. I've taken bits and pieces from various sample scripts and tried to make this work, but my problem appears when I try to use conditionals.
This is a limited version of what I want to do, but it is enough to get the point across.
1. I want to select a script that has various dropdown boxes. I would like the first dropdown to give me 3 options: 10, 13, 18
2. I would also like another drop down box that gives me three more options: single needle, double needle, and knife edge.
3. I would then like it to have an "ok" button and "Cancel" button.
4. From here when I click the ok button, a symbol is brought in from the library depending on what parameters were given to the form.
ex. If I selected 10 in the first drop down and double needle in the second, I would like "SYMBOL A" to be pulled from the library and centered on the artboard.
ex. If I selected 13 in the first drop down and double needle in the second, I would like "SYMBOL B" to be pulled from the library and centered on the artboard.
I've gotten the UI to pop up and it works as planned as well as bringing in a symbol, my problem comes when I try to incorporate conditionals and functions.
Here is my script. Please let me know what I'm doing wrong.
var myDoc = app.activeDocument;
var Pallette = new Window ("dialog", "Create a Shell");
Pallette.add ("statictext", undefined, "Fill Opening in Inches:");
Pallette.orientation = "row";
var myDropdown = Pallette.add ("dropdownlist", undefined, ["10", "13", "18"]);
myDropdown.selection = 1;
var myButtonGroup = Pallette.add ("group");
myButtonGroup.orientation = "column";
var btnCreate = myButtonGroup.add ("button", undefined, "OK");
MyFillSelection = myDropdown.selection
btnCreate.onClick = function () {
if ( MyFillSelection = "13") {
symbolRef = myDoc.symbols["SYMBOL A"];
symbolItemRef1 = myDoc.symbolItems.add(symbolRef);
redraw();
}
}
var btnCancel = myButtonGroup.add ("button", undefined, "Cancel");
Pallette.show ();
If anyone has any input, it would be much appreciated.
thanks,
MyFillSelection = myDropdown.selection is outside the function, so it will always read "13", nothing is making the value change.
move that line into your function and add the text property to it...MyFillSelection = myDropdown.selection.text;
then do your if comparisons, that will do it.
Copy link to clipboard
Copied
If this is too confusing, the biggest issue is getting the script to recognize the "If" statement. I have it in there as you can see from above, but the symbol is placed no matter what. It doesn't matter which dropdown item is selected. Is there another object that needs to be called out underneath the dropdown like myDropdown.value or selection?. If that could be answered, that would be a big help.
thanks
Copy link to clipboard
Copied
Sorry I have not had the time just yet but I can say now the if ( condition == value ) single = assigns…
Copy link to clipboard
Copied
ok, thanks for the response. I have since figured that one out, but it's still ignoring the statement and placing the symbol anyway. Just let me know when you get the time. I appreciate it.
Copy link to clipboard
Copied
Half time… watching my man city at the moment…
I will take a look though…
Copy link to clipboard
Copied
No problem, thanks for keeping me on the radar Muppet.
Copy link to clipboard
Copied
MyFillSelection = myDropdown.selection is outside the function, so it will always read "13", nothing is making the value change.
move that line into your function and add the text property to it...MyFillSelection = myDropdown.selection.text;
then do your if comparisons, that will do it.
Copy link to clipboard
Copied
Thanks Carlos!! That did the trick. I have been spending days trying to figure that out and it was all about placement.
. You definitely got this one, thanks!
Copy link to clipboard
Copied
help gald to, welcome you are....yes, it is all about the placement ![]()
Copy link to clipboard
Copied
Hi Mark, The Citizens won!!!
Copy link to clipboard
Copied
Of cause they did… I can change the
to
now… do Carlos sort this… while ( mark.hasABeer == true );
Copy link to clipboard
Copied
do Carlos sort this… while ( mark.hasABeer == true );
hahaha, good one
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more