3 Replies Latest reply on Sep 29, 2010 9:32 PM by Michael L Hale

    Is there something like the Actions Palette insert menu Item for Scripts?

    JJMack Most Valuable Participant

      The Action Palette has a feature that let you insert steps into actions that can not be recorded.  That means the ScriptListener can not be used to generate script  code for these steps to use the action manager interface.  Is there anything beside making an Action and using doaction(name,set) within a script to pull off the action step in a script.  I would like to make a script that doesn't have to depend on a particular action set being loaded.

        • 1. Re: Is there something like the Actions Palette insert menu Item for Scripts?
          Michael L Hale Level 5

          Xbytor has a script in his xtools that will convert actions to javascript( action manager ). You can use that to get access the code created by imsert menu item.

           

          Or if you will list the menuItems you want to script either X or I should be able to post the code for you. We both have function libs and we have already converted most of the useful menuItems.

          • 2. Re: Is there something like the Actions Palette insert menu Item for Scripts?
            JJMack Most Valuable Participant

            Yes I forgot about X's ActionFileToJavaScript!  I did not install his whole toolkit I only hack at scripts his stuff ie beyond me. I did extract his tools and had install his utility scripts like ActionFileToJavaScript  it work on the actions I needed to convert  menu items to change display screen mode, fit on screen and zoom, menu place and menu free transform.  Just need to add code to catch the cancel case. Thanks my memory is not what it ise to be...

            • 3. Re: Is there something like the Actions Palette insert menu Item for Scripts?
              Michael L Hale Level 5

              Here is how to control the screen.

              imageView ("FtOn");// fit on screen 
              imageView ("ActP");// actual pixels 
              imageView ("ZmIn");// zoom in 
              imageView ("ZmOt");// zoom out 
              imageView ("screenModeFullScreen"); 
              imageView ("screenModeStandard");
              stringIDToTypeID( "screenModeFullScreenWithMenubar" ); 
              
              
              function imageView (view) {
                  desc= new ActionDescriptor();
                      ref = new ActionReference();
                    if (view.length < 5){
                       var viewID = charIDToTypeID( view );
                    }else{
                       var viewID = stringIDToTypeID( view );
                    }
                    ref.putEnumerated( charIDToTypeID( "Mn  " ), charIDToTypeID( "MnIt" ), viewID );
                  desc.putReference( charIDToTypeID( "null" ), ref );
                 executeAction( charIDToTypeID( "slct" ), desc, DialogModes.NO );
              };
              

              Place and transform should appear in the log. But...

              function placeSmartObject(fileRef){
              //create a new smart object  layer using a file
              cTID = function(s) { return app.charIDToTypeID(s); };
                   try { 
                        var desc = new ActionDescriptor();
                            desc.putPath( cTID( "null" ), new File( fileRef ) );
                            desc.putEnumerated( cTID( "FTcs" ), cTID( "QCSt" ),cTID( "Qcsa" ));
                            desc.putUnitDouble( cTID( "Wdth" ),cTID( "#Prc" ), 100 );
                            desc.putUnitDouble( cTID( "Hght" ), cTID( "#Prc" ), 100 );
                            desc.putUnitDouble( cTID( "Angl" ), cTID( "#Ang" ), 0 );
                            desc.putBoolean( cTID( "Lnkd" ), true );
                        executeAction( cTID( "Plc " ), desc, DialogModes.NO );
                             //activeDocument.activeLayer.resize(100 ,100,AnchorPosition.MIDDLECENTER);
                             //activeDocument.revealAll();
                    } catch (e) {
                if (!e.toString().match(/Place.+is not currently available/)) {
                    throw e;
                    }
                }
              };
              //or
              function placeSmartObject(){// opens the place dialog.
              cTID = function(s) { return app.charIDToTypeID(s); };
                   try { 
                        var desc = new ActionDescriptor();
                        executeAction( cTID( "Plc " ), desc, DialogModes.ALL );
              
                    } catch (e) {
                if (!e.toString().match(/Place.+is not currently available/)) {
                    throw e;
                    }
                }
              };
              

              And for transform

              function transform(){
              try{ 
                  var desc = new ActionDescriptor();
                      var ref = new ActionReference();
                      ref.putEnumerated( app.charIDToTypeID('Lyr '), app.charIDToTypeID('Ordn'), app.charIDToTypeID('Trgt') );
                  desc.putReference( app.charIDToTypeID('null'), ref );
                  executeAction( app.charIDToTypeID('Trnf'), desc, DialogModes.ALL );
                  }catch(e){ 
                if (e.toString().match(/User cancelled/)) { 
                     return -1; 
                     }else{ 
                    throw e; 
                    }
                }
              };
              

              Transform is harder to convert into a function without a dialog.  Except for simple scale or translate, the values in the log can be different from those entered in the dialog.