2 Replies Latest reply on Jun 23, 2015 11:05 AM by VarunParashar31

    Modified "vertical" line rotate and moves




      I have a script for InDesign to create a Vizier on a vertical line and horizontal line. Which works perfectly on horizontal line but it rotate and moves the object from its current position while creating a Vizier on vertical line. Can any one help to make it stay on its original position.


      Here is the script that I have. You can find the error image as well at the bottom. Thanks a lot for your help in advance.


      var half = 0.07;

      var vee = 0.0416666667;

      var obj = app.selection[0];

      if(app.selection.length == 0){ alert("Error: No line is selected; please select a single line to Vizier."); exit(0);}

      if(obj.constructor.name != "GraphicLine"){alert("Error: A line was not selected; please select a line to Vizier."); exit(0);}

      var bounds = obj.geometricBounds;

      var width = bounds[3]-bounds[1];

      var height = bounds[2]-bounds[0];

      var midpoint_h = bounds[2] - (height / 2.0);

      var top = midpoint_h - half;

      var bottom = midpoint_h + half;

      var y1 = bounds[2];

      var midpoint = bounds[1] + (width / 2.0);

      var left = midpoint - half;

      var right = midpoint + half;

      var y = bounds[0];


      if(app.selection.length != 1){ alert("Error: More than one object was selected; please select a single line to Vizier."); exit(0);}


      if(height != 0.0)


      obj.paths.item(0).entirePath = [[bounds[0],  y1], [top, y1],   [midpoint_h, y1+vee],   [bottom, y1],  [bounds[2], y1]];

      app.layoutWindows[0].transformReferencePoint = AnchorPoint.TOP_LEFT_ANCHOR;

      obj.rotationAngle = 90;

      } else if(width != 0.0) {

      obj.paths[0].entirePath = [[bounds[1], y],  [left, y],   [midpoint, y+vee],   [right, y],  [bounds[3], y]];

      }else{alert("Error: the line is not horizontal.\nThis script only works on perfectly horizontal lines.");exit(0);}