Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Automation of scripts with random value

Community Beginner ,
Apr 23, 2020 Apr 23, 2020

Good morning all,
Technical question concerning the automation of scripts in Photoshop.
I created a script. In this script, I created a gradient transfer curve, with a random gradient. So far so good.
Normally, when I click on this random button, I have a different gradient each time. But by creating a script with this click on the random button, it saves the ID of the gradient. Suddenly, during a mass automation, it is always this same gradient that comes out.
I'm not sure I'm very clear, am I clear? 😁
So in the end, how do you create a script, with a gradient that changes with each repetition of the script (therefore really random)?
Thank you and good day !

 

Technicals infromations : 

Windows 10

French Photoshop CC (updated)

 

TOPICS
Actions and scripting , Windows
1.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Apr 28, 2020 Apr 28, 2020
// 2020, use it at your own risk;
// =======================================================
var idmake = stringIDToTypeID( "make" );
    var desc8 = new ActionDescriptor();
    var idnull = stringIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idadjustmentLayer = stringIDToTypeID( "adjustmentLayer" );
        ref3.putClass( idadjustmentLayer );
    desc8.putReference( idnull, ref3 );
    var idusing = stringIDToTypeID( "using" );
        var desc9 = new ActionDescrip
...
Translate
Adobe
Community Expert ,
Apr 24, 2020 Apr 24, 2020

 

// =======================================================
var idmake = stringIDToTypeID( "make" );
    var desc2 = new ActionDescriptor();
    var idnull = stringIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idcontentLayer = stringIDToTypeID( "contentLayer" );
        ref1.putClass( idcontentLayer );
    desc2.putReference( idnull, ref1 );
    var idusing = stringIDToTypeID( "using" );
        var desc3 = new ActionDescriptor();
        var idtype = stringIDToTypeID( "type" );
            var desc4 = new ActionDescriptor();
            var idangle = stringIDToTypeID( "angle" );
            var idangleUnit = stringIDToTypeID( "angleUnit" );
            desc4.putUnitDouble( idangle, idangleUnit, 90.000000 );
            var idtype = stringIDToTypeID( "type" );
            var idgradientType = stringIDToTypeID( "gradientType" );
            var idlinear = stringIDToTypeID( "linear" );
            desc4.putEnumerated( idtype, idgradientType, idlinear );
            var idgradient = stringIDToTypeID( "gradient" );
                var desc5 = new ActionDescriptor();
                var idname = stringIDToTypeID( "name" );
                desc5.putString( idname, """Custom""" );
                var idgradientForm = stringIDToTypeID( "gradientForm" );
                var idgradientForm = stringIDToTypeID( "gradientForm" );
                var idcolorNoise = stringIDToTypeID( "colorNoise" );
                desc5.putEnumerated( idgradientForm, idgradientForm, idcolorNoise );
                var idshowTransparency = stringIDToTypeID( "showTransparency" );
                desc5.putBoolean( idshowTransparency, false );
                var idvectorColor = stringIDToTypeID( "vectorColor" );
                desc5.putBoolean( idvectorColor, true );
                var idcolorSpace = stringIDToTypeID( "colorSpace" );
                var idcolorSpace = stringIDToTypeID( "colorSpace" );
                var idRGBColor = stringIDToTypeID( "RGBColor" );
                desc5.putEnumerated( idcolorSpace, idcolorSpace, idRGBColor );
                var idrandomSeed = stringIDToTypeID( "randomSeed" );
                desc5.putInteger( idrandomSeed, Math.round(10000000000 * Math.random()) );
                var idsmoothness = stringIDToTypeID( "smoothness" );
                desc5.putInteger( idsmoothness, 2048 );
                var idminimum = stringIDToTypeID( "minimum" );
                    var list1 = new ActionList();
                    list1.putInteger( 0 );
                    list1.putInteger( 0 );
                    list1.putInteger( 0 );
                    list1.putInteger( 0 );
                desc5.putList( idminimum, list1 );
                var idmaximum = stringIDToTypeID( "maximum" );
                    var list2 = new ActionList();
                    list2.putInteger( 100 );
                    list2.putInteger( 100 );
                    list2.putInteger( 100 );
                    list2.putInteger( 100 );
                desc5.putList( idmaximum, list2 );
            var idgradientClassEvent = stringIDToTypeID( "gradientClassEvent" );
            desc4.putObject( idgradient, idgradientClassEvent, desc5 );
        var idgradientLayer = stringIDToTypeID( "gradientLayer" );
        desc3.putObject( idtype, idgradientLayer, desc4 );
    var idcontentLayer = stringIDToTypeID( "contentLayer" );
    desc2.putObject( idusing, idcontentLayer, desc3 );
executeAction( idmake, desc2, DialogModes.NO );

Edit: I hadn’t grasped the 10 places correctly, the multiplicator was one zero short … 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 28, 2020 Apr 28, 2020

Great !!! Thank you so much/

Jut one little thing. It's correct for a random "gradient". But what-s the code for a random "gradient transfer curve" ? (I'm not sure it's the good term, I'm french, my photoshop is french, and in french it's "une courbe transfert de dégradé")

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 28, 2020 Apr 28, 2020
// 2020, use it at your own risk;
// =======================================================
var idmake = stringIDToTypeID( "make" );
    var desc8 = new ActionDescriptor();
    var idnull = stringIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idadjustmentLayer = stringIDToTypeID( "adjustmentLayer" );
        ref3.putClass( idadjustmentLayer );
    desc8.putReference( idnull, ref3 );
    var idusing = stringIDToTypeID( "using" );
        var desc9 = new ActionDescriptor();
        var idtype = stringIDToTypeID( "type" );
            var desc10 = new ActionDescriptor();
            var idgradient = stringIDToTypeID( "gradient" );
            var desc11 = new ActionDescriptor();
            var idname = stringIDToTypeID( "name" );
            desc11.putString( idname, "Custom" );
            var idgradientForm = stringIDToTypeID( "gradientForm" );
            var idcolorNoise = stringIDToTypeID( "colorNoise" );
            desc11.putEnumerated( idgradientForm, idgradientForm, idcolorNoise );
            var idshowTransparency = stringIDToTypeID( "showTransparency" );
            desc11.putBoolean( idshowTransparency, false );
            var idvectorColor = stringIDToTypeID( "vectorColor" );
            desc11.putBoolean( idvectorColor, true );
            var idcolorSpace = stringIDToTypeID( "colorSpace" );
            var idRGBColor = stringIDToTypeID( "RGBColor" );
            desc11.putEnumerated( idcolorSpace, idcolorSpace, idRGBColor );
            var idrandomSeed = stringIDToTypeID( "randomSeed" );
            desc11.putInteger( idrandomSeed, Math.round(10000000000 * Math.random()) );
            var idsmoothness = stringIDToTypeID( "smoothness" );
            desc11.putInteger( idsmoothness, 2048 );
            var idminimum = stringIDToTypeID( "minimum" );
                var list1 = new ActionList();
                list1.putInteger( 0 );
                list1.putInteger( 0 );
                list1.putInteger( 0 );
                list1.putInteger( 0 );
                desc11.putList( idminimum, list1 );
            var idmaximum = stringIDToTypeID( "maximum" );
                var list2 = new ActionList();
                list2.putInteger( 100 );
                list2.putInteger( 100 );
                list2.putInteger( 100 );
                list2.putInteger( 100 );
            desc11.putList( idmaximum, list2 );
            var idgradientClassEvent = stringIDToTypeID( "gradientClassEvent" );
            desc10.putObject( idgradient, idgradientClassEvent, desc11 );
        var idgradientMapClass = stringIDToTypeID( "gradientMapClass" );
        desc9.putObject( idtype, idgradientMapClass, desc10 );
    desc8.putObject( idusing, idadjustmentLayer, desc9 );
executeAction( idmake, desc8, DialogModes.NO );
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 28, 2020 Apr 28, 2020

Amazing ! 

Thank you so much ! And Have a nice day from France.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 28, 2020 Apr 28, 2020
LATEST

You’re welcome! 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 24, 2020 Apr 24, 2020

The random seed is apparaently a 10 digit number. 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines