13 Replies Latest reply on Aug 10, 2016 9:56 PM by Silly-V

    Using a function to build and object then define the properties of the object outside of the function.

    richardw26639360

      Trying to develop a script that will create an object we call a slur gauge. We use it as a mark for printing. To get the correct spacing I've had to define each polygon individually.  However I'm not sure how I can then apply properties like stroke, strokeWidth and color to it. Right now it pulls the information from the document itself based on whatever is currently the stroke selection and stroke width. Ultimately I want to be able to duplicate the slur gauge and color it based on the swatches the user has selected prior to running the script. I have other scripts that can identify the swatches so I intend to apply those to this. But first I need to understand how to apply a property to a function or method. Any help??

       

      var doc = app.activeDocument;

       

      var p = { method: function(){

      doc.pathItems.polygon(0,0,0.40,6);

      doc.pathItems.polygon(0,0,2.325,6);

      doc.pathItems.polygon(0,0,4.382,6);

      doc.pathItems.polygon(0,0,6.429,6);

      doc.pathItems.polygon(0,0,8.4765,6);

      doc.pathItems.polygon(0,0,10.4765,6);

      doc.pathItems.polygon(0,0,12.4765,6);

      doc.pathItems.polygon(0,0,14.53,6);

      doc.pathItems.polygon(0,0,16.6,6);

      doc.pathItems.polygon(0,0,18.65,6);

      doc.pathItems.polygon(0,0,20.75,6);

      doc.pathItems.polygon(0,0,22.82,6);

      }}

      slurGauge = p.method();

      slurGauge.filled = false;

      slurGauge.stroked = true;

      slurGauge.strokeWidth = .8;