Highlighted

Bring back weight of line tool

Advocate ,
Nov 17, 2020

Copy link to clipboard

Copied

Since the new update (22.0.1) did not bring back the weight function of the line tool, it would be helpful if someone could write a script to make this possible again.

 

The weight function still exists, but is no longer accessible.

 

Here is a script that shows that the function still exists:

 

var idMk = charIDToTypeID( "Mk  " );
    var desc51 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref13 = new ActionReference();
        var idcontentLayer = stringIDToTypeID( "contentLayer" );
        ref13.putClass( idcontentLayer );
    desc51.putReference( idnull, ref13 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc52 = new ActionDescriptor();
        var idType = charIDToTypeID( "Type" );
            var desc53 = new ActionDescriptor();
            var idClr = charIDToTypeID( "Clr " );
                var desc54 = new ActionDescriptor();
                var idRd = charIDToTypeID( "Rd  " );
                desc54.putDouble( idRd, 255.000000 );
                var idGrn = charIDToTypeID( "Grn " );
                desc54.putDouble( idGrn, 241.922698 );
                var idBl = charIDToTypeID( "Bl  " );
                desc54.putDouble( idBl, 0.000000 );
            var idRGBC = charIDToTypeID( "RGBC" );
            desc53.putObject( idClr, idRGBC, desc54 );
        var idsolidColorLayer = stringIDToTypeID( "solidColorLayer" );
        desc52.putObject( idType, idsolidColorLayer, desc53 );
        var idShp = charIDToTypeID( "Shp " );
            var desc55 = new ActionDescriptor();
            var idStrt = charIDToTypeID( "Strt" );
                var desc56 = new ActionDescriptor();
                var idHrzn = charIDToTypeID( "Hrzn" );
                var idRlt = charIDToTypeID( "#Rlt" );
                desc56.putUnitDouble( idHrzn, idRlt, 20.000 );
                var idVrtc = charIDToTypeID( "Vrtc" );
                var idRlt = charIDToTypeID( "#Rlt" );
                desc56.putUnitDouble( idVrtc, idRlt, 100.000 );
            var idPnt = charIDToTypeID( "Pnt " );
            desc55.putObject( idStrt, idPnt, desc56 );
            var idEnd = charIDToTypeID( "End " );
                var desc57 = new ActionDescriptor();
                var idHrzn = charIDToTypeID( "Hrzn" );
                var idRlt = charIDToTypeID( "#Rlt" );
                desc57.putUnitDouble( idHrzn, idRlt, 220.000 );
                var idVrtc = charIDToTypeID( "Vrtc" );
                var idRlt = charIDToTypeID( "#Rlt" );
                desc57.putUnitDouble( idVrtc, idRlt, 100.000 );
            var idPnt = charIDToTypeID( "Pnt " );
            desc55.putObject( idEnd, idPnt, desc57 );
            var idWdth = charIDToTypeID( "Wdth" );
            var idPxl = charIDToTypeID( "#Pxl" );
            desc55.putUnitDouble( idWdth, idPxl, 13.000000 );
            var idStrA = charIDToTypeID( "StrA" );
                var desc58 = new ActionDescriptor();
                var idWdth = charIDToTypeID( "Wdth" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc58.putUnitDouble( idWdth, idPrc, 25.000000 );
                var idLngt = charIDToTypeID( "Lngt" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc58.putUnitDouble( idLngt, idPrc, 50.000000 );
                var idCncv = charIDToTypeID( "Cncv" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc58.putUnitDouble( idCncv, idPrc, 0.000000 );
                var idOn = charIDToTypeID( "On  " );
                desc58.putBoolean( idOn, true );
            var idcArw = charIDToTypeID( "cArw" );
            desc55.putObject( idStrA, idcArw, desc58 );
            var idEndA = charIDToTypeID( "EndA" );
                var desc59 = new ActionDescriptor();
                var idWdth = charIDToTypeID( "Wdth" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc59.putUnitDouble( idWdth, idPrc, 25.000000 );
                var idLngt = charIDToTypeID( "Lngt" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc59.putUnitDouble( idLngt, idPrc, 50.000000 );
                var idCncv = charIDToTypeID( "Cncv" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc59.putUnitDouble( idCncv, idPrc, 0.000000 );
                var idOn = charIDToTypeID( "On  " );
                desc59.putBoolean( idOn, true );
            var idcArw = charIDToTypeID( "cArw" );
            desc55.putObject( idEndA, idcArw, desc59 );
        var idLn = charIDToTypeID( "Ln  " );
        desc52.putObject( idShp, idLn, desc55 );
        var idstrokeStyle = stringIDToTypeID( "strokeStyle" );
            var desc60 = new ActionDescriptor();
            var idstrokeStyleVersion = stringIDToTypeID( "strokeStyleVersion" );
            desc60.putInteger( idstrokeStyleVersion, 2 );
            var idstrokeEnabled = stringIDToTypeID( "strokeEnabled" );
            desc60.putBoolean( idstrokeEnabled, true );
            var idfillEnabled = stringIDToTypeID( "fillEnabled" );
            desc60.putBoolean( idfillEnabled, true );
            var idstrokeStyleLineWidth = stringIDToTypeID( "strokeStyleLineWidth" );
            var idPxl = charIDToTypeID( "#Pxl" );
            desc60.putUnitDouble( idstrokeStyleLineWidth, idPxl, 2.510000 );
            var idstrokeStyleLineDashOffset = stringIDToTypeID( "strokeStyleLineDashOffset" );
            var idPnt = charIDToTypeID( "#Pnt" );
            desc60.putUnitDouble( idstrokeStyleLineDashOffset, idPnt, 0.000000 );
            var idstrokeStyleMiterLimit = stringIDToTypeID( "strokeStyleMiterLimit" );
            desc60.putDouble( idstrokeStyleMiterLimit, 100.000000 );
            var idstrokeStyleLineCapType = stringIDToTypeID( "strokeStyleLineCapType" );
            var idstrokeStyleLineCapType = stringIDToTypeID( "strokeStyleLineCapType" );
            var idstrokeStyleButtCap = stringIDToTypeID( "strokeStyleButtCap" );
            desc60.putEnumerated( idstrokeStyleLineCapType, idstrokeStyleLineCapType, idstrokeStyleButtCap );
            var idstrokeStyleLineJoinType = stringIDToTypeID( "strokeStyleLineJoinType" );
            var idstrokeStyleLineJoinType = stringIDToTypeID( "strokeStyleLineJoinType" );
            var idstrokeStyleMiterJoin = stringIDToTypeID( "strokeStyleMiterJoin" );
            desc60.putEnumerated( idstrokeStyleLineJoinType, idstrokeStyleLineJoinType, idstrokeStyleMiterJoin );
            var idstrokeStyleLineAlignment = stringIDToTypeID( "strokeStyleLineAlignment" );
            var idstrokeStyleLineAlignment = stringIDToTypeID( "strokeStyleLineAlignment" );
            var idstrokeStyleAlignCenter = stringIDToTypeID( "strokeStyleAlignCenter" );
            desc60.putEnumerated( idstrokeStyleLineAlignment, idstrokeStyleLineAlignment, idstrokeStyleAlignCenter );
            var idstrokeStyleScaleLock = stringIDToTypeID( "strokeStyleScaleLock" );
            desc60.putBoolean( idstrokeStyleScaleLock, false );
            var idstrokeStyleStrokeAdjust = stringIDToTypeID( "strokeStyleStrokeAdjust" );
            desc60.putBoolean( idstrokeStyleStrokeAdjust, false );
            var idstrokeStyleLineDashSet = stringIDToTypeID( "strokeStyleLineDashSet" );
                var list5 = new ActionList();
                var idNne = charIDToTypeID( "#Nne" );
                list5.putUnitDouble( idNne, 4.000000 );
                var idNne = charIDToTypeID( "#Nne" );
                list5.putUnitDouble( idNne, 2.000000 );
            desc60.putList( idstrokeStyleLineDashSet, list5 );
            var idstrokeStyleBlendMode = stringIDToTypeID( "strokeStyleBlendMode" );
            var idBlnM = charIDToTypeID( "BlnM" );
            var idNrml = charIDToTypeID( "Nrml" );
            desc60.putEnumerated( idstrokeStyleBlendMode, idBlnM, idNrml );
            var idstrokeStyleOpacity = stringIDToTypeID( "strokeStyleOpacity" );
            var idPrc = charIDToTypeID( "#Prc" );
            desc60.putUnitDouble( idstrokeStyleOpacity, idPrc, 100.000000 );
            var idstrokeStyleContent = stringIDToTypeID( "strokeStyleContent" );
                var desc61 = new ActionDescriptor();
                var idClr = charIDToTypeID( "Clr " );
                    var desc62 = new ActionDescriptor();
                    var idRd = charIDToTypeID( "Rd  " );
                    desc62.putDouble( idRd, 237.281931 );
                    var idGrn = charIDToTypeID( "Grn " );
                    desc62.putDouble( idGrn, 28.433876 );
                    var idBl = charIDToTypeID( "Bl  " );
                    desc62.putDouble( idBl, 36.261481 );
                var idRGBC = charIDToTypeID( "RGBC" );
                desc61.putObject( idClr, idRGBC, desc62 );
            var idsolidColorLayer = stringIDToTypeID( "solidColorLayer" );
            desc60.putObject( idstrokeStyleContent, idsolidColorLayer, desc61 );
            var idstrokeStyleResolution = stringIDToTypeID( "strokeStyleResolution" );
            desc60.putDouble( idstrokeStyleResolution, 72.000000 );
        var idstrokeStyle = stringIDToTypeID( "strokeStyle" );
        desc52.putObject( idstrokeStyle, idstrokeStyle, desc60 );
    var idcontentLayer = stringIDToTypeID( "contentLayer" );
    desc51.putObject( idUsng, idcontentLayer, desc52 );
    var idLyrI = charIDToTypeID( "LyrI" );
    desc51.putInteger( idLyrI, 4 );
executeAction( idMk, desc51, DialogModes.NO );

 

 

I have tried to fix it myself, but I'm not a programmer and not able to get the values directly from the line tool (e.g. to distinguish between start and end arrow or to get the used settings for color or stroke, etc.)

Here is my humble attempt to at least work with fixed values:

 

#target photoshop

var linewidth = 0;

   /*
   <javascriptresource>
   <name>line tool</name>
   <about>line tool
Tom, 2020</about>
<category>OwnScripts</category>
   <eventid>fba55381-88fc-4998-bd03-a06cca7247b9</eventid>
   <terminology><![CDATA[<< /Version 1 
                            /Events << 
                             /fba55381-88fc-4998-bd03-a06cca7247b9 [(line tool)<<
                             >>] 
                            >> 
                         >> ]]></terminology>
   </javascriptresource>
   */

(d = new ActionDescriptor).putString(stringIDToTypeID("null"), decodeURI(new File($.fileName).name));
app.playbackParameters = d;

var strtRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
var doc = activeDocument;
var res = doc.resolution;
doc.resizeImage(undefined, undefined, 72, ResampleMethod.NONE);
var workPath = doc.pathItems[0];

if(workPath.subPathItems[0].pathPoints.length==2){
var start = workPath.subPathItems[0].pathPoints[0].leftDirection;
var end = workPath.subPathItems[0].pathPoints[1].leftDirection;
var fillEnabled = false
var sa = false
var sawidth = 0
var sawlength = 0
var sacon = 0
var ea = false
var eawidth = 0
var eawlength = 0
var eacon = 0
}
if(workPath.subPathItems[0].pathPoints.length==6){
//    alert(workPath.subPathItems[0].pathPoints.length);
var start = workPath.subPathItems[0].pathPoints[2].leftDirection;
var end = workPath.subPathItems[0].pathPoints[5].leftDirection;
var fillEnabled = false
var sa = true
var sawidth = 50
var sawlength = 100
var sacon = 0
var ea = false
var eawidth = 0
var eawlength = 0
var eacon = 0
}
if(workPath.subPathItems[0].pathPoints.length==10){
var fillEnabled = false
var sa = true
var sawidth = 50
var sawlength = 100
var sacon = 0
var ea = true
var eawidth = 50
var eawlength = 100
var eacon = 0
var start = workPath.subPathItems[0].pathPoints[2].leftDirection;
var end = workPath.subPathItems[0].pathPoints[7].leftDirection;
}

if(linewidth==0){
var linewidth= prompt("Linewidth: ",15);
};

    if (doc.pathItems[0].kind == PathKind.WORKPATH) {
    make(255, 255, 0, start[0], start[1], end[0], end[1], linewidth, sawidth, sawlength, sacon, sa, eawidth, eawlength, eacon, ea, 2, false,fillEnabled, 2.51, 0, 100, false, false, 4, 2, 100, 237.281931, 28.433876, 36.261481, 72, 4);
       zWorkPath = localize("$$$/Actions/Key/Document/WorkPath=Work Path");
       var tempPath = app.activeDocument.pathItems.getByName(zWorkPath);
       tempPath.remove();
    } else if (doc.pathItems[0].kind == PathKind.VECTORMASK) {
//        doc.pathItems[0].makeClippingPath(.2);
make(255, 255, 0, start[0], start[1], end[0], end[1], linewidth, sawidth, sawlength, sacon, sa, eawidth, eawlength, eacon, ea, 2, false,fillEnabled, 2.51, 0, 100, false, false, 4, 2, 100, 237.281931, 28.433876, 36.261481, 72, 4);
var idslct = charIDToTypeID("slct");
var desc53 = new ActionDescriptor();
var idnull = charIDToTypeID("null");
var ref8 = new ActionReference();
var idLyr = charIDToTypeID("Lyr ");
var idOrdn = charIDToTypeID("Ordn");
var idBckw = charIDToTypeID("Bckw");
ref8.putEnumerated(idLyr, idOrdn, idBckw);
desc53.putReference(idnull, ref8);
var idMkVs = charIDToTypeID("MkVs");
desc53.putBoolean(idMkVs, false);
var idLyrI = charIDToTypeID("LyrI");
var list9 = new ActionList();
list9.putInteger(17);
desc53.putList(idLyrI, list9);
executeAction(idslct, desc53, DialogModes.NO);

activeDocument.activeLayer.remove()

var idslct = charIDToTypeID("slct");
var desc52 = new ActionDescriptor();
var idnull = charIDToTypeID("null");
var ref7 = new ActionReference();
var idLyr = charIDToTypeID("Lyr ");
var idOrdn = charIDToTypeID("Ordn");
var idFrwr = charIDToTypeID("Frwr");
ref7.putEnumerated(idLyr, idOrdn, idFrwr);
desc52.putReference(idnull, ref7);
var idMkVs = charIDToTypeID("MkVs");
desc52.putBoolean(idMkVs, false);
var idLyrI = charIDToTypeID("LyrI");
var list8 = new ActionList();
list8.putInteger(18);
desc52.putList(idLyrI, list8);
executeAction(idslct, desc52, DialogModes.NO);
};

doc.resizeImage(undefined, undefined, res, ResampleMethod.NONE);

app.preferences.rulerUnits = strtRulerUnits;

function make(red, Grn, blue, horizontal, vertical, horizontal2, vertical2, width, sawidth, sawlength, sacon, on, width3, length3, concavity2, on2, strokeStyleVersion, strokeEnabled, fillEnabled, strokeStyleLineWidth, strokeStyleLineDashOffset, strokeStyleMiterLimit, strokeStyleScaleLock, strokeStyleStrokeAdjust, noneUnit, noneUnit2, strokeStyleOpacity, red2, Grn2, blue2, strokeStyleResolution, layerID) {
	var c2t = function (s) {
		return app.charIDToTypeID(s);
	};

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

	var descriptor = new ActionDescriptor();
	var reference = new ActionReference();
	reference.putClass( s2t( "contentLayer" ));
	descriptor.putReference( c2t( "null" ), reference );
	var descriptor2 = new ActionDescriptor();
	var descriptor3 = new ActionDescriptor();
	var descriptor4 = new ActionDescriptor();
	descriptor4.putDouble( s2t( "red" ), red );
	descriptor4.putDouble( c2t( "Grn " ), Grn );
	descriptor4.putDouble( s2t( "blue" ), blue );
	descriptor3.putObject( s2t( "color" ), s2t( "RGBColor" ), descriptor4 );
	descriptor2.putObject( s2t( "type" ), s2t( "solidColorLayer" ), descriptor3 );
	var descriptor5 = new ActionDescriptor();
	var descriptor6 = new ActionDescriptor();
	descriptor6.putUnitDouble( s2t( "horizontal" ), s2t( "distanceUnit" ), horizontal );
	descriptor6.putUnitDouble( s2t( "vertical" ), s2t( "distanceUnit" ), vertical );
	descriptor5.putObject( c2t( "Strt" ), c2t( "Pnt " ), descriptor6 );
	var descriptor7 = new ActionDescriptor();
	descriptor7.putUnitDouble( s2t( "horizontal" ), s2t( "distanceUnit" ), horizontal2 );
	descriptor7.putUnitDouble( s2t( "vertical" ), s2t( "distanceUnit" ), vertical2 );
	descriptor5.putObject( s2t( "end" ), c2t( "Pnt " ), descriptor7 );
	descriptor5.putUnitDouble( s2t( "width" ), s2t( "pixelsUnit" ), width );
	var descriptor8 = new ActionDescriptor();
	descriptor8.putUnitDouble( s2t( "width" ), s2t( "percentUnit" ), sawidth );
	// 25
	descriptor8.putUnitDouble( s2t( "length" ), s2t( "percentUnit" ), sawlength );
	// 50
	descriptor8.putUnitDouble( s2t( "concavity" ), s2t( "percentUnit" ), sacon );
	descriptor8.putBoolean( s2t( "on" ), on );
	descriptor5.putObject( s2t( "startArrowhead" ), s2t( "arrowhead" ), descriptor8 );
	var descriptor9 = new ActionDescriptor();
	descriptor9.putUnitDouble( s2t( "width" ), s2t( "percentUnit" ), width3 );
	// 25
	descriptor9.putUnitDouble( s2t( "length" ), s2t( "percentUnit" ), length3 );
	// 50
	descriptor9.putUnitDouble( s2t( "concavity" ), s2t( "percentUnit" ), concavity2 );
	descriptor9.putBoolean( s2t( "on" ), on2 );
	descriptor5.putObject( s2t( "endArrowhead" ), s2t( "arrowhead" ), descriptor9 );
	descriptor2.putObject( s2t( "shape" ), s2t( "lineClass" ), descriptor5 );
	var descriptor10 = new ActionDescriptor();
	descriptor10.putInteger( s2t( "strokeStyleVersion" ), strokeStyleVersion );
	descriptor10.putBoolean( s2t( "strokeEnabled" ), strokeEnabled );
	// false/true to (de)activate stroke
	descriptor10.putBoolean( s2t( "fillEnabled" ), fillEnabled );
	// false/true to (de)activate fill
	descriptor10.putUnitDouble( s2t( "strokeStyleLineWidth" ), s2t( "pixelsUnit" ), strokeStyleLineWidth );
	//Stroke width
	descriptor10.putUnitDouble( s2t( "strokeStyleLineDashOffset" ), s2t( "pointsUnit" ), strokeStyleLineDashOffset );
	descriptor10.putDouble( s2t( "strokeStyleMiterLimit" ), strokeStyleMiterLimit );
	descriptor10.putEnumerated( s2t( "strokeStyleLineCapType" ), s2t( "strokeStyleLineCapType" ), s2t( "strokeStyleButtCap" ));
	descriptor10.putEnumerated( s2t( "strokeStyleLineJoinType" ), s2t( "strokeStyleLineJoinType" ), s2t( "strokeStyleMiterJoin" ));
	//Center/Outside/Inside
	descriptor10.putEnumerated( s2t( "strokeStyleLineAlignment" ), s2t( "strokeStyleLineAlignment" ), s2t( "strokeStyleAlignInside" ));
	//Center/Outside/Inside
	descriptor10.putBoolean( s2t( "strokeStyleScaleLock" ), strokeStyleScaleLock );
	descriptor10.putBoolean( s2t( "strokeStyleStrokeAdjust" ), strokeStyleStrokeAdjust );
	var list = new ActionList();
	list.putUnitDouble( s2t( "noneUnit" ), noneUnit );
	// Dash length
	list.putUnitDouble( s2t( "noneUnit" ), noneUnit2 );
	// Gap length
	descriptor10.putList( s2t( "strokeStyleLineDashSet" ), list );
	descriptor10.putEnumerated( s2t( "strokeStyleBlendMode" ), s2t( "blendMode" ), s2t( "normal" ));
	descriptor10.putUnitDouble( s2t( "strokeStyleOpacity" ), s2t( "percentUnit" ), strokeStyleOpacity );
	// Opactiy
	var descriptor11 = new ActionDescriptor();
	var descriptor12 = new ActionDescriptor();
	descriptor12.putDouble( s2t( "red" ), red2 );
	descriptor12.putDouble( c2t( "Grn " ), Grn2 );
	descriptor12.putDouble( s2t( "blue" ), blue2 );
	descriptor11.putObject( s2t( "color" ), s2t( "RGBColor" ), descriptor12 );
	descriptor10.putObject( s2t( "strokeStyleContent" ), s2t( "solidColorLayer" ), descriptor11 );
	descriptor10.putDouble( s2t( "strokeStyleResolution" ), strokeStyleResolution );
	descriptor2.putObject( s2t( "strokeStyle" ), s2t( "strokeStyle" ), descriptor10 );
	descriptor.putObject( s2t( "using" ), s2t( "contentLayer" ), descriptor2 );
	descriptor.putInteger( s2t( "layerID" ), layerID );
	executeAction( s2t( "make" ), descriptor, DialogModes.NO );
}

 


Any help is appreciated!

Tom

TOPICS
Actions and scripting

Views

78

Likes

Translate

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

Bring back weight of line tool

Advocate ,
Nov 17, 2020

Copy link to clipboard

Copied

Since the new update (22.0.1) did not bring back the weight function of the line tool, it would be helpful if someone could write a script to make this possible again.

 

The weight function still exists, but is no longer accessible.

 

Here is a script that shows that the function still exists:

 

var idMk = charIDToTypeID( "Mk  " );
    var desc51 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref13 = new ActionReference();
        var idcontentLayer = stringIDToTypeID( "contentLayer" );
        ref13.putClass( idcontentLayer );
    desc51.putReference( idnull, ref13 );
    var idUsng = charIDToTypeID( "Usng" );
        var desc52 = new ActionDescriptor();
        var idType = charIDToTypeID( "Type" );
            var desc53 = new ActionDescriptor();
            var idClr = charIDToTypeID( "Clr " );
                var desc54 = new ActionDescriptor();
                var idRd = charIDToTypeID( "Rd  " );
                desc54.putDouble( idRd, 255.000000 );
                var idGrn = charIDToTypeID( "Grn " );
                desc54.putDouble( idGrn, 241.922698 );
                var idBl = charIDToTypeID( "Bl  " );
                desc54.putDouble( idBl, 0.000000 );
            var idRGBC = charIDToTypeID( "RGBC" );
            desc53.putObject( idClr, idRGBC, desc54 );
        var idsolidColorLayer = stringIDToTypeID( "solidColorLayer" );
        desc52.putObject( idType, idsolidColorLayer, desc53 );
        var idShp = charIDToTypeID( "Shp " );
            var desc55 = new ActionDescriptor();
            var idStrt = charIDToTypeID( "Strt" );
                var desc56 = new ActionDescriptor();
                var idHrzn = charIDToTypeID( "Hrzn" );
                var idRlt = charIDToTypeID( "#Rlt" );
                desc56.putUnitDouble( idHrzn, idRlt, 20.000 );
                var idVrtc = charIDToTypeID( "Vrtc" );
                var idRlt = charIDToTypeID( "#Rlt" );
                desc56.putUnitDouble( idVrtc, idRlt, 100.000 );
            var idPnt = charIDToTypeID( "Pnt " );
            desc55.putObject( idStrt, idPnt, desc56 );
            var idEnd = charIDToTypeID( "End " );
                var desc57 = new ActionDescriptor();
                var idHrzn = charIDToTypeID( "Hrzn" );
                var idRlt = charIDToTypeID( "#Rlt" );
                desc57.putUnitDouble( idHrzn, idRlt, 220.000 );
                var idVrtc = charIDToTypeID( "Vrtc" );
                var idRlt = charIDToTypeID( "#Rlt" );
                desc57.putUnitDouble( idVrtc, idRlt, 100.000 );
            var idPnt = charIDToTypeID( "Pnt " );
            desc55.putObject( idEnd, idPnt, desc57 );
            var idWdth = charIDToTypeID( "Wdth" );
            var idPxl = charIDToTypeID( "#Pxl" );
            desc55.putUnitDouble( idWdth, idPxl, 13.000000 );
            var idStrA = charIDToTypeID( "StrA" );
                var desc58 = new ActionDescriptor();
                var idWdth = charIDToTypeID( "Wdth" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc58.putUnitDouble( idWdth, idPrc, 25.000000 );
                var idLngt = charIDToTypeID( "Lngt" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc58.putUnitDouble( idLngt, idPrc, 50.000000 );
                var idCncv = charIDToTypeID( "Cncv" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc58.putUnitDouble( idCncv, idPrc, 0.000000 );
                var idOn = charIDToTypeID( "On  " );
                desc58.putBoolean( idOn, true );
            var idcArw = charIDToTypeID( "cArw" );
            desc55.putObject( idStrA, idcArw, desc58 );
            var idEndA = charIDToTypeID( "EndA" );
                var desc59 = new ActionDescriptor();
                var idWdth = charIDToTypeID( "Wdth" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc59.putUnitDouble( idWdth, idPrc, 25.000000 );
                var idLngt = charIDToTypeID( "Lngt" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc59.putUnitDouble( idLngt, idPrc, 50.000000 );
                var idCncv = charIDToTypeID( "Cncv" );
                var idPrc = charIDToTypeID( "#Prc" );
                desc59.putUnitDouble( idCncv, idPrc, 0.000000 );
                var idOn = charIDToTypeID( "On  " );
                desc59.putBoolean( idOn, true );
            var idcArw = charIDToTypeID( "cArw" );
            desc55.putObject( idEndA, idcArw, desc59 );
        var idLn = charIDToTypeID( "Ln  " );
        desc52.putObject( idShp, idLn, desc55 );
        var idstrokeStyle = stringIDToTypeID( "strokeStyle" );
            var desc60 = new ActionDescriptor();
            var idstrokeStyleVersion = stringIDToTypeID( "strokeStyleVersion" );
            desc60.putInteger( idstrokeStyleVersion, 2 );
            var idstrokeEnabled = stringIDToTypeID( "strokeEnabled" );
            desc60.putBoolean( idstrokeEnabled, true );
            var idfillEnabled = stringIDToTypeID( "fillEnabled" );
            desc60.putBoolean( idfillEnabled, true );
            var idstrokeStyleLineWidth = stringIDToTypeID( "strokeStyleLineWidth" );
            var idPxl = charIDToTypeID( "#Pxl" );
            desc60.putUnitDouble( idstrokeStyleLineWidth, idPxl, 2.510000 );
            var idstrokeStyleLineDashOffset = stringIDToTypeID( "strokeStyleLineDashOffset" );
            var idPnt = charIDToTypeID( "#Pnt" );
            desc60.putUnitDouble( idstrokeStyleLineDashOffset, idPnt, 0.000000 );
            var idstrokeStyleMiterLimit = stringIDToTypeID( "strokeStyleMiterLimit" );
            desc60.putDouble( idstrokeStyleMiterLimit, 100.000000 );
            var idstrokeStyleLineCapType = stringIDToTypeID( "strokeStyleLineCapType" );
            var idstrokeStyleLineCapType = stringIDToTypeID( "strokeStyleLineCapType" );
            var idstrokeStyleButtCap = stringIDToTypeID( "strokeStyleButtCap" );
            desc60.putEnumerated( idstrokeStyleLineCapType, idstrokeStyleLineCapType, idstrokeStyleButtCap );
            var idstrokeStyleLineJoinType = stringIDToTypeID( "strokeStyleLineJoinType" );
            var idstrokeStyleLineJoinType = stringIDToTypeID( "strokeStyleLineJoinType" );
            var idstrokeStyleMiterJoin = stringIDToTypeID( "strokeStyleMiterJoin" );
            desc60.putEnumerated( idstrokeStyleLineJoinType, idstrokeStyleLineJoinType, idstrokeStyleMiterJoin );
            var idstrokeStyleLineAlignment = stringIDToTypeID( "strokeStyleLineAlignment" );
            var idstrokeStyleLineAlignment = stringIDToTypeID( "strokeStyleLineAlignment" );
            var idstrokeStyleAlignCenter = stringIDToTypeID( "strokeStyleAlignCenter" );
            desc60.putEnumerated( idstrokeStyleLineAlignment, idstrokeStyleLineAlignment, idstrokeStyleAlignCenter );
            var idstrokeStyleScaleLock = stringIDToTypeID( "strokeStyleScaleLock" );
            desc60.putBoolean( idstrokeStyleScaleLock, false );
            var idstrokeStyleStrokeAdjust = stringIDToTypeID( "strokeStyleStrokeAdjust" );
            desc60.putBoolean( idstrokeStyleStrokeAdjust, false );
            var idstrokeStyleLineDashSet = stringIDToTypeID( "strokeStyleLineDashSet" );
                var list5 = new ActionList();
                var idNne = charIDToTypeID( "#Nne" );
                list5.putUnitDouble( idNne, 4.000000 );
                var idNne = charIDToTypeID( "#Nne" );
                list5.putUnitDouble( idNne, 2.000000 );
            desc60.putList( idstrokeStyleLineDashSet, list5 );
            var idstrokeStyleBlendMode = stringIDToTypeID( "strokeStyleBlendMode" );
            var idBlnM = charIDToTypeID( "BlnM" );
            var idNrml = charIDToTypeID( "Nrml" );
            desc60.putEnumerated( idstrokeStyleBlendMode, idBlnM, idNrml );
            var idstrokeStyleOpacity = stringIDToTypeID( "strokeStyleOpacity" );
            var idPrc = charIDToTypeID( "#Prc" );
            desc60.putUnitDouble( idstrokeStyleOpacity, idPrc, 100.000000 );
            var idstrokeStyleContent = stringIDToTypeID( "strokeStyleContent" );
                var desc61 = new ActionDescriptor();
                var idClr = charIDToTypeID( "Clr " );
                    var desc62 = new ActionDescriptor();
                    var idRd = charIDToTypeID( "Rd  " );
                    desc62.putDouble( idRd, 237.281931 );
                    var idGrn = charIDToTypeID( "Grn " );
                    desc62.putDouble( idGrn, 28.433876 );
                    var idBl = charIDToTypeID( "Bl  " );
                    desc62.putDouble( idBl, 36.261481 );
                var idRGBC = charIDToTypeID( "RGBC" );
                desc61.putObject( idClr, idRGBC, desc62 );
            var idsolidColorLayer = stringIDToTypeID( "solidColorLayer" );
            desc60.putObject( idstrokeStyleContent, idsolidColorLayer, desc61 );
            var idstrokeStyleResolution = stringIDToTypeID( "strokeStyleResolution" );
            desc60.putDouble( idstrokeStyleResolution, 72.000000 );
        var idstrokeStyle = stringIDToTypeID( "strokeStyle" );
        desc52.putObject( idstrokeStyle, idstrokeStyle, desc60 );
    var idcontentLayer = stringIDToTypeID( "contentLayer" );
    desc51.putObject( idUsng, idcontentLayer, desc52 );
    var idLyrI = charIDToTypeID( "LyrI" );
    desc51.putInteger( idLyrI, 4 );
executeAction( idMk, desc51, DialogModes.NO );

 

 

I have tried to fix it myself, but I'm not a programmer and not able to get the values directly from the line tool (e.g. to distinguish between start and end arrow or to get the used settings for color or stroke, etc.)

Here is my humble attempt to at least work with fixed values:

 

#target photoshop

var linewidth = 0;

   /*
   <javascriptresource>
   <name>line tool</name>
   <about>line tool
Tom, 2020</about>
<category>OwnScripts</category>
   <eventid>fba55381-88fc-4998-bd03-a06cca7247b9</eventid>
   <terminology><![CDATA[<< /Version 1 
                            /Events << 
                             /fba55381-88fc-4998-bd03-a06cca7247b9 [(line tool)<<
                             >>] 
                            >> 
                         >> ]]></terminology>
   </javascriptresource>
   */

(d = new ActionDescriptor).putString(stringIDToTypeID("null"), decodeURI(new File($.fileName).name));
app.playbackParameters = d;

var strtRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
var doc = activeDocument;
var res = doc.resolution;
doc.resizeImage(undefined, undefined, 72, ResampleMethod.NONE);
var workPath = doc.pathItems[0];

if(workPath.subPathItems[0].pathPoints.length==2){
var start = workPath.subPathItems[0].pathPoints[0].leftDirection;
var end = workPath.subPathItems[0].pathPoints[1].leftDirection;
var fillEnabled = false
var sa = false
var sawidth = 0
var sawlength = 0
var sacon = 0
var ea = false
var eawidth = 0
var eawlength = 0
var eacon = 0
}
if(workPath.subPathItems[0].pathPoints.length==6){
//    alert(workPath.subPathItems[0].pathPoints.length);
var start = workPath.subPathItems[0].pathPoints[2].leftDirection;
var end = workPath.subPathItems[0].pathPoints[5].leftDirection;
var fillEnabled = false
var sa = true
var sawidth = 50
var sawlength = 100
var sacon = 0
var ea = false
var eawidth = 0
var eawlength = 0
var eacon = 0
}
if(workPath.subPathItems[0].pathPoints.length==10){
var fillEnabled = false
var sa = true
var sawidth = 50
var sawlength = 100
var sacon = 0
var ea = true
var eawidth = 50
var eawlength = 100
var eacon = 0
var start = workPath.subPathItems[0].pathPoints[2].leftDirection;
var end = workPath.subPathItems[0].pathPoints[7].leftDirection;
}

if(linewidth==0){
var linewidth= prompt("Linewidth: ",15);
};

    if (doc.pathItems[0].kind == PathKind.WORKPATH) {
    make(255, 255, 0, start[0], start[1], end[0], end[1], linewidth, sawidth, sawlength, sacon, sa, eawidth, eawlength, eacon, ea, 2, false,fillEnabled, 2.51, 0, 100, false, false, 4, 2, 100, 237.281931, 28.433876, 36.261481, 72, 4);
       zWorkPath = localize("$$$/Actions/Key/Document/WorkPath=Work Path");
       var tempPath = app.activeDocument.pathItems.getByName(zWorkPath);
       tempPath.remove();
    } else if (doc.pathItems[0].kind == PathKind.VECTORMASK) {
//        doc.pathItems[0].makeClippingPath(.2);
make(255, 255, 0, start[0], start[1], end[0], end[1], linewidth, sawidth, sawlength, sacon, sa, eawidth, eawlength, eacon, ea, 2, false,fillEnabled, 2.51, 0, 100, false, false, 4, 2, 100, 237.281931, 28.433876, 36.261481, 72, 4);
var idslct = charIDToTypeID("slct");
var desc53 = new ActionDescriptor();
var idnull = charIDToTypeID("null");
var ref8 = new ActionReference();
var idLyr = charIDToTypeID("Lyr ");
var idOrdn = charIDToTypeID("Ordn");
var idBckw = charIDToTypeID("Bckw");
ref8.putEnumerated(idLyr, idOrdn, idBckw);
desc53.putReference(idnull, ref8);
var idMkVs = charIDToTypeID("MkVs");
desc53.putBoolean(idMkVs, false);
var idLyrI = charIDToTypeID("LyrI");
var list9 = new ActionList();
list9.putInteger(17);
desc53.putList(idLyrI, list9);
executeAction(idslct, desc53, DialogModes.NO);

activeDocument.activeLayer.remove()

var idslct = charIDToTypeID("slct");
var desc52 = new ActionDescriptor();
var idnull = charIDToTypeID("null");
var ref7 = new ActionReference();
var idLyr = charIDToTypeID("Lyr ");
var idOrdn = charIDToTypeID("Ordn");
var idFrwr = charIDToTypeID("Frwr");
ref7.putEnumerated(idLyr, idOrdn, idFrwr);
desc52.putReference(idnull, ref7);
var idMkVs = charIDToTypeID("MkVs");
desc52.putBoolean(idMkVs, false);
var idLyrI = charIDToTypeID("LyrI");
var list8 = new ActionList();
list8.putInteger(18);
desc52.putList(idLyrI, list8);
executeAction(idslct, desc52, DialogModes.NO);
};

doc.resizeImage(undefined, undefined, res, ResampleMethod.NONE);

app.preferences.rulerUnits = strtRulerUnits;

function make(red, Grn, blue, horizontal, vertical, horizontal2, vertical2, width, sawidth, sawlength, sacon, on, width3, length3, concavity2, on2, strokeStyleVersion, strokeEnabled, fillEnabled, strokeStyleLineWidth, strokeStyleLineDashOffset, strokeStyleMiterLimit, strokeStyleScaleLock, strokeStyleStrokeAdjust, noneUnit, noneUnit2, strokeStyleOpacity, red2, Grn2, blue2, strokeStyleResolution, layerID) {
	var c2t = function (s) {
		return app.charIDToTypeID(s);
	};

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

	var descriptor = new ActionDescriptor();
	var reference = new ActionReference();
	reference.putClass( s2t( "contentLayer" ));
	descriptor.putReference( c2t( "null" ), reference );
	var descriptor2 = new ActionDescriptor();
	var descriptor3 = new ActionDescriptor();
	var descriptor4 = new ActionDescriptor();
	descriptor4.putDouble( s2t( "red" ), red );
	descriptor4.putDouble( c2t( "Grn " ), Grn );
	descriptor4.putDouble( s2t( "blue" ), blue );
	descriptor3.putObject( s2t( "color" ), s2t( "RGBColor" ), descriptor4 );
	descriptor2.putObject( s2t( "type" ), s2t( "solidColorLayer" ), descriptor3 );
	var descriptor5 = new ActionDescriptor();
	var descriptor6 = new ActionDescriptor();
	descriptor6.putUnitDouble( s2t( "horizontal" ), s2t( "distanceUnit" ), horizontal );
	descriptor6.putUnitDouble( s2t( "vertical" ), s2t( "distanceUnit" ), vertical );
	descriptor5.putObject( c2t( "Strt" ), c2t( "Pnt " ), descriptor6 );
	var descriptor7 = new ActionDescriptor();
	descriptor7.putUnitDouble( s2t( "horizontal" ), s2t( "distanceUnit" ), horizontal2 );
	descriptor7.putUnitDouble( s2t( "vertical" ), s2t( "distanceUnit" ), vertical2 );
	descriptor5.putObject( s2t( "end" ), c2t( "Pnt " ), descriptor7 );
	descriptor5.putUnitDouble( s2t( "width" ), s2t( "pixelsUnit" ), width );
	var descriptor8 = new ActionDescriptor();
	descriptor8.putUnitDouble( s2t( "width" ), s2t( "percentUnit" ), sawidth );
	// 25
	descriptor8.putUnitDouble( s2t( "length" ), s2t( "percentUnit" ), sawlength );
	// 50
	descriptor8.putUnitDouble( s2t( "concavity" ), s2t( "percentUnit" ), sacon );
	descriptor8.putBoolean( s2t( "on" ), on );
	descriptor5.putObject( s2t( "startArrowhead" ), s2t( "arrowhead" ), descriptor8 );
	var descriptor9 = new ActionDescriptor();
	descriptor9.putUnitDouble( s2t( "width" ), s2t( "percentUnit" ), width3 );
	// 25
	descriptor9.putUnitDouble( s2t( "length" ), s2t( "percentUnit" ), length3 );
	// 50
	descriptor9.putUnitDouble( s2t( "concavity" ), s2t( "percentUnit" ), concavity2 );
	descriptor9.putBoolean( s2t( "on" ), on2 );
	descriptor5.putObject( s2t( "endArrowhead" ), s2t( "arrowhead" ), descriptor9 );
	descriptor2.putObject( s2t( "shape" ), s2t( "lineClass" ), descriptor5 );
	var descriptor10 = new ActionDescriptor();
	descriptor10.putInteger( s2t( "strokeStyleVersion" ), strokeStyleVersion );
	descriptor10.putBoolean( s2t( "strokeEnabled" ), strokeEnabled );
	// false/true to (de)activate stroke
	descriptor10.putBoolean( s2t( "fillEnabled" ), fillEnabled );
	// false/true to (de)activate fill
	descriptor10.putUnitDouble( s2t( "strokeStyleLineWidth" ), s2t( "pixelsUnit" ), strokeStyleLineWidth );
	//Stroke width
	descriptor10.putUnitDouble( s2t( "strokeStyleLineDashOffset" ), s2t( "pointsUnit" ), strokeStyleLineDashOffset );
	descriptor10.putDouble( s2t( "strokeStyleMiterLimit" ), strokeStyleMiterLimit );
	descriptor10.putEnumerated( s2t( "strokeStyleLineCapType" ), s2t( "strokeStyleLineCapType" ), s2t( "strokeStyleButtCap" ));
	descriptor10.putEnumerated( s2t( "strokeStyleLineJoinType" ), s2t( "strokeStyleLineJoinType" ), s2t( "strokeStyleMiterJoin" ));
	//Center/Outside/Inside
	descriptor10.putEnumerated( s2t( "strokeStyleLineAlignment" ), s2t( "strokeStyleLineAlignment" ), s2t( "strokeStyleAlignInside" ));
	//Center/Outside/Inside
	descriptor10.putBoolean( s2t( "strokeStyleScaleLock" ), strokeStyleScaleLock );
	descriptor10.putBoolean( s2t( "strokeStyleStrokeAdjust" ), strokeStyleStrokeAdjust );
	var list = new ActionList();
	list.putUnitDouble( s2t( "noneUnit" ), noneUnit );
	// Dash length
	list.putUnitDouble( s2t( "noneUnit" ), noneUnit2 );
	// Gap length
	descriptor10.putList( s2t( "strokeStyleLineDashSet" ), list );
	descriptor10.putEnumerated( s2t( "strokeStyleBlendMode" ), s2t( "blendMode" ), s2t( "normal" ));
	descriptor10.putUnitDouble( s2t( "strokeStyleOpacity" ), s2t( "percentUnit" ), strokeStyleOpacity );
	// Opactiy
	var descriptor11 = new ActionDescriptor();
	var descriptor12 = new ActionDescriptor();
	descriptor12.putDouble( s2t( "red" ), red2 );
	descriptor12.putDouble( c2t( "Grn " ), Grn2 );
	descriptor12.putDouble( s2t( "blue" ), blue2 );
	descriptor11.putObject( s2t( "color" ), s2t( "RGBColor" ), descriptor12 );
	descriptor10.putObject( s2t( "strokeStyleContent" ), s2t( "solidColorLayer" ), descriptor11 );
	descriptor10.putDouble( s2t( "strokeStyleResolution" ), strokeStyleResolution );
	descriptor2.putObject( s2t( "strokeStyle" ), s2t( "strokeStyle" ), descriptor10 );
	descriptor.putObject( s2t( "using" ), s2t( "contentLayer" ), descriptor2 );
	descriptor.putInteger( s2t( "layerID" ), layerID );
	executeAction( s2t( "make" ), descriptor, DialogModes.NO );
}

 


Any help is appreciated!

Tom

TOPICS
Actions and scripting

Views

79

Likes

Translate

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
Nov 17, 2020 0
Adobe Community Professional ,
Nov 17, 2020

Copy link to clipboard

Copied

Hi

I am puzzled as to what you are trying to achieve that is not provided by just changing the stroke thickness on the new line tool, which can be done before or after drawing the line ?

Dave

Likes

Translate

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
Reply
Loading...
Nov 17, 2020 1
LEGEND ,
Nov 17, 2020

Copy link to clipboard

Copied

Unfortunately the Stroke-alignment-default seems to be »Inside« … which never seemed to make a lot of sense but in this case probably even less. 

Likes

Translate

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
Reply
Loading...
Nov 17, 2020 0
Adobe Community Professional ,
Nov 17, 2020

Copy link to clipboard

Copied

Mine is set to "centre" but I may well have changed it at some point

Dave

Likes

Translate

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
Reply
Loading...
Nov 17, 2020 1
JJMack LATEST
Most Valuable Participant ,
Nov 17, 2020

Copy link to clipboard

Copied

The problem is if you stroke on the path or outside the path the arrowheads will now NOT point the where they should.  We need line without strokes either line shapes  layer or laid down pixels. Line weight is required.  Strokes  change where arrowheads point and changes the size of the arrowheads.

JJMack

Likes

Translate

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
Reply
Loading...
Nov 17, 2020 1
Advocate ,
Nov 17, 2020

Copy link to clipboard

Copied

I/we want paths with "normal" path outlines...

Paths.jpg

 That's what my script does (in a bad way)...

You draw a line (with(out) arrows) and the script changes the 2-point-path of the line to a 4 point-path (as the old line tool does it).

The problem is that I don't wanna use the fixed values of the script, rather the values of the already existing line/path.

Likes

Translate

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
Reply
Loading...
Nov 17, 2020 0