Skip to main content
Inspiring
August 23, 2018
Question

My script works as an action but not as a script

  • August 23, 2018
  • 14 replies
  • 940 views

Hi here is the code, it works as an action then when I convert it to script then it just does nothing, this is to go to end of working area in timeline in photoshop

#target photoshop

//

// Set.jsx

//

//

// Generated Thu Aug 23 2018 18:57:29 GMT+0200

//

cTID = function(s) { return app.charIDToTypeID(s); };

sTID = function(s) { return app.stringIDToTypeID(s); };

//

//==================== Set ==============

//

function Set() {

  // Set

  function step1(enabled, withDialog) {

    if (enabled != undefined && !enabled)

      return;

    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);

    var desc1 = new ActionDescriptor();

    var ref1 = new ActionReference();

    ref1.putProperty(cTID('Prpr'), cTID('time'));

    ref1.putClass(sTID("timeline"));

    desc1.putReference(cTID('null'), ref1);

    var desc2 = new ActionDescriptor();

    desc2.putInteger(sTID("seconds"), 4);

    desc2.putInteger(sTID("frame"), 29);

    desc2.putDouble(sTID("frameRate"), 30);

    desc1.putObject(cTID('T   '), sTID("timecode"), desc2);

    executeAction(cTID('setd'), desc1, dialogMode);

  };

  step1();      // Set

};

//=========================================

//                    Set.main

//=========================================

//

Set.main = function () {

  Set();

};

Set.main();

// EOF

"Set.jsx"

// EOF

This topic has been closed for replies.

14 replies

Inspiring
August 24, 2018

Thank you for all your help mack! someone gave me the answer here it is

There should be 's' instead of 'c' / change: cTID('time') to sTID('time')

JJMack
Community Expert
Community Expert
August 24, 2018

Then what you used to convert the action to a script has a problem. What did you use?

JJMack
Inspiring
August 23, 2018

oh yes that is correct, well i dont know about the fps, but i just need the keyframes to make my image scale a bit larger in the script, so far everything works except the set part, dont know why

Inspiring
August 23, 2018

well its not a video, its just images, so im guessing it wouldnt matter

JJMack
Community Expert
Community Expert
August 23, 2018

It has a video timeline and your go to end seen to have set 4 29 and 30. You may not have rendered  out a video file but you have a video in the making.  You seem to have extended the layer to play for some time at a 30fps rate.  I would have thought a 4second 30FPS video would have 120 frame though. So 29 does not seem right to me

JJMack
Inspiring
August 23, 2018

JJMack
Community Expert
Community Expert
August 23, 2018

Will these values be valid for all your video timelines. You stated you clicked on a got to end button will all your video timeline be 4 seconds and have 29 frames and a 30fps rate? you scripy woul most likel need toe finf the enfs s set the correct values you neen  Seconds frames and  rate vakued to the function you created from the action manager code.

#target photoshop

cTID = function(s) { return app.charIDToTypeID(s); };

sTID = function(s) { return app.stringIDToTypeID(s); };

function setVideo(seconds, frame, frameRate) {

var descriptor = new ActionDescriptor();

var descriptor2 = new ActionDescriptor();

var reference = new ActionReference();

reference.putProperty(cTID('Prpr'), cTID('time'));

reference.putClass(sTID("timeline"));

descriptor.putReference(cTID('null'), reference);

descriptor2.putInteger(sTID("seconds"), seconds);

descriptor2.putInteger(sTID("frame"), frame);

descriptor2.putDouble(sTID("frameRate"), frameRate);

descriptor.putObject(cTID('T   '), sTID("timecode"), descriptor2);

executeAction(cTID('setd'), descriptor,  DialogModes.NO);

}

setVideo(4, 29, 30);

JJMack
Inspiring
August 23, 2018

how i recorded it was, i right click on the marker then click go to end of working area, then stop recording

JJMack
Community Expert
Community Expert
August 23, 2018

I ask for you to show me what was recorded for the last few action steps options.  I did not ask for a mp4 or how you recorded the  last step.  I told you Action steps record hard coded settings.  What settings were recorder into you action. Would they be valid for the document you play the action on or use a script equipment to one of your action's hard coded action step?  I'm trying to help you why not cooperate and reply with what I ask you to provide.  To me it looks like seconds 4 frame 29 rate 30 was recorded is that correct.

In your mp4 it looks like you recorded. It look like you have a video open in Photoshop and had recorded sometime in the past an action named set in Adobe default action set.   The action has one step "Set Time of timeline" the action step is not expanded and you did not show how the step was recorded.  You may have played the action with the open document  video timeline created  and you may have move a video timeline time slider but that seems to be moved to the 5th second,  You may also be using some third party extension to convert the action to a script or you may have used  X;s xtools kit to do that and  then third party extension  you added action  converted to a script in as a button.  You say the nothing happens when you use the set script.  Have you tried using the script from menu File>Scripts>script name or Browse to where the converted action is stored as a jsx file.   If the slider needed to be moved first did you doe the steps need in the document before tried using the script?  It look like values 4, 29 and 30 were recorded into the action so they are also in the script for no logic was added the change these values. Thes values will mnots likel not be valid fot all video timemines.

JJMack
Inspiring
August 23, 2018
Inspiring
August 23, 2018

ok let me try to record a video clip of everything im doing, will keep it short

JJMack
Community Expert
Community Expert
August 23, 2018

Expand you action fully so you can see all that was recorded and capture the last few steps in the action palette and pos the capture here. Also what did the document you recorder the action on look like when you recorded the last step. The layers and video timeline...

JJMack
Inspiring
August 23, 2018

I must be doing something wrong, I cant get the code to run, does nothing, no errors either

JJMack
Community Expert
Community Expert
August 23, 2018

I do not know what the action step you recorded was. I find action manage code unreadable unless I record the steps with scriptlistener, or in action steps.

I use all the tools I have to clean up the code you posted its hard coded 4 seconds, frame 29 frame rate 30 does that ring a bell expand  your action so you can see all the is recorded for its last step options.  You did not add any logic to that script its hard coded to do one particular thing like an action step is. Your document must meet the requirements for the step to work else the command will not be available for use.

#target photoshop

cTID = function(s) { return app.charIDToTypeID(s); };

sTID = function(s) { return app.stringIDToTypeID(s); };

function setVideo(seconds, frame, frameRate) {

   var descriptor = new ActionDescriptor();

   var descriptor2 = new ActionDescriptor();

   var reference = new ActionReference();

   reference.putProperty(cTID('Prpr'), cTID('time'));

   reference.putClass(sTID("timeline"));

   descriptor.putReference(cTID('null'), reference);

   descriptor2.putInteger(sTID("seconds"), seconds);

   descriptor2.putInteger(sTID("frame"), frame);

   descriptor2.putDouble(sTID("frameRate"), frameRate);

   descriptor.putObject(cTID('T   '), sTID("timecode"), descriptor2);

executeAction(cTID('setd'), descriptor, DialogModes.NO);

}

setVideo(4, 29, 30);

JJMack