5 Replies Latest reply on Jul 6, 2010 3:59 AM by sstanleyau

    [AS, CS4] Update Link Isn't Working Any More

    tobias.wantzen Level 1

      Hello,

       

      I have updated an (rather big) AppleScript from CS3 to CS4 encountering only minor problems. But there is one thing, for that I need some help.

       

      There is a part within, which changes dimensions of an image and/or updates the link, if the user wants to (userUpdateLink and userChangeDimensions are both bools, fed by GUI-result). theDocName is a string, theImgLinkID is a string containing a number (both fed from a sqlight database).

      Here's the code:

       

      on updateInDesign(theGraphic, theDocName, theImgLinkID, userUpdateLink, userChangeDimensions)
           tell application "Adobe InDesign CS4"
                tell document theDocName
                     if userUpdateLink then
                          set theLink to link id (theImgLinkID as number)
                          set theNewLink to update theLink
                          set theImgLinkID to id of theNewLink
                     end if
                     if userChangeDimensions then
                          tell parent of link id (theImgLinkID as number)
                               if (horizontal scale < 0) then
                                    set horizontal scale to -100.0
                               else
                                    set horizontal scale to 100.0
                               end if
                               if (vertical scale < 0) then
                                    set vertical scale to -100.0
                               else
                                    set vertical scale to 100.0
                               end if
                          end tell
                     end if
                end tell
           end tell
           return theImgLinkID
      end updateInDesign
      
      

       

      I permanently get an error on the line:

                          set theNewLink to update theLink
       
      
      It throws out:

      »

      update link id 49430 of image id 49456 of rectangle id 49431 of page id 15272 of spread id 15261 of document "xyz.indd"

      "„Adobe InDesign CS4“ hat einen Fehler erhalten: Ungültiges Objekt für diese Anforderung."

      «
      (Which in english is something like: »Adobe InDesign CS4 got an error: Invalid object for this request.«)
      Any suggestions?
      Thanks in advance,
      Tobias.

        • 1. Re: [AS, CS4] Update Link Isn't Working Any More
          sstanleyau Level 4

          What happens if you add:

           

           

          log (exists link id (theImgLinkID as number))
          

          • 2. Re: [AS, CS4] Update Link Isn't Working Any More
            tobias.wantzen Level 1

            Hi Shane,

             

            I added ...

             

            on updateInDesign(theGraphic, theDocName, theImgLinkID, userUpdateLink, userChangeDimensions)
                 tell application "Adobe InDesign CS4"
                      tell document theDocName
                           log (exists link id (theImgLinkID as number))
                           if userUpdateLink then
                                set theLink to link id (theImgLinkID as number)
                                set theNewLink to update theLink
                                set theImgLinkID to id of theNewLink
                           end if
            
            

             

            and got the following in the event protocoll:

             

            tell application "Adobe InDesign CS4"
                 exists link id 58160 of document "xyz.indd"
                      true
                 (*true*)
                 get link id 58160 of document "xyz.indd"
                      link id 58160 of image id 58785 of rectangle id 47318 of page id 42451 of spread id 39642 of document "xyz.indd"
                 update link id 58160 of image id 58785 of rectangle id 47318 of page id 42451 of spread id 39642 of document "xyz.indd"
                      "„Adobe InDesign CS4“ hat einen Fehler erhalten: Ungültiges Objekt für diese Anforderung."
            
            

             

            The link exists (I tested this before with a »select link id 58160 of document "xyz.indd"« script), but the error remains the same.

             

            Tobias

            • 3. Re: [AS, CS4] Update Link Isn't Working Any More
              sstanleyau Level 4

              What's the reason for the update -- the file has moved, or been changed?

              • 4. Re: [AS, CS4] Update Link Isn't Working Any More
                tobias.wantzen Level 1

                The image file was changed in PhotoShop (changing physical dimensions to fit 100% horizontal/vertical scale in layout - and not < or > 100%; downsampling to 200ppi) and needs to be updated.

                 

                I haven't tried, if a relink would work, but in fact I don't need a relink, but an update ...

                 

                Cheers

                Tobias

                • 5. Re: [AS, CS4] Update Link Isn't Working Any More
                  sstanleyau Level 4

                  I'd be tempted to just do a place and be done with it...