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

[Script] Cannot set an object style as a default frame style if this style is inside a folder

New Here ,
Jul 11, 2022 Jul 11, 2022

Copy link to clipboard

Copied

I have a simple script:

 

var doc = app.activeDocument;

var myStyle = doc.objectStyleGroups.itemByName('My Group1').objectStyles.itemByName('My Style1');

doc.pageItemDefaults.appliedTextObjectStyle = myStyle;

 

I'd like to set "My Style1" as a default text frame style. But when this style is inside a folder - I get this error:

Invalid value for set property 'appliedTextObjectStyle'. Expected ObjectStyle or String, but received ObjectStyle

 

The following piece of code - where target style is at the first level, outside folders - works fine:

var doc = app.activeDocument;
var myStyle = doc.objectStyles.itemByName('2 Columns');
doc.pageItemDefaults.appliedTextObjectStyle = myStyle;

 

Does anyone know how I can set a style from the folder as a default text/graphic frame style ?

 

Screen Shot 2022-07-11 at 22.34.12.png

TOPICS
Bug , How to , Scripting

Views

634

Translate

Translate

Report

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 2 Correct answers

Guru , Jul 12, 2022 Jul 12, 2022

The same here in Indy 15.0.3 and 17.2.1, Win 10.

Definitely a bug!

Votes

Translate

Translate
Community Expert , Jul 12, 2022 Jul 12, 2022

Hi together,

I can re-create the issue as well on my German InDesign 2022 on Windows 10.

Tried it with the doc.allObjectStyles array. This failed when the object style was nested in an object style group and is clearly working when the object style is in the root of the Object Styles panel.

 

The workaround would be:

[1] Move the style to the root.

[2] Apply it to the pageItemDefaults

[3] Move it back to the group

 

if( myStyle.parent.constructor.name != "Document" )
{
	var objStyleGroup = mySty
...

Votes

Translate

Translate
Community Expert ,
Jul 11, 2022 Jul 11, 2022

Copy link to clipboard

Copied

Hmm, seems like a bug. I was able to re-create on my Windows 11 running ID 17.3. I'll let others weigh in; I haven't worked much with doc.pageItemDefaults so maybe there's a gotcha there. 

Votes

Translate

Translate

Report

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
Guru ,
Jul 12, 2022 Jul 12, 2022

Copy link to clipboard

Copied

The same here in Indy 15.0.3 and 17.2.1, Win 10.

Definitely a bug!

Votes

Translate

Translate

Report

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
Community Expert ,
Jul 12, 2022 Jul 12, 2022

Copy link to clipboard

Copied

Hi together,

I can re-create the issue as well on my German InDesign 2022 on Windows 10.

Tried it with the doc.allObjectStyles array. This failed when the object style was nested in an object style group and is clearly working when the object style is in the root of the Object Styles panel.

 

The workaround would be:

[1] Move the style to the root.

[2] Apply it to the pageItemDefaults

[3] Move it back to the group

 

if( myStyle.parent.constructor.name != "Document" )
{
	var objStyleGroup = myStyle.parent;
	myStyle.move( LocationOptions.AT_END , doc );
	doc.pageItemDefaults.appliedTextObjectStyle = myStyle;
	myStyle.move( LocationOptions.AT_END , objStyleGroup );
}
else
{
	doc.pageItemDefaults.appliedTextObjectStyle = myStyle;
};

 

Note: You need perhaps another check for the name of the object style, because there could be a style in the root with the same name.

 

Regards,
Uwe Laubender
( Adobe Community Professional )

Votes

Translate

Translate

Report

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
New Here ,
Jul 12, 2022 Jul 12, 2022

Copy link to clipboard

Copied

Hi @Laubender

Thanks a lot! It works and solves my problem.

Votes

Translate

Translate

Report

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
Community Expert ,
Jul 12, 2022 Jul 12, 2022

Copy link to clipboard

Copied

Another note:
I can see the issue already with InDesign CS6 version 8.1 on Windows 10.

 

Regards,
Uwe Laubender
( Adobe Community Professional )

Votes

Translate

Translate

Report

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
Community Expert ,
Jul 12, 2022 Jul 12, 2022

Copy link to clipboard

Copied

I have submitted the bug to InDesign User Voice: https://indesign.uservoice.com/forums/601180-adobe-indesign-bugs/suggestions/45417503-object-styles-...

 

Please vote to increase visibility. 

Votes

Translate

Translate

Report

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
Community Expert ,
Jul 12, 2022 Jul 12, 2022

Copy link to clipboard

Copied

LATEST

Hi Brian,

thank you very much. I voted for fixing the bug.

 

Regards,
Uwe Laubender
( Adobe Community Professional )

 

Votes

Translate

Translate

Report

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