11 Replies Latest reply on Sep 7, 2015 1:06 PM by Ronald63

    object style exporting snippet naming

    hamdifem Level 1

      In my document object still text frames, I want to export as snippets

      but in the present specification in the paragraph style, but also get the name of the snippet

      I have written a code for it, but the results frustrated

       

      var myDoc = app.activeDocument; 
      for(var p=0; p<myDoc.pages.length; p++)
      {
          for(var i =0;i<myDoc.pages[p].textFrames.length;i++)  
          {
              var myFrame = myDoc.pages[p].textFrames[i];
                  app.findGrepPreferences = app.changeGrepPreferences = null;  
                  app.findGrepPreferences.findWhat = ".+";  
                  app.findGrepPreferences.appliedParagraphStyle = myParS; 
      var mySearch = myFrame[i].findGrep();
      for(j=0; j<mySearch.length; j++)  
      {
              if(myFrame.appliedObjectStyle == tmc) {
                  myFrame.exportFile(ExportFormat.INDESIGN_SNIPPET, File("d:\\Yeni\\"+  mySearch[j] + ".idms"));
      }
      }
      }
      }
      
      
      
        • 1. Re: object style exporting snippet naming
          Ronald63 Level 4

          Hi,

           

          I don't really understand what you want to do. Could you specify ?


          Regards

          • 2. Re: object style exporting snippet naming
            hamdifem Level 1

            "tmc" has named object style

            This style has a paragraph style applied to text frame in (myPars)

            I want to make snippets s TMC

            but snippet is name myPars text value

            Başlıksız-1.jpg

            • 3. Re: object style exporting snippet naming
              Ronald63 Level 4

              I'm not sure that's what you want to do ...

               

              var myDoc = app.activeDocument;   
              for(var p=0; p<myDoc.pages.length; p++){  
                  for(var i =0;i<myDoc.pages[p].textFrames.length;i++){  
                      var myFrame = myDoc.pages[p].textFrames[i];  
                      app.findGrepPreferences = app.changeGrepPreferences = null;    
                      app.findGrepPreferences.findWhat = ".+";    
                      app.findGrepPreferences.appliedParagraphStyle = 'foo';   
                      var mySearch = myFrame.findGrep();  
                      for(j=0; j<mySearch.length; j++){  
                          if(myFrame.appliedObjectStyle.name == 'tmc') {  
                              myFrame.exportFile(ExportFormat.INDESIGN_SNIPPET, File("~/Desktop/"+  'tmc' + ".idms"));  
                          }  
                      }  
                  }  
              } 
              


              • 4. Re: object style exporting snippet naming
                hamdifem Level 1

                How can I explain more

                Başlıksız-3.jpg

                • 5. Re: object style exporting snippet naming
                  Ronald63 Level 4

                  Try this

                   

                  for(var p=0; p<myDoc.pages.length; p++){  
                      for(var i =0;i<myDoc.pages[p].textFrames.length;i++){  
                          var myFrame = myDoc.pages[p].textFrames[i];  
                          app.findGrepPreferences = app.changeGrepPreferences = null;    
                          app.findGrepPreferences.findWhat = ".+";    
                          app.findGrepPreferences.appliedParagraphStyle = 'myPars';   
                          var mySearch = myFrame.findGrep();  
                          for(j=0; j<mySearch.length; j++){  
                              if(myFrame.appliedObjectStyle.name == 'tmc') {  
                                  myFrame.exportFile(ExportFormat.INDESIGN_SNIPPET, File("~/Desktop/"+  mySearch[j].contents + ".idms"));  
                              }  
                          }  
                      }  
                  } 
                  
                  • 6. Re: object style exporting snippet naming
                    hamdifem Level 1

                    thanks

                    if the group I can not name in

                    How to make a snippet

                     

                    var myDoc = app.activeDocument;
                    var myGrup = myDoc.groups.everyItem();
                    var myGframe = myGrup.textFrames[0];
                    if(myGframe.appliedObjectStyle =="tmc"){
                                app.findGrepPreferences = app.changeGrepPreferences = null;      
                                app.findGrepPreferences.findWhat = "\\d{4}";
                                app.findGrepPreferences.appliedParagraphStyle = "myParS";
                                var mySearch = myGframe.findGrep();
                                    myGrup.exportFile(ExportFormat.INDESIGN_SNIPPET, File("D:\\Yeni\\"+  mySearch.contents + ".idms")); 
                    }
                    
                    • 7. Re: object style exporting snippet naming
                      Ronald63 Level 4

                      Hope this help you

                      var myDoc = app.activeDocument;  
                      var myItems= myDoc.allPageItems;
                      
                      var J = myItems.length;
                      
                      while( J-- ){
                          var mItem = myItems[J];
                          if (mItem.constructor instanceof TextFrame) {
                              if(mItem.appliedObjectStyle.name =="tmc"){  
                                  app.findGrepPreferences = app.changeGrepPreferences = null;        
                                  app.findGrepPreferences.findWhat = "\\d{4}";  
                                  app.findGrepPreferences.appliedParagraphStyle = "myParS";  
                                  var mySearch = mItem.findGrep();
                                  if (mySearch.length ==1){
                                      if (mItem.parent instanceof Group){
                                          mItem.parent.exportFile(ExportFormat.INDESIGN_SNIPPET, File("~/Desktop/"+  mySearch[0].contents + ".idms"));
                                      }else{
                                          mItem.exportFile(ExportFormat.INDESIGN_SNIPPET, File("~/Desktop/"+  mySearch[0].contents + ".idms"));
                                      }
                                  }
                              } 
                          }
                      }
                      
                      • 8. Re: object style exporting snippet naming
                        hamdifem Level 1

                        For this code in paragraph style

                        for example

                         

                        19     FIZ     E     3854                                 (.appliedParagraphStyle = "myParS")

                         

                        How can we get only 4-digit numbers

                        .replace(/(\d+)(\t.+?\t)(.+?\t)(\d+)/g, '$4');

                        where I could not find how to write

                        • 9. Re: object style exporting snippet naming
                          Ronald63 Level 4

                          The above code also works in this case ...


                                      app.findGrepPreferences.findWhat = "\\d{4}";    
                                      app.findGrepPreferences.appliedParagraphStyle = "myParS"; 
                          
                          
                          • 10. Re: object style exporting snippet naming
                            hamdifem Level 1

                            yes but my list which can be

                            12     FIZ    A     651531

                            13     FIZ    B     12358743

                            14     FIZ    E     84435

                             

                            I will take them through how

                             

                            651531

                            12358743

                            84435

                            • 11. Re: object style exporting snippet naming
                              Ronald63 Level 4

                              Try with this ...

                              var myDoc = app.activeDocument;    
                              var myItems= myDoc.allPageItems;  
                                
                              var J = myItems.length;  
                                
                              while( J-- ){  
                                  var mItem = myItems[J];  
                                  if (mItem.constructor instanceof TextFrame) {  
                                      if(mItem.appliedObjectStyle.name =="tmc"){    
                                          app.findGrepPreferences = app.changeGrepPreferences = null;          
                                          //app.findGrepPreferences.findWhat = "\\d{4}";
                                          app.findGrepPreferences.findWhat = "\\d+$";    
                                          app.findGrepPreferences.appliedParagraphStyle = "myParS";    
                                          var mySearch = mItem.findGrep();  
                                          if (mySearch.length ==1){ 
                                              if (mItem.parent instanceof Group){  
                                                  mItem.parent.exportFile(ExportFormat.INDESIGN_SNIPPET, File("~/Desktop/"+  mySearch[0].contents + ".idms"));  
                                              }else{  
                                                  mItem.exportFile(ExportFormat.INDESIGN_SNIPPET, File("~/Desktop/"+  mySearch[0].contents + ".idms"));  
                                              }  
                                          }  
                                      }   
                                  }  
                              }