Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Ungroup text frame

Explorer ,
Apr 26, 2017 Apr 26, 2017

Hello everyone,

i need to ungroup textframe inside so many groups present

first Layer1

inside layer1 Group Item is present

inside Group item AAA group present

Inside AAA group Group Item Present

inside Group Item if Textframe is present i have to place textframe before (Ungroup)

Program code:

var sourceDoc=app.activeDocument;

ungroup();

function ungroup()

{

      layer_file = sourceDoc.layers;

       for(layer_iteration=0;layer_iteration<layer_file.length;layer_iteration++)

    {

          if(layer_file[layer_iteration].name=="Layer 1")

  

    {

       

        var theGrp =layer_file[layer_iteration].groupItems;

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

               var count=0;

                  var count2=0;

    count++;

        var allGrp = 0;

   theObj = theGrp.pageItems;

        for(var k= theObj.length-1; k>=0; k--) {

                

       

  

        if (theObj.typename == "GroupItem") {

            count++;

              theObj2 = theObj.pageItems;

            for(var kk = theObj2.length-1; kk>=0; kk--) {

         

         if(theObj2[kk].typename == "GroupItem"){

             count++;

              theObj3 = theObj2[kk].pageItems;

            for(var kkk = theObj3.length-1; kkk>=0; kkk--) {

      

           if(theObj3[kkk].typename == "GroupItem"){

             count++;

              theObj4 = theObj3[kkk].pageItems;

            for(var kkkk = theObj4.length-1; kkkk>=0; kkkk--) {

                if(theObj4[kkkk].typename == "GroupItem"){

             count++;

              theObj5 = theObj4[kkkk].pageItems;

            for(var kkkkk = theObj5.length-1; kkkkk>=0; kkkkk--) {

             

              

              if ((theObj5[kkkkk].typename == 'TextFrame')){

                   theObj5[kkkkk].move(theObj4[kkkk],ElementPlacement.PLACEBEFORE); 

            

                }

           

            }}}}}}}}}}}}}

But this code not at all working for me can anybody modify it please it is urgent.

i have tried so many times.

with regards,

yogi                 

TOPICS
Scripting
728
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Community Expert ,
Apr 28, 2017 Apr 28, 2017
LATEST

Just so I'm clear, you just want to pull the text frame out of the group? There is no such thing as "ungrouping a text frame", but it appears you are talking about a group that holds a single text frame, and you need that group ungrouped?.

It's quite difficult to see what your code is doing there because the indenting is all over the place.

I'm not sure exactly what you're looking to do, but i made the assumption that there's one text frame you need to remove from it's parent group, and i assumed you're using CS6+.

I tested this code a few times and it seems to work well. This will find the text frame no matter how deep it's nested in the groups. However that "feature" will cause a problem if there is more than one text frame in the document and you only want to change one of them. Perhaps this will be a good jumping off point though.

function ungroupTextFrame()

{

    //define findTextFrame recursive function

    function findTextFrame(group)

    {

        //look for a text frame in the top level of this group

        if(group.textFrames.length == 1)

        {

            sourceDoc.selection = null;

            group.selected = true;

            app.executeMenuCommand("ungroup");

        }

        else

        {

            for(var g=0;g<group.groupItems.length;g++)

            {

                var thisInnerGroup = group.groupItems;

                findTextFrame(thisInnerGroup);

            }

        }

    }

    if(app.documents.length>0)

    {

        var sourceDoc = app.activeDocument;

        var layers = sourceDoc.layers;

        try

        {

            var theLayer = layers["Layer 1"];

            for(var x=0;x<theLayer.groupItems.length;x++)

            {

                var thisGroup = theLayer.groupItems;

                findTextFrame(thisGroup);

            }  

        }

        catch(e)

        {

            alert("Sorry. \"Layer 1\" does not exist.");

        }

    }

    else

    {

        alert("No document open!");

    }

}

ungroupTextFrame();

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines