Copy link to clipboard
Copied
Hello,
I am working on a script with a UI window and a dropwodn list. the dropdown populates with a list of files and folder from a certian locaiton on our server. I would like to use the selected dropdown item as a variable that I can open, maybe post a screenshot to the folder, export too, etc. Right now my code populates the dropwon with a server location, and the selection is a variable and I am attemping to use the "go" button to open the selected using a system.callSystem method which contains the path plus the selected item variable name I don't think I have the order or the proper syntax of the function right to open the selected item. I'm sure I'm missing somehting but is ther a way to make this work, or a differnt way to go about it? I have posted my code below Any help is much appreciated.
{
function myScript(thisObj) {
function myScript_buildUI(thisObj) {
var myPanel = (thisObj instanceof Panel) ? thisObj : new Window("palette", "Dockable Script", undefined, { resizeable: true, closeButton: false });
res = "group{orientation:'column',\
groupOne: Group{orientation:'row',\
dropDown: DropDownList{},\
},\
groupThree: Group{orientation:'row',\
refreshButton: Button{text:'Refresh'},\
closeButton: Button{text:'Close'},\
goButton: Button{text:'Go'},\
},\
}";
myPanel.grp = myPanel.add(res);
//Defaults
myPanel.grp.groupOne.dropDown.size = [200, 25];
myPanel.grp.groupThree.refreshButton.onClick = function() {
populateDropDown(myPanel.grp.groupOne.dropDown, Folder("/Volumes/AgencyServer/Transfer").getFiles());
}
myPanel.grp.groupThree.closeButton.onClick = function() {
myPanel.close();
}
myPanel.grp.groupThree.goButton.onClick = function () {
system.callSystem("open /Volumes/AgencyServer/Transfer/" + "dd.selection");
}
myPanel.layout.layout(true);
return myPanel;
}
var myScriptPal = myScript_buildUI(thisObj);
if (myScriptPal != null && myScriptPal instanceof Window) {
myScriptPal.center();
myScriptPal.show();
}
}
myScript(this);
}
function populateDropDown(dd, array){
dd.removeAll();
for(var i = 0; i < array.length; i++){
dd.add("item", array[i].name.replace(/%20/g, " "));
}
dd.selection;
}
Copy link to clipboard
Copied
It might be easier to use the app.open() method rather than forcing the opening via the operating system. You pass it a File object for the .aep file you want the script to open. In this way, you can develop for both Windows and macOS without needing to have two separate incantations for the system.callSystem() method.
Copy link to clipboard
Copied
I might not have been clear in my original post but I'm actually looking to specifically get ahold of the path of the selected item in the drop down, as a start I am really just looking at how to store the item locaiton as a variable and the path plus the seleciton is how I thought it might work. The goal is to avoid having to navigate our server, so being able to have access to the subdolfers of a given project at the ready, means I can push renders, save frames, open the folder in a ui window. etc. that will save my team a lot of time.
Thank you for the suggesiton though, thats deifnitely something that I need to look into becuase there are a number of things I would like to do with files as well, import being the most obvious so I definitely need to explore your suggestion.
Copy link to clipboard
Copied
In your code you have:
system.callSystem("open /Volumes/AgencyServer/Transfer/" + "dd.selection");
The "dd.selection" is just a string here. You have to get the dropdown object, and use .selection.toString() which takes the dropdown's current selection and turns it into a string. So if `dd` is your dropdown ui element, you can do something like
system.callSystem("open /Volumes/AgencyServer/Transfer/" + dd.selection.toString());
This also assumes that the literal selection in the drop down is the name of just the .aep file.