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

object style exporting snippet naming

Participant ,
Sep 02, 2015 Sep 02, 2015

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

.textFrames.length;i++) 

    {

        var myFrame = myDoc.pages

.textFrames;

            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 == tmc) {

            myFrame.exportFile(ExportFormat.INDESIGN_SNIPPET, File("d:\\Yeni\\"+  mySearch + ".idms"));

}

}

}

}

TOPICS
Scripting
1.3K
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

correct answers 1 Correct answer

Enthusiast , Sep 03, 2015 Sep 03, 2015

Hope this help you

var myDoc = app.activeDocument; 

var myItems= myDoc.allPageItems;

var J = myItems.length;

while( J-- ){

    var mItem = myItems;

    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.fi

...
Translate
Enthusiast ,
Sep 02, 2015 Sep 02, 2015

Hi,

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


Regards

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
Participant ,
Sep 02, 2015 Sep 02, 2015

"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

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
Enthusiast ,
Sep 02, 2015 Sep 02, 2015

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

.textFrames.length;i++){ 

        var myFrame = myDoc.pages

.textFrames

        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")); 

            } 

        } 

    } 

}


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
Participant ,
Sep 02, 2015 Sep 02, 2015

How can I explain more

Başlıksız-3.jpg

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
Enthusiast ,
Sep 02, 2015 Sep 02, 2015

Try this

for(var p=0; p<myDoc.pages.length; p++){ 

    for(var i =0;i<myDoc.pages

.textFrames.length;i++){ 

        var myFrame = myDoc.pages

.textFrames

        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.contents + ".idms")); 

            } 

        } 

    } 

}

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
Participant ,
Sep 02, 2015 Sep 02, 2015

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"));

}

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
Enthusiast ,
Sep 03, 2015 Sep 03, 2015

Hope this help you

var myDoc = app.activeDocument; 

var myItems= myDoc.allPageItems;

var J = myItems.length;

while( J-- ){

    var mItem = myItems;

    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"));

                }

            }

        }

    }

}

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
Participant ,
Sep 07, 2015 Sep 07, 2015

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

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
Enthusiast ,
Sep 07, 2015 Sep 07, 2015

The above code also works in this case ...


  1.             app.findGrepPreferences.findWhat = "\\d{4}";   
  2.             app.findGrepPreferences.appliedParagraphStyle = "myParS";
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
Participant ,
Sep 07, 2015 Sep 07, 2015

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

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
Enthusiast ,
Sep 07, 2015 Sep 07, 2015
LATEST

Try with this ...

var myDoc = app.activeDocument;   

var myItems= myDoc.allPageItems; 

 

var J = myItems.length; 

 

while( J-- ){ 

    var mItem = myItems

    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")); 

                } 

            } 

        }  

    } 

}

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