0 Replies Latest reply on Feb 15, 2014 10:06 AM by AKGeo

    Create area measuring polygon


      Anyone adding area measuring polygons to documents using Javascript?


      I’m using addAnnot to add a polygon, but am unable to get it to measure the area as when creating one interactively with the area measuring tool.


      I set the intent to PolygonDimension, but it looks as if there is more to it.  I tried just copying the properties from another area measuring polygon on the same page, but the area value in the contents property has the value from the original polygon.  It does not update when I change the shape/size of the new polygon either.


      Below is the code that I used to copy the properties from another area measuring polygon. Commented out are the properties that I was using with addAnnot to try to create the new area measuring polygon from scratch.  That was used before the annotation scan loop was added to find the existing area measuring polygon.


      I'm new to Javascript and Adobe, so constructive criticism of the code is appreciated.



      var currentPage = this.pageNum

      var annots = this.getAnnots({Page:this.pageNum,});

      var arrayAuthor = new Array();

      var arrVertices = new Array();

      var oAnnotProps;


      for (var i = 0; i < annots.length; i++){


          // blank the array that holds the Author field parsed out

          arrayAuthor = [];

          arrVertices = [];


          switch (annots[i].type.toUpperCase())


              case "POLYGON":


                  arrayAuthor = annots[i].author.split( / /);

                  switch (arrayAuthor[0].toUpperCase())


                      case "MARKUP" || "MARK-UP" || "MARK":  //this is a mark up polygon


                          oAnnotProps = annots[i].getProps();

                          arrVertices = [[10, 10], [10, 100], [200, 100], [200, 10], [10, 10]]

                          oAnnotProps.vertices = arrVertices;


                          var nAreaAnnot = this.addAnnot( oAnnotProps);


      //                            ({

      //                                Delay:  false,

      //                                page: currentPage,

      //                                type: "Polygon",

      //                                intent: "PolygonDimension",

      //                                author: "MARKUP",

      //                                contents: "0.00 sq ft",

      //                                vertices: arrVertices,

      //                                refType:  "R",

      //                                style:  "D",

      //                                subject:  "Area Measurement",

      //                                strokeColor: color.black

      //                            });