9 Replies Latest reply on Mar 6, 2012 12:57 AM by dgolberg

    Select tasks before running scripts.

    dgolberg Level 1

      This might be a bit of an odd one, but I've run into a bit of an issue with contractors naming layers incorrectly based on features that they're working with.  I'd like to make a script that they can run that will bring up a checkbox list of the various features in the project.  They can then check the box next to the feature they're having trouble with and it will either fix the issue automatically (by renaming the layer from a common misspelling to the correct spelling) or alert them to what the correct layer format should be.  I can do the fix/alert portions of the script myself, but I'm not sure if/how to do the checkbox window at the start of the script.  Any ideas on how to do this (if it is doable)?  Thanks for any help!

       

      dgolberg

        • 1. Re: Select tasks before running scripts.
          c.pfaffenbichler Level 9

          While I assume what you are asking is possible would a series of confirm-dialogs not be easier to Script (though less elegant)?

          How many possible problems are there and how many checkboxes would the Script therefore have to include?

          • 2. Re: Select tasks before running scripts.
            dgolberg Level 1

            Yeah, I had considered the possibility of confirm dialogs; but that would result in a near endless amount of dialogs (less elegant would be like saying moldy food is first-class in this case); hence the reason for the question.  There are currently up to 11 features that need to be checked, so 12 different check boxes would be needed (one for an "all" option that could override the others if checked).  The checkboxes would simply have to refer to different functions where I'll do the actual checking of said feature to see if it exists/is named correctly/is in the correct group/etc. 

             

            Basically, I'd like to make an automated form of troubleshooting that is easy to use and handles the more common issues contractors have with projects (primarily naming issues).  I've already incorporated some of said trouble-shooting into other scripts that allow for such fixes, but there are features that don't use scripts that could benefit from these checks (and including them in other features' scripts isn't always an option).  I know how to setup the code for the actual trouble-shooting, but not how to have the user select what it is they're having trouble with (aside from giving them a ton of random scripts that would simply confuse them).

             

            In a way, it could also be used as a check-list to confirm that the user has done the work correctly and everything is setup so that it's ready to be saved out by our main saving script (nearly 1500 lines of code that can be a bit of a pain to filter through only to find it was user error in the end).

             

            Anyway, long story short; I have the code for the actual troubleshooting ready to go; I just need a way for them to call it into play if it's relavent for the project they're working on.  Not all projects will have "trim" for example, but it will need to know that it needs to look for it in case it was forgotten; and having a check list seemed the most user friendly (while also being very versatile) if it is doable.

             

            Hope that clarifies it some (I have a habit of over-explaining things to the point of re-confusing people after all).

            • 3. Re: Select tasks before running scripts.
              dgolberg Level 1

              Probably a simpler way to put it would be:

               

              If possible; How would you have a window come up with check boxes (2 or more) that; when selected; run certain function calls once the user hits an "Ok" or "Continue" button on the window. 

               

              If I got the code for that, I think I can "reverse engineer" it the rest of the way to get it to work for what I need.  I'm just not sure how to create custom pop-up windows with checkboxes.

              • 4. Re: Select tasks before running scripts.
                c.pfaffenbichler Level 9

                If possible; How would you have a window come up with check boxes (2 or more) that; when selected; run certain function calls once the user hits an "Ok" or "Continue" button on the window.

                That is possible, you just need to evaluate the checkbox’ value if the dialog has been OK-ed.

                »Image Processor.jsx« has examples, but is a bit complex, so not ideal for tinkering.

                 

                What I have so far never done is populating a dialog with a varying number of elements – would have to research that but maybe one of the other contributors could provide a sample Script.

                • 5. Re: Select tasks before running scripts.
                  Paul Riggott Level 6

                  Here is a snippet of code that uses checkboxs and one using radiobuttons.

                  If you need any more please let me know.

                   

                   

                  function main(){
                  var somethingNeedsToBeChecked = true;
                  if(somethingNeedsToBeChecked) query1();
                  var mustBeSelected =true;
                  if(mustBeSelected) query2();
                  function query1(){
                  var w1 = new Window( 'dialog', 'Query 1' ); 
                  w1.p1= w1.add("panel", undefined, undefined, {borderStyle:"black"}); 
                  w1.g1 = w1.p1.add('group');
                  w1.st1 = w1.g1.add('statictext',undefined,'Query One');
                  w1.st1.graphics.font =ScriptUI.newFont("Georgia","BOLDITALIC",22);
                  w1.g5 =w1.p1.add('group');
                  w1.g5.orientation = "column";
                  w1.g5.alignChildren = ["fill","fill"];
                  w1.g5.cb1 = w1.g5.add('checkbox',undefined,'Do something?');
                  w1.g5.cb2 = w1.g5.add('checkbox',undefined,'Do something else?');
                  w1.g5.cb3 = w1.g5.add('checkbox',undefined,'Do something if you must?');
                  w1.g10 =w1.p1.add('group');
                  w1.g10.orientation = "column";
                  w1.g10.alignment='center';
                  w1.g10.bu1 = w1.g10.add('button',undefined,'Done');
                  w1.g10.bu1.onClick= function(){
                  w1.close(1); //close the window
                  if(w1.g5.cb1.value){
                      alert("Checkbox 1 has been selected");
                      }
                  if(w1.g5.cb2.value){
                      alert("Checkbox 2 has been selected");
                      }
                  if(w1.g5.cb3.value){
                      alert("Checkbox 3 has been selected");
                      }
                  if(!w1.g5.cb1.value && !w1.g5.cb2.value && !w1.g5.cb3.value){
                      alert("No checkboxs were selected");
                      }
                  }
                  w1.show();
                  }//end query 1
                  function query2(){
                  var w2 = new Window( 'dialog', 'Query 2' ); 
                  w2.p1= w2.add("panel", undefined, undefined, {borderStyle:"black"}); 
                  w2.g1 = w2.p1.add('group');
                  w2.st1 = w2.g1.add('statictext',undefined,'Query Two');
                  w2.st1.graphics.font =ScriptUI.newFont("Georgia","BOLDITALIC",22);
                  w2.g5 =w2.p1.add('group');
                  w2.g5.orientation = "column";
                  w2.g5.alignChildren = ["fill","fill"];
                  w2.g5.rb1 = w2.g5.add('radiobutton',undefined,'Do something?');
                  w2.g5.rb2 = w2.g5.add('radiobutton',undefined,'Do something else?');
                  w2.g5.rb3 = w2.g5.add('radiobutton',undefined,'Do something if you must?');
                  w2.g5.rb1.value=true; //set radiobutton one selected
                  w2.g10 =w2.p1.add('group');
                  w2.g10.orientation = "column";
                  w2.g10.alignment='center';
                  w2.g10.bu1 = w2.g10.add('button',undefined,'Done');
                  w2.g10.bu1.onClick= function(){
                  w2.close(1); //close the window
                  if(w2.g5.rb1.value){
                      alert("radiobutton 1 is selected");
                      }
                  if(w2.g5.rb2.value){
                      alert("radiobutton 2 is selected");
                      }
                  if(w2.g5.rb3.value){
                      alert("radiobutton 3 is selected");
                      }
                  }
                  w2.show();
                  }//end query 2
                  }//end main
                  main();
                  
                   
                  
                  • 6. Re: Select tasks before running scripts.
                    dgolberg Level 1

                    You're Awesome Paul!  Thats EXACTLY what I was looking for!  Now for the fun part... attaching it to the processes it needs to run (I'm not bein sarcastic either... love reverse-engineering code to work for an exact situation).  Thanks again!

                    • 7. Re: Select tasks before running scripts.
                      dgolberg Level 1

                      This script is working wonders for me!  I've got a highly complex saving process down to a few checkboxes and radio buttons that a little kid could easily figure out!  Thanks again for the code!

                       

                      I do have one last question though; regarding it.  Is there any way to have the "Enter/Return" key automatically perform the same task as someone clicking the "Done" button?  Not a biggy, but would be handy.

                       

                      Thanks again!

                      • 8. Re: Select tasks before running scripts.
                        Paul Riggott Level 6

                        That's no problem, just change "Done" to "Ok" and it will then accept enter/return.

                        1 person found this helpful
                        • 9. Re: Select tasks before running scripts.
                          dgolberg Level 1

                          LOL! And here I thought it was going to be some complex method of binding that key to the button.  Thanks a ton Paul!