3 Replies Latest reply on Apr 14, 2016 6:21 AM by b91823603

    edit object styles

    Suzan.V Level 1

      Hi all,

       

      i got a code to edit all anchored object's position but i would like to know if it possible to create a script to edit all object styles (Anchored objects) section

       

      var myDocument = app.activeDocument;

      app.findObjectPreferences = NothingEnum.nothing;

      app.changeObjectPreferences = NothingEnum.nothing;

      app.findObjectPreferences.anchoredPosition = AnchorPosition.ANCHORED;

      app.findObjectPreferences.anchorPoint =  AnchorPoint.CENTER_ANCHOR;

      app.findObjectPreferences.positionReferencePoint =AnchorPoint.RIGHT_CENTER_ANCHOR;

       

      app.changeObjectPreferences.anchoredPosition = AnchorPosition.ANCHORED;

      app.changeObjectPreferences.anchorPoint =  AnchorPoint.CENTER_ANCHOR;

      app.changeObjectPreferences.positionReferencePoint =AnchorPoint.LEFT_CENTER_ANCHOR;

      myDocument.changeObject();

      app.findObjectPreferences = NothingEnum.nothing;

      app.changeObjectPreferences = NothingEnum.nothing;

       

       

      i want the edit to be on object styles to avoid override

       

      from (Center/Center.Left) to (Center/Center.right)

      from (Top Right/Center.Left) to (Top Left/Center.right)

       

       

      Thanks

        • 1. Re: edit object styles
          b91823603 Level 3

          Hi Suzan,

           

          You could try like this,

           

          var objStyles = app.activeDocument.objectStyles;

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

          {

              if(objStyles[i].anchoredObjectSettings.anchorPoint==AnchorPoint.CENTER_ANCHOR &&

              objStyles[i].anchoredObjectSettings.verticalAlignment==VerticalAlignment.CENTER_ALIGN &&

              objStyles[i].anchoredObjectSettings.horizontalAlignment==HorizontalAlignment.LEFT_ALIGN)

                  objStyles[i].anchoredObjectSettings.horizontalAlignment=HorizontalAlignment.RIGHT_ALIGN;

              else if(objStyles[i].anchoredObjectSettings.anchorPoint==AnchorPoint.RIGHT_CENTER_ANCHOR &&

              objStyles[i].anchoredObjectSettings.verticalAlignment==VerticalAlignment.CENTER_ALIGN &&

              objStyles[i].anchoredObjectSettings.horizontalAlignment==HorizontalAlignment.LEFT_ALIGN)

                  objStyles[i].anchoredObjectSettings.horizontalAlignment=HorizontalAlignment.RIGHT_ALIGN;

          }

          • 2. Re: edit object styles
            Suzan.V Level 1

            Hi dear

             

            actually i found something weird

             

            i have an object style, summery for anchored objects is as shown below

             

            5.png

             

            but the objects acts like

             

            555.png

             

            so how come in summery there is anchored position (vertical): bottom

            and the real position is left.center then left

             

            so can you adjust your code to search for the coordinates that shown on summary at first screenshot

             

             

            Thanks a lot

            • 3. Re: edit object styles
              b91823603 Level 3

              Hi Suzan,

               

              Try this,

               

              var objStyles = app.activeDocument.objectStyles;

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

              {

                  if(objStyles[i].anchoredObjectSettings.anchorPoint==AnchorPoint.CENTER_ANCHOR &&

                  objStyles[i].anchoredObjectSettings.verticalAlignment==VerticalAlignment.BOTTOM_ALIGN &&

                  objStyles[i].anchoredObjectSettings.horizontalAlignment==HorizontalAlignment.LEFT_ALIGN)

                      objStyles[i].anchoredObjectSettings.horizontalAlignment=HorizontalAlignment.RIGHT_ALIGN;

                  else if(objStyles[i].anchoredObjectSettings.anchorPoint==AnchorPoint.RIGHT_CENTER_ANCHOR &&

                  objStyles[i].anchoredObjectSettings.verticalAlignment==VerticalAlignment.BOTTOM_ALIGN &&

                  objStyles[i].anchoredObjectSettings.horizontalAlignment==HorizontalAlignment.LEFT_ALIGN)

                      objStyles[i].anchoredObjectSettings.horizontalAlignment=HorizontalAlignment.RIGHT_ALIGN;

              }