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

Placing Group Library Assets

Enthusiast ,
Aug 12, 2013 Aug 12, 2013

Hi All,

Facing issues while placing grouped library assets in the active document.

No issues while placing assets as a single text frame.

Code is below:

var myDoc = app.activeDocument;

var myLib = app.libraries[0];

app.findTextPreferences = app.changeTextPreferences = null;

app.findTextPreferences.appliedParagraphStyle = "tx"

var myFound = myDoc.findText()

for(k=myFound.length-1; k>-1; k--)

{

    var myAnno = myFound.texts[0]

    var myPlaceAsset = myLib.assets.item("aaa").placeAsset(myFound.insertionPoints[-1])[0];

    myAnno.move(LocationOptions.AT_END, myPlaceAsset);             //I think Problem here only

    myPlaceAsset.appliedObjectStyle = myDoc.objectStyles.item("bbb")

    }

Please find the screenshot for your more reference.

group_Lib_assets.png

Could anyone please help me for the group library assets.

Thanks in advance

Beginner

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

Mentor , Aug 12, 2013 Aug 12, 2013

Hi,

In case of placing a group your code is trying to move some text - without container - into the group ==> so it fails

Try to modify the code including additional variable mRef as a move reference parameter, so:

...

var mRef = myPlaceAsset;

if (mRef.textFrames.length >0)

     mRef = mRef.textFrames[0];

myAnno.move(LocationOptions.AT_END, mRef);

...

Jarek

Translate
Mentor ,
Aug 12, 2013 Aug 12, 2013

Hi,

In case of placing a group your code is trying to move some text - without container - into the group ==> so it fails

Try to modify the code including additional variable mRef as a move reference parameter, so:

...

var mRef = myPlaceAsset;

if (mRef.textFrames.length >0)

     mRef = mRef.textFrames[0];

myAnno.move(LocationOptions.AT_END, mRef);

...

Jarek

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 ,
Aug 16, 2013 Aug 16, 2013

Hi Jump_Over,

Extremely Sorry for the late response....

Above coding working fine to cut and move the "tx" style in Marginal Notes("aaa").

But facing the new problem is,

If we apply the object style to the Marginal box, fill color properties is lost.

Could you have any solution for this.

var myDoc = app.activeDocument;

var myLib = app.libraries[0];

app.findTextPreferences = app.changeTextPreferences = null;

app.findTextPreferences.appliedParagraphStyle = "tx"

var myFound = myDoc.findText()

for(k=myFound.length-1; k>-1; k--)

{

    var myAnno = myFound.texts[0]

    var myPlaceAsset = myLib.assets.item("aaa").placeAsset(myFound.insertionPoints[-1])[0];

     var mRef = myPlaceAsset;

     mRef = mRef.textFrames[0];

    myAnno.move(LocationOptions.AT_END, mRef);

    myPlaceAsset.appliedObjectStyle = myDoc.objectStyles.item("bbb")

    }

Please find the screenshot:

Screen Shot 2013-08-16 at 3.33.19 PM.png

Thanks in advance

Beginner_X

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 ,
Aug 18, 2013 Aug 18, 2013

Hi All,

Could anyone please help for the above request.

Thanks in advance

Beginner

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 ,
Aug 18, 2013 Aug 18, 2013

Edit:

define the objectstyle for the group with option for fillcolor switched off!!! so it won't change a existing fillcolor

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 ,
Aug 18, 2013 Aug 18, 2013

Hi Jump_Over & hans,

Thanks a lot genius!!!!

Above threads are very helpful for me to find the solution.

But now I try to learn myself with different task, but cant reach the destination.

Is it possible to move the next paragraph move into the library assets

i.e.,

    var myAnno = myFound.texts[0];

//~     alert("myAnno:" + myAnno)

    var myAnno1 = myFound[k+1].texts[0];

//~     alert("myAnno1:" + myAnno1);                //Here is the problem

     var myPlaceAsset = myLib.assets.item("aaa").placeAsset(myFound.insertionPoints[-1])[0];

     var mRef = myPlaceAsset;

     mRef = mRef.textFrames[0];

     myAnno1.move(LocationOptions.AT_END, mRef);

Could anyone please help to give the solution.

Thanks

Beginner

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 ,
Aug 20, 2013 Aug 20, 2013

Hi All,

Could anyone please help for the above request.

Thanks

Beginner

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
Contributor ,
Aug 20, 2013 Aug 20, 2013

Hi Beginner,

         Try the below code.

Insert the below codes after ur codes.

app.select(app.selection[0].insertionPoints[-1]);

app.findGrepPreferences = app.changeGrepPreferences = null;

app.findGrepPreferences.findWhat = ".+";

var xxx = app.findGrep(); //var xxx = app.insertionPoints[0].findGrep();

app.select(xxx[0]);

app.cut();

app.select(mRef.insertionPoints[0]);

app.paste();

Note:

Currently, I can't able to check my code works. Becoz i'm out of city. Use, If it works. Else ignore.

Thanks and Regards,

Vel.

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 ,
Aug 22, 2013 Aug 22, 2013
LATEST

Hi Velprakash,

The above coding not help to find the solution.

Anyway thanks for your extra ordinary effort.....

Jump_Over & Hans your coding helps to find for my initial solution.

Always I thankful for you.

Thanks

Beginner_X

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