5 Replies Latest reply on Jun 29, 2017 9:52 PM by Laubender

    Polygon setting


      Hi all,

              i would like to know how set POLYGON SETTING such as options in which i can set the number of SIDE.

             i would like to script the flowing interface


      Thanks in advance!



        • 1. Re: Polygon setting
          Laubender Adobe Community Professional & MVP

          Hi Saeed,


          look this up in DOM documentation.

          E.g. here compiled by Jongware

          Adobe InDesign CS6 (8.0) Object Model JS: PolygonPreference



          • 2. Re: Polygon setting
            Saeedfs Level 1

            Thank you very much Laubender

            the code i wrote is

            var polygon = doc.pages[0].polygons.add  
                    geometricBounds :[ 272.25,12.7,284.25,18.7],// [ "20mm" , "20mm" , "190mm" , "277mm" ] ,   
                    appliedObjectStyle : "None" ,
                    numberOfSides :6,
                    //properties: A property that allows setting of several properties at the same time.,
                    //contents : a.join("\r")+"\r"   

            there is another questions arises

            first : in line 09 what sort of property i can put

            second : is it possible to insert text frame and content not only that

            polygon is grouped with a corresponding text frame.

            as you mention in

            inserting numbers in a polygon

            • 3. Re: Polygon setting
              Laubender Adobe Community Professional & MVP

              Hi Saeed,


              depending what you like to do with the text frame that will correspond with the polygon you could also do a hexagon shaped text frame.

              So this would reduce the task to one single object per unit.


              The trick goes like that:
              First you add a polygon to the page—let's call the variable myPolygonMaster—then you are using property contentType to assign a TEXT_TYPE value like that:


              myPolygonMaster.contentType = ContentType.TEXT_TYPE ;


              Now you have a text frame on the page in the shape of that polygon.

              Or you could build a hexagon with polygons.add() doing a 90° rotation—that could be an advantage—and use the myPolygonMaster.paths[0].entirePath array to build a new text frame with method myPage.textFrames.add() .


              // No specifics here at creation time:
              var myTextFrameMaster = myPage.textFrames.add();
              // The shape can be done in an extra step. We do something like a clone of myPolygonMaster:
              myTextFrameMaster.paths[0].entirePath = myPolygonMaster.paths[0].entirePath;


              One last tip:
              You could do a master object as we can see above.

              Do it without assigning any stroke weight.


              Now you can duplicate and move the master(s) with method duplicate( [x,y] ) in one go to an appropriate place so that you can do a regular pattern of polygons. After doing the pattern you will assign a stroke weight. Test that and check if value anchor of a single path point can be helpful with duplicate() ( believe me, it will :-) ).


              About the properties property of an object ( an ExtendScript specific thing with InDesign only ):

              The value of that property is always an object. That object could hold one or several property/value pairs that are assigned at the same time.


              The schema and notation for that is:


              myObject.properties =
                   property1 : value ,
                   property2 : value ,
                   property3 : value
                   /* etc. etc. */


              Sometimes that could fail, but very often it's the easiest and most convenient way to apply property/value pairs.
              And sometimes you have to use it because there could be dependencies between properties where it is an advantage to apply two property/value pairs at the same time.


              Seeing into your code example you already using the property properties without knowing it.
              You just do an object as argument of method add().


              One could do it also this way:


              app.polygonProperties.properties =
                   insetPercentage : 0 ,
                   numberOfSides : 6


              And then using method add() with all other necessary properties for building the hexagon.

              The difference: With the way above you are changing the perferences app wide for building polygons.


              Note: Maybe there is a little anomaly with method add() of object Polygon: DOM documentation does not list insetPercentage and numberOfSides directly as properties of object Polygon so I would have thought that using the two properties with method polygons.add() would throw an error or would fail silently. ( If you do a for in loop with a polygon object you will find them not listed. )


              Thank you for pointing me at this…

              ( Food for thought )



              1 person found this helpful
              • 4. Re: Polygon setting
                Saeedfs Level 1

                Thank you,

                     appreciating your quick response  and your humility giving your knowledge to others

                • 5. Re: Polygon setting
                  Laubender Adobe Community Professional & MVP

                  Hi Saeed,

                  an error sneaked in with my last snippet.

                  It has to be:


                  app.polygonPreferences.properties = 
                      insetPercentage : 0 , 
                      numberOfSides : 6 


                  It should read app.polygonPreferences of course and not app.polygonProperties …