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

Script: convert path to shape layer not working

Community Expert ,
Nov 21, 2023 Nov 21, 2023

Copy link to clipboard

Copied

With javascript, I was trying to convert a path into a shape layer, with a red fill. I recorded the below script, with ScriptListner, but when run, it does nothing. Any ideas or workarounds?

 

var idMk = charIDToTypeID( "Mk  " );
    var desc340 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref21 = new ActionReference();
        var idcontentLayer = stringIDToTypeID( "contentLayer" );
        ref21.putClass( idcontentLayer );
    desc340.putReference( idnull, ref21 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc341 = new ActionDescriptor();
        var idType = charIDToTypeID( "Type" );
            var desc342 = new ActionDescriptor();
            var idClr = charIDToTypeID( "Clr " );
                var desc343 = new ActionDescriptor();
                var idRd = charIDToTypeID( "Rd  " );
                desc343.putDouble( idRd, 255.000000 );
                var idGrn = charIDToTypeID( "Grn " );
                desc343.putDouble( idGrn, 0.000000 );
                var idBl = charIDToTypeID( "Bl  " );
                desc343.putDouble( idBl, 0.000000 );
            var idRGBC = charIDToTypeID( "RGBC" );
            desc342.putObject( idClr, idRGBC, desc343 );
        var idsolidColorLayer = stringIDToTypeID( "solidColorLayer" );
        desc341.putObject( idType, idsolidColorLayer, desc342 );
        var idShp = charIDToTypeID( "Shp " );
            var desc344 = new ActionDescriptor();
            var idTrgp = charIDToTypeID( "Trgp" );
            var idPthK = charIDToTypeID( "PthK" );
            var idTrgp = charIDToTypeID( "Trgp" );
            desc344.putEnumerated( idTrgp, idPthK, idTrgp );
        var idpathClass = stringIDToTypeID( "pathClass" );
        desc341.putObject( idShp, idpathClass, desc344 );
        var idstrokeStyle = stringIDToTypeID( "strokeStyle" );
            var desc345 = new ActionDescriptor();
            var idstrokeStyleVersion = stringIDToTypeID( "strokeStyleVersion" );
            desc345.putInteger( idstrokeStyleVersion, 2 );
            var idstrokeEnabled = stringIDToTypeID( "strokeEnabled" );
            desc345.putBoolean( idstrokeEnabled, false );
            var idfillEnabled = stringIDToTypeID( "fillEnabled" );
            desc345.putBoolean( idfillEnabled, true );
            var idstrokeStyleLineWidth = stringIDToTypeID( "strokeStyleLineWidth" );
            var idPxl = charIDToTypeID( "#Pxl" );
            desc345.putUnitDouble( idstrokeStyleLineWidth, idPxl, 1.000000 );
            var idstrokeStyleLineDashOffset = stringIDToTypeID( "strokeStyleLineDashOffset" );
            var idPnt = charIDToTypeID( "#Pnt" );
            desc345.putUnitDouble( idstrokeStyleLineDashOffset, idPnt, 0.000000 );
            var idstrokeStyleMiterLimit = stringIDToTypeID( "strokeStyleMiterLimit" );
            desc345.putDouble( idstrokeStyleMiterLimit, 100.000000 );
         

 

TOPICS
Actions and scripting

Views

113
Translate

Report

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
Adobe
Community Expert ,
Nov 21, 2023 Nov 21, 2023

Copy link to clipboard

Copied

LATEST

I discovered the issue. You don't want to use the button in the menubar to convert the path. you want to use the menu item: Layer>New Fill Layer>Solid Color. You get this code instead.

 

var idMk = charIDToTypeID( "Mk  " );
    var desc430 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref30 = new ActionReference();
        var idcontentLayer = stringIDToTypeID( "contentLayer" );
        ref30.putClass( idcontentLayer );
    desc430.putReference( idnull, ref30 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc431 = new ActionDescriptor();
        var idType = charIDToTypeID( "Type" );
            var desc432 = new ActionDescriptor();
            var idClr = charIDToTypeID( "Clr " );
                var desc433 = new ActionDescriptor();
                var idRd = charIDToTypeID( "Rd  " );
                desc433.putDouble( idRd, 59.926071 );
                var idGrn = charIDToTypeID( "Grn " );
                desc433.putDouble( idGrn, 232.000001 );
                var idBl = charIDToTypeID( "Bl  " );
                desc433.putDouble( idBl, 20.019456 );
            var idRGBC = charIDToTypeID( "RGBC" );
            desc432.putObject( idClr, idRGBC, desc433 );
        var idsolidColorLayer = stringIDToTypeID( "solidColorLayer" );
        desc431.putObject( idType, idsolidColorLayer, desc432 );
    var idcontentLayer = stringIDToTypeID( "contentLayer" );
    desc430.putObject( idUsng, idcontentLayer, desc431 );
executeAction( idMk, desc430, DialogModes.NO );

Votes

Translate

Report

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