(JS) Locating the current parentTextFrame from the selection?

Hi Everyone,
In my xml workflow, I will find the xml element (<fig></fig>) through xpath (using glue code.jsx) and placing the figures with calculated bounds.
First I'm selecting the text(xml element) and placing first image & and moving the xml element perfectly, problem occurs while the placing the second
image and caption. I cannot locate the current parentTextFrame, previous parentTextFrame is acting as the current parentTextFrame.
Help me to acheive this....
Here is my full code and see bottom of this message i have pointed out where i need help ......
#include "D:/Program Files/Adobe/Adobe InDesign CS4/Scripts/XML Rules/glue code.jsx"
//==================================================================
//For placement of Figures
//==================================================================
myDoc = app.activeDocument;
var myCount = 0;
var myFolder = Folder.selectDialog("Select image folder");
var figcapdis=prompt("Enter the space between Figure and Figure Caption (pts)", 8, "Figure Caption");
var figcap=parseInt(figcapdis);
          var myRuleSet = new Array (new FindByAttribute("//fig"));
          with(myDoc){
          var elements = xmlElements;
          __processRuleSet(elements.item(0), myRuleSet);
               if(myCount > 0){
                    myCount = 0;
                    }//end if
               }//end with
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function FindByAttribute(myXPath){
     this.name = "FindByAttribute";
     //XPath will match on every description in the XML structure.
     this.xpath = myXPath;
     this.apply = function(myElement, myRuleProcessor){
          var selectPoint = myElement.texts.item(0).select(SelectionOptions.replaceWith);         
          var tFs = app.selection[0].parentTextFrames[0];
          var myFrameBounds = tFs.geometricBounds;
          var myWidth = (myFrameBounds[3]-myFrameBounds[1]);
          var myHeight = (myFrameBounds[2]-myFrameBounds[0]);
          var mySelectionHOffset = myDoc.selection[0].lines[0].horizontalOffset;
          var mySelectionBaseline = myDoc.selection[0].lines[0].baseline;
          var myCurrentPage=tFs.parent;
          app.activeWindow.activePage = myCurrentPage;
          var figName = myElement.xmlElements.item('graphic').xmlAttributes.item('xlink:href').value;
          var figType = myElement.xmlElements.item('graphic').xmlAttributes.item('mime-subtype').value;
          var myFigPath = myFolder+"/"+figName+"."+figType;
          if (File(myFigPath).exists)
               alert("Image exists");
               var myFig = myCurrentPage.place(new File(myFigPath));
               var myFigBounds = myFig[0].geometricBounds;
               var figHeight = (myFigBounds[2]-myFigBounds[0]);
               var figwidth = (myFigBounds[3]-myFigBounds[1]);
               var myParent = myFig[0].parent;
               var myFreeSpace = myHeight-mySelectionBaseline;
               var myBounds = [myFigBounds[2]+figcap,0,myFigBounds[2]+25,myWidth];
               var myCaptionFrame = myCurrentPage.textFrames.add({geometricBounds:myBounds});
               myCaptionFrame.placeXML(myElement);
               myCaptionFrame.fit(FitOptions.frameToContent);
               var item1 = myParent;
               var item2 = myCaptionFrame;
               var myGroup = myCurrentPage.groups.add([item1, item2]);
               myGroup.label = figName;
               var myGroupBound = myGroup.geometricBounds;
               var myGroupHeight = (myGroupBound[2]-myGroupBound[0]);
                    if(figHeight<myFreeSpace)
                         var movePoint = [mySelectionHOffset, mySelectionBaseline+12];
                         //var movePoint = [mySelectionBaseline+24,mySelectionHOffset, mySelectionBaseline+16+figHeight,mySelectionHOffset+figwidth];
                         myGroup.move(movePoint);
                         //myFig[0].geometricBounds = setFigBounds;
                         }//end of figHegiht  less than Free space
                    else
                         if (myCurrentPage == myDoc.pages[-1]){
                              myDoc.pages.add();
                              myCurrentPage = myDoc.pages.nextItem(myCurrentPage);
                         myCurrentPage = myDoc.pages.nextItem(myCurrentPage);
                         var nextTF = tFs.nextTextFrame;
                         var nextTFBounds = nextTF.geometricBounds;
                         myGroup.move(myCurrentPage, [nextTFBounds[1], nextTFBounds[0]]);
                         }//end of else
               myGroup.textWrapPreferences.textWrapMode=TextWrapModes.BOUNDING_BOX_TEXT_WRAP;
               myGroup.textWrapPreferences.textWrapOffset=[24, 6, 24, 6];
               }//end of if -->file exists check
          else
               alert(figName+"."+figType+" doest not exists");
          //var myFigGroup =
        //var myParaStyle = app.documents.item(0).paragraphStyles.item(newStyle);
        //myElement.texts.item(0).applyParagraphStyle(myParaStyle, true);
        myCount++;
        }//end of this.apply
     return true;
I am having problem in the below line
var tFs = app.selection[0].parentTextFrames[0];
I want the parent text frame of the current selection, but it takes the first selection's parent text Frame.
Note: The text frames are in continuous thread...
Looking forward your replies....    
Message was edited by: Green4ever

Hi All,
I am having problem in the below line
var tFs = app.selection[0].parentTextFrames[0];
I want the parent text frame of the current selection, but it takes the first selection's parent text Frame.
Note: The text frames are in continuous thread...
Looking forward your replies....    
Is there any other way to locate the current parent text frame.
Thanks
Green4ever

Similar Messages

  • Need to find our current time from sqlplus

    I need to find out current time from sqlplus.

    select sysdate from dual;
    Hmmm ... time to hit the manuals?!?!

  • Just put my i-tunes library on a 2nd hard drive, how do I easily change the location where the program looks for current songs from the C:/ drive to the new drive without going thru each song individually in the "get info" tab

    I just installed a new hard drive and transfered my i-tunes library to the new drive.  How can I make a bulk change of the location the program looks for the current songs.  I know you can do it song by song from the "get info" tab but I need to do it for all 4500 songs.  I have already changed the location that new files are stored to the new hard drive.

    The pop-up lets you connect to the library file, iTunes Library.itl, on the external drive. This will, in turn, automatically update the preference for the iTunes Media folder to be the iTunes Media or iTunes Music folder inside the iTunes folder on the external drive and it will update the locations of all the content inside the media folder so that it uses the version on the external drive.
    This works seamlessly if all iTunes content was inside the iTunes Media (or iTunes Music) folder (which was itself inside the iTunes library folder) before you moved/copied the iTunes folder. For content outside the iTunes Media folder iTunes should remain connected to the original location. These files should be consolidated (before or after the move/copy) and in addition, if available the library should be upgraded to the newer layout which places iPod Games and Mobile Applications inside the media folder instead of the library folder. (File > Library > Organize Library...)
    For split libraries there are methods to rejoin them before moving (preferred) or repairing after the fact (e.g. my script) which I can go into if needed.
    tt2

  • Active Directory error message "the following object is not from a domain listed in the Select location forestB\username

    Hello Community
        "forestA" is my forest it is a Windows 2008 Server Enterprise Edition
    domain controller using Active Directory and the UI.
        In my forest ("forestA") trust relationship I created a "One-Way, Out-going"
    forest trust with Forest-Wide authentication so that a different forest user(s) or
    group(s) with a different admin in a forest named “forestB” can access the resources in my “forestA”
        But also forestB needs to create a "One-way, Incoming" forest trust so that
    I can either add the user(s) or group(s) from “forestB” into to a "Global Security - Group"
    in my "forestA" or I can
     add user(s)  as  "domain user(s)" from “forestB” into my "forestA".
        The problem is that when I right click  the global group in my forestA  and then
    properties, when I click "Members" and then the "Add" button when I type
    "forestB\username" I get an error message from Active Directory stating:
        "the following object is not from a domain listed in the Select location
    dialog box, and is therefore not valid: forestB\username".
        Am I doing something wrong when creating the one-way trust in my
    “forestA” or is the one-way trust being created wrong by the other domain admin in the other “forestB”?
        Or could I possibly need to select "Change Domain" or "Change Domain Controller"
    before adding the users or Groups to my forestA from forestB?
        That is why I am asking
     how do you add an Active Directory user from one forest into another forest?
        Thank you
        Shabeaut

    Hello Denis Cooper
        That is the end result.
        What I was trying  to do was that I was trying to
     bring in the user(s) and group(s) from “forestB”  into
    my “forestA”  Global group.
        Later on I was going to add the user(s) or Global groups(s) that I brought into my dc in my forestA
     into the domain local groups  on my member servers in my forestA.
        So since the error message is:
    "the following object is not from a domain listed in the Select location dialog box, and is therefore not valid: forestB\username".
    Does your response
     mean only Global group(s) from forestB not domain user(s) from forestB have
     to been added to domain local groups in forestA?
    Or is it also possible to add Global group(s) from “forestB” to Global group(s) in my “forestA” and if so
    how without getting the above error message?
    Thank you
        Shabeaut

  • Unable to create federation in below two subscriptions due to error..."The required VM size or combination of VM sizes is not currently available in the selected region"

    Hi, We recently created new Azure subscriptions and Hosted Services, and now trying to create federations. We are getting and error "The required VM size or combination of VM sizes is not currently available in the selected region". What does this
    mean and how can we resolve this to create a federation successfully? BTW, we use a SQL VM and not a standard A1, A2 types VMs and we have already set the DisablePackageValidation flag to true in these subscriptions.
    Thanks,
    -ven
     

    Hi,
    This is a sql azure issue. You also post this question on SQL azure forum. From error message, you need make sure your VM region is in one location.
    see this:
    http://msdn.microsoft.com/en-us/library/azure/hh597470.aspx
    -Billgiee 

  • Upon upgrading iPhoto, iPhoto Help no longer works.  It gives the error message:  "The selected topic is currently unavailable. To see all iPhoto Help, you must be connected to the Internet." Help!?

    Upon upgrading iPhoto, iPhoto Help no longer works.  It gives the error message:  "The selected topic is currently unavailable. To see all iPhoto Help, you must be connected to the Internet."   I am obviously connected to the internet since you are reading this.
    I tried upgrading permissions but it did not help!?  Can anyone tell me what is wrong?  Thanks

    Try
    Reboot the computer, see if that fixes it.
    Then try:
    Backup your files off the computer (not TimeMachine) and disconnect
    Hold c boot off the 10.6 disk and simply reinstalling OS X
    Log in and update to 10.6.8
    c boot off the 10.6 disk again and use Disk Utility >Repair Disk
    reboot and all should be fine, except some third party programs that install kext files, those will have to be reinstalled from fresh sources.

  • Can't install printer driver: HP Color LaserJet 2605dn drivers "not currently available from the Software Update server"

    I was having trouble printing to my HP Color LaserJet 2605dn from a Mac Pro running Mountain Lion, so I went to System Prefernces -> Print & Scan deleted it and atempted to re-add it.  When I try add the printer I get this message:
    Software for this printer is available from Apple. Would you like to download and install it?
    After clicking Download & Install (the only option other than Cancel), I get this:
    Can't install the software for the Hewlett-Packard HP Color LaserJet 2605dn because it is not currently available from the Software Update server.
    What's the workaround when Mountain Lion can't find the driver?
    Thanks!

    Sean L. wrote:
    I was having trouble printing to my HP Color LaserJet 2605dn from a Mac Pro running Mountain Lion, so I went to System Prefernces -> Print & Scan deleted it and atempted to re-add it.  When I try add the printer I get this message:
    Software for this printer is available from Apple. Would you like to download and install it?
    After clicking Download & Install (the only option other than Cancel), I get this:
    Can't install the software for the Hewlett-Packard HP Color LaserJet 2605dn because it is not currently available from the Software Update server.
    What's the workaround when Mountain Lion can't find the driver?
    Thanks!
    The 2605dn has dual Network and USB connectivity. Which are you attempting to configure: Network or attached USB?
    Printer on, and if networked, use a static IP address
    Print & Scan
    IP
    Provide printer static IP address
    Select Printer Software ... HP Color LaserJet 2605dn driver (not sure about that 2600 driver)
    Add
    Configure Driver under Options and Supplies
    I have a 1994 HP Laserjet 4m Plus set up using these steps and the appropriate driver. I just added another network printer, using the same IP address, but using the above 2605dn driver without any issue other than complaint about a redundant IP address.
    Hopefully, you have already sorted this out.

  • Hi i am trying to install windows to my macbook through boot camp and i get this message Can't install the software because it is not currently available from the Software Update server.!!!what can i do???please help me!

    Can't install the software because it is not currently available from the Software Update server. this is the message that i get a few days now that i am trying to install windows through boot camp to my macbook!does anybody knows what i can do????

    You keep it on the usb stick for after you boot into Windows. From Windows you install the Windows Support software on the stick. Do you realize that you need to buy and install Windows? The Windows Support software you downloaded is only the Windows drivers for your hardware.
    Read the Boot Camp installation instructions and help guides located here: http://www.apple.com/support/bootcamp/

  • How can I locate the drop down menu to select thumbnails for viewing my photos?

    I am using Microsoft Windows Vista. I select Files> Get photos and Videos> From Files and Folders.  I select my photos and In my views I have a choice of different size icons, list, details and tiles.  The icons are a flower image. When I select an image to view it only appears as an extra large icon on the middle right side of the moniter.  I would like to view the thumbnail of the photo bfore I bring to my organizer.  The drop down menu doesn't have a choice for thumbnail.  

    Perhaps I need to supply more details.  I am using PSE9.  I haven't any problem importing the images into the Organizer as I just select the Icons and select "Get Media" or "Open" and they transfer over to the Organizer.  I would like to see the image as a thumbnail not an icon when when making the selection.  If I right click them, the Icon, and select open they will open in "Windows Live Photo Gallery".
    The icons are now listed on the left  side of the monitor about the right middle it states "Select A File To Preview".  When I select a file (icon) a large file (icon) appears in that area and it should be a thumbnail of the image. Somehow I can't locate the drop down menu taht permits me to make that selection.  I think it has something to do with my files being able to open in Windows Live Photo Gallery when right clicking and select Open.  Is the drop down menu only available in Windows 7?

  • When I download photos from a flash drive,everything is fine and they show in Events and Pictures, but when I click on the individual pic I get an error message saying that it cannot locate the JPG. Any thoughts?

    When I download photos from a flash drive,everything is fine and they show in Events and Pictures, but when I click on the individual pic I get an error message saying that it cannot locate the JPG. Any thoughts?

    It sounds like your iPhoto Advanced preferences are set to not copy photos during import, i.e. a Referenced library:
    Check your Advanced preferences to see if that's the case. If it is the best solution would be to select the checkbox to copy the photos and reimport the photos from the flash drive.  Then check the new import. It it was OK you can delete the previous event with the "missing" photos.
    OT

  • I sent iTunes to trash. I was able to recover the program but have to "put back" songs one at a time. Is there any way to put back from trash using the "select all" command?

    I sent iTues to trash by mistake (trying to delete files from "yesterday"). I got the program back but have to "put back" songs one at a time. Is there a way to put back multiple songs using the "select all" command or anything else? Thanks for the help.

    The prgram is in one location and the library (media + library files) are in another. Sending it all to the trash would take some pretty delibrate multiple actions and digging through multiple folders, so I don't know how this was managed unless there's something in Snow Leopard that's new. Occasionally I have moved a file to the trash in Finder that I didn't want to and I can use Finder's "undo" to undo the last move. With many files...?

  • Since upgrading to Mavericks, my Canon MP980 printer no longer works. I've tried deleting the printer and adding it again. the process ends with my mac saying the software is not currently available from the software update server.

    Since upgrading to Mavericks, my Canon MP980 printer no longer works. I've tried deleting the printer and adding it again. I've downloaded the driver software from Canon. My Mac dropbox tells me "the selected printer software is available from Apple", but when I click to download it, the process ends with my mac saying the software is not currently available from the software update server.

    Open Finder and click on Go > Go to Folder. Then type
    /Library/Printers/Canon
    and press Enter. This will show the BJPrinter and iJScanner folders. You could try moving or trashing this folder and then installing the driver that you downloaded from Canon again.

  • "The selected topic is currently unavailable"

    Why do I always get the following message when using Help in iPhoto, when in fact I am connected to the internet.
    The selected topic is currently unavailable.
    To see all iPhoto Help, you must be connected to the Internet.

    I get it all the time - my mac mini came pre installed with mountain lion and it's never worked- i've tried everything - and now i've given up.
    Tbh you can get better help from the forums on the net and various help pages over the net
    Maybe they should just forget the help viewer thing entirely ?

  • When trying to download Boot Camp Windows Support Software, error says: "Can't install the software because it is not currently available from the Software Update server."

    I use a Macbook Pro 13" mid 2010 on Mavericks and I've tried using the Boot Camp assistant to download support software for Windows 7. This gives the error "Can't install the software because it is not currently available from the Software Update server."
    Further, I tried to separately download Boot Camp 4 and 5. When I do this and try to install from Windows 7, it says that this version of Boot Camp is not for this computer and doesn't install. The result is that I have Windows 7 working and installed, but am unable to use the trackpad to rightclick, brightness settings, etc.
    Please help!
    Thanks

    You need to run Bootcamp Assistant and select only the menu item to download the Windows Support Software. Follow the instructions. The download servers are extremely slow therefore it may take several hours to get the download.

  • I receive the following message under Boot Camp Assistant: "Can't install the software because it is not currently available from the Software Update server.

    I am trying to install the software drivers for Windows 7 Home using Boot Camp 4 Assistant. I receive the following message: "Can't install software because it is not currently available from the Software Update server." Why is this happening?

    You keep it on the usb stick for after you boot into Windows. From Windows you install the Windows Support software on the stick. Do you realize that you need to buy and install Windows? The Windows Support software you downloaded is only the Windows drivers for your hardware.
    Read the Boot Camp installation instructions and help guides located here: http://www.apple.com/support/bootcamp/

Maybe you are looking for