2 Replies Latest reply on Jun 13, 2009 8:44 AM by RockScript

    Return parnt name in CS3

    RockScript Level 1

      var myDoc=app.activeDocument;
      var imageBox=myDoc.layoutWindows[0].activePage.place("C:/Documents and Settings/lw/Desktop/Workflow_1/Artfiles/blo26940_ch10/blo26940_1002.eps");





      This is my script Here i placed Rectancle image from (blo26940_1002.eps) File. In Indesig 2. it returns the (imageBox.parent)Name is Rectangle.


      But when i run this code in CS3 it did'nt return the parent name wht is the problem

        • 1. Re: Return parnt name in CS3
          Dave Saunders Level 4

          Have you found the Object Model Viewer for InDesign CS3? It's under the Help menu in ESTK.


          You're using the place method of a page, so let's look that up:

          Page.place (fileName: File , placePoint:Array of number, destinationLayer: Layer , showingOptions:boolean, autoflowing:boolean, withProperties:Object):Array of any
          Places the file.
          fileName: Data Type: File
          The file to place
          placePoint: Data Type: Array of number
          The point at which to place (Optional)
          destinationLayer: Data Type: Layer
          The layer on which to place (Optional)
          showingOptions (optional): Data Type: boolean, Default Value: false
          Whether to display the import options dialog (Optional)
          autoflowing (optional): Data Type: boolean, Default Value: false
          Whether to autoflow placed text (Optional)
          withProperties: Data Type: Object
          Initial values for properties of the new Page (Optional)


          I'll grant this is a bit hard to read for a newcomer, but looking at your code, there are two points you seem to be missing (based on what's written here):


          1. You're passing a file path as a string to the place method rather than a file object.

          2. The method returns an array (that's what the ":Array of any" means at the end of that first bold string).


          I haven't checked, but your use of a string might actually work, but I would always use a file reference myself. This is trivially easy to do.


          As for the returned array, this is because in theory the place method can be used to place multiple items, so the parent you want is the first (and in this case, only) member of the array.


          So, based on this, and assuming that file path is correct, try this:


          var myDoc=app.activeDocument;
          var imageBox=myDoc.layoutWindows[0].activePage.place(File("C:/Documents and Settings/lw/Desktop/Workflow_1/Artfiles/blo26940_ch10/blo26940_1002.eps"));




          That should do the job, although I'd probably write it like this:


          var myDoc=app.activeDocument;
          var myFile = File("C:/Documents and Settings/lw/Desktop/Workflow_1/Artfiles/blo26940_ch10/blo26940_1002.eps");

          if (myFile.exists) {

               imageBox = myDoc.layoutWindows[0].activePage.place(myFile)[0];


          } else {

               alert("File does not exist")



          Notice that I've moved the [0] to the end of the place statement so that the name of the imageBox variable matches what it really is.



          • 2. Re: Return parnt name in CS3
            RockScript Level 1

            Thanks Dave