6 Replies Latest reply on Jun 8, 2009 12:18 AM by Kay Malek

    Safe rotation in Indesign Server

    Kay Malek Level 1

      Hello,

       

      In the past i had some trouble with rotations of pictures during a import of a page, because a user has switched manually the anchor point and all pictures with rotation-angle rotated out of position. I could fix it with saving the old state, putting the anchor point in the middle, do the import and put the anchor point back to the user default:

       

      var curTransformationPoint = app.layoutWindows[0].transformReferencePoint;

      .

      .

      .

       

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

       

      Do anybody knows in which way Indesign server (CS3) is working these things? Is the achor point in Indesign server always on the default (I think in the upper left) or is there another way to solve safe rotations ?

       

      Thanks

        • 1. Re: Safe rotation in Indesign Server
          Dave Saunders Level 4

          Off the top of my head, I'd tackle this by first calculating the location of the anchor point of interest, rotating, then getting the new location of the point and finally moving.

           

          But this only works easily for 90 degree operations. For arbitrary rotations, I guess I'd bite the bullet and look into the new-fangled transformation logic that superficially looks rather mind-bending.

           

          Which version of Server are we talking about?

           

          Dave

          • 2. Re: Safe rotation in Indesign Server
            Kay Malek Level 1

            Hello Dave,

            Thanks for your fast answer. It is about Indesign Server CS3. The main problem is to ensure that the imports works every time with the same output. The problem with the user setting in the Indesign client made real headache, because the reason for the out of position-rotation was not very obvious for me. I have not very much experience with Indesign server scripting, but i want to ensure, that rotated items, imported via plugin, holds their position independend from any settings.


            I do not want a own rotation method with sin/cos against the native Indesign calculations, because there might occur unexpected effects.

             

            I will ask in another way : Changing the anchor point in Indesign could have effects on importet items, do you know if this is the same in Indesign Server? And if so, do you know how to handle it?

             

            Thanks, Kay

            • 3. Re: Safe rotation in Indesign Server
              Dave Saunders Level 4

              In that sense, InDesign Server doesn't have anchor points because they are properties of a layout window and InDesign server doesn't have windows.

               

              Yet, when a rotation occurs, it must do so relative to some point. If you're rotating in your script by setting the anchor point and then changing the rotation angle, then you need to change your approach for Server.

               

              Can you show the code that you are using for rotation?

               

              Dave

              • 4. Re: Safe rotation in Indesign Server
                Kay Malek Level 1

                Hello Dave,

                 

                The problems i had were linked with the export of a page with rotated items:

                 

                Here is some code:

                 

                if(inddBox.graphics.length > 0){
                           
                        var curImage = inddBox.allGraphics[0];
                       
                        // ALTE WERTE SPEICHERN
                        var curTransformationPoint = app.layoutWindows[0].transformReferencePoint;
                        var curFlip = curImage.flip;
                        var curShear = inddBox.absoluteShearAngle;
                        var curAngle = inddBox.absoluteRotationAngle;
                       
                        var changed = false;
                        if(curFlip != Flip.NONE || curShear != 0 || curAngle != 0){
                            changed = true;
                            app.layoutWindows[0].transformReferencePoint = AnchorPoint.CENTER_ANCHOR;
                            curImage.flip = Flip.NONE;
                            inddBox.absoluteShearAngle = 0;
                            inddBox.absoluteRotationAngle = 0;
                        }
                   
                        cx30Box.setPictureXScale(curImage.absoluteHorizontalScale);
                        cx30Box.setPictureYScale(curImage.absoluteVerticalScale);
                        cx30Box.setPictureXScroll(curImage.geometricBounds[1] - inddBox.geometricBounds[1]);
                        cx30Box.setPictureYScroll(curImage.geometricBounds[0] - inddBox.geometricBounds[0]);
                       
                        if(changed){
                            // ALTE WERTE ZURÜCKSETZEN
                            inddBox.absoluteShearAngle = curShear;
                            inddBox.absoluteRotationAngle = curAngle;
                            curImage.flip = curFlip;
                            app.layoutWindows[0].transformReferencePoint = curTransformationPoint;
                        }
                       
                        cx30Box.setPictureHMirror(false);
                        cx30Box.setPictureVMirror(false);
                       
                        if(curFlip == Flip.HORIZONTAL) {
                            cx30Box.setPictureHMirror(true);
                        }
                        else if(curFlip == Flip.VERTICAL) {
                            cx30Box.setPictureVMirror(true);
                        }
                        else if(curFlip == Flip.HORIZONTAL_AND_VERTICAL) {
                            cx30Box.setPictureHMirror(true);
                            cx30Box.setPictureVMirror(true);
                        }
                           
                        cx30Box.setPictureAngle(curAngle-curImage.rotationAngle);
                        cx30Box.setPictureSkew(curShear-curImage.shearAngle);

                 

                 

                Is the anchor point of the indesign server always in the middle? And what is the behaviour of lines and other items ?

                Or is there something like:

                 

                curImage.flipItem(FlipItemOptions.horizontal, AnchorPoint.centerAnchor);

                 

                Thanks,

                 

                Kay

                1 person found this helpful
                • 5. Re: Safe rotation in Indesign Server
                  Olav Martin Kvern Level 3

                  Hi Kay,

                   

                  You can still use anchor points--but you'll use the anchor points of the object, not the anchor points of the proxy in Control or Transform panel. Here's something that might be useful (the "mySnippet" part is the section you're interested in; the rest is set-up):

                   

                  main();

                  function main(){

                  mySetup();

                  mySnippet();

                  }

                  function mySnippet(){

                  var myRectangle = app.documents.item(0).pages.item(0).rectangles.item(0);

                  var myTransformationMatrix = app.transformationMatrices.add({counterclockwiseRotationAngle:0});

                  //rotateMatrix can take the following parameters: byAngle, byCosine, bySine;

                  //Replace the current matrix with the rotated matrix.

                  myTransformationMatrix = myTransformationMatrix.rotateMatrix(15);

                  myRectangle.transform(CoordinateSpaces.pasteboardCoordinates, AnchorPoint.centerAnchor, myTransformationMatrix);

                  }

                  function mySetup(){

                  app.transformPreferences.whenScaling = WhenScalingOptions.adjustScalingPercentage;

                  var myDocument = app.documents.add();

                  myDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.points;

                  myDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.points;

                  var myPage = myDocument.pages.item(0);

                  var myRectangle = myPage.rectangles.add({geometricBounds:[72, 72, 144, 144]});

                  myDocument.zeroPoint = [108, 108];

                  }

                   

                  Thanks,

                   

                  Ole

                  • 6. Re: Safe rotation in Indesign Server
                    Kay Malek Level 1

                    Hello Ole,

                     

                    Thank you very much for your help. I have found also the Indesign Transformation Tutorial.

                     

                    Best regards,

                     

                    Kay