1 Reply Latest reply on Aug 12, 2013 4:38 AM by Michael L Hale

    How to create a line without using execute action method.

    AI_learner Level 1

      Hi All,

       

      I want to create a line whose weight and co-ordinate are given to me. I am using ActionDescriptor and execute action method to do this.

       

      Here is my code:

       

          var idcontentLayer = stringIDToTypeID( "contentLayer" );

          var idStrt = charIDToTypeID( "Strt" );

          var idHrzn = charIDToTypeID( "Hrzn" );

          var idPxl = charIDToTypeID( "#Pxl" );

          var idVrtc = charIDToTypeID( "Vrtc" );

          var idPnt = charIDToTypeID( "Pnt " );

       

          var actRef = new ActionReference();

          actRef.putClass( idcontentLayer );

          var layerDesc = new ActionDescriptor();

          layerDesc.putReference( charIDToTypeID( "null" ), actRef );

          var lineDesc = new ActionDescriptor();

          lineDesc.putClass( charIDToTypeID( "Type" ), stringIDToTypeID( "solidColorLayer" ) );

          var propertyDesc = new ActionDescriptor();

          var strtPointDesc = new ActionDescriptor();

          strtPointDesc.putUnitDouble( idHrzn, idPxl,  startX);                         //startX, startY, endX, endY are given..

          strtPointDesc.putUnitDouble( idVrtc, idPxl, startY);

          var endPointDesc = new ActionDescriptor();

          endPointDesc.putUnitDouble( idHrzn, idPxl, endX );

          endPointDesc.putUnitDouble( idVrtc, idPxl, endY );

          propertyDesc.putObject(  charIDToTypeID( "Strt" ), idPnt, strtPointDesc );

          propertyDesc.putObject( charIDToTypeID( "End " ), idPnt, endPointDesc);

          propertyDesc.putUnitDouble( charIDToTypeID( "Wdth" ), idPxl, weight );               // weight is given.

          lineDesc.putObject( charIDToTypeID( "Shp " ), charIDToTypeID( "Ln  " ), propertyDesc );

          layerDesc.putObject( charIDToTypeID( "Usng" ), idcontentLayer, lineDesc );

          executeAction( charIDToTypeID( "Mk  " ), layerDesc, DialogModes.NO );

       

       

      Is there any other way to do the above (using photoshop scripting method)?

       

      Thanks,
      AI