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

How to change the default Object Style

Participant ,
Aug 23, 2023 Aug 23, 2023

Hi everyone,

I Should change default Object Style and I found out these methods, but How should I behave in these cases where nothing is documented?

It's really difficult to have a good workflow when I encounter these commands which are not documented, so I have to try and try, also every time I encounter IPMUnknown interfaces I don't know how to behave, should they be left empty? do they have to be filled? I have no idea without some documentation.

I would need some tips from someone with a lot of experience to know how to behave in these situations, because I'm always reduced to asking the community slowing down my workflow considerably.

 

Anyway, back to changing the default object style, I've tried these methods:

1) Using kChangeDefaultTFObjStyleCmdBoss

Schermata 2023-08-23 alle 12.01.13.png

 

InterfacePtr<ICommand> changeDefaultTFObjStyleCmd(CmdUtils::CreateCommand(kChangeDefaultTFObjStyleCmdBoss));
if(!changeDefaultTFObjStyleCmd)
  break;
            
InterfacePtr<IUIDData> UIDData(changeDefaultTFObjStyleCmd, UseDefaultIID());
if(!UIDData)
  break;
UIDData->Set(DATABASE, UIDStyle);
            
if(CmdUtils::ProcessCommand(changeDefaultTFObjStyleCmd) != kSuccess) // Thread 1: EXC_BAD_ACCESS (code=1, address=0x0)
  break;

 

 

2) Using kApplyObjStyleToDefaultsCmdBoss

Schermata 2023-08-23 alle 10.58.53.png

 

InterfacePtr<ICommand> applyObjStyleToDefaultsCmd(CmdUtils::CreateCommand(kApplyObjStyleToDefaultsCmdBoss));
if(!applyObjStyleToDefaultsCmd)
  break;

InterfacePtr<IUIDData> UIDData(applyObjStyleToDefaultsCmd, UseDefaultIID());
if(!UIDData)
  break;
UIDData->Set(DATABASE, UIDStyle);

if(CmdUtils::ProcessCommand(applyObjStyleToDefaultsCmd) != kSuccess) // Thread 1: EXC_BAD_ACCESS (code=1, address=0x0)
  break;

 

 

3) Using IStyleGroupManager::Set______()

Schermata 2023-08-23 alle 12.44.18.png

 

InterfacePtr<IStyleGroupManager> styleGroupManager(DOCUMENT->GetDocWorkSpace(), IID_IOBJECTSTYLEGROUPMANAGER);
if(!styleGroupManager)
  break;

styleGroupManager->SetDefaultStyleUID(UIDStyle);
styleGroupManager->SetDefaultTextStyleUID(UIDStyle);
styleGroupManager->SetDefaultFrameGridStyleUID(UIDStyle);

 

But when I try to create new text frame apply [None] anyway, so I think that I sholud usekChangeDefaultTFObjStyleCmdBoss or kApplyObjStyleToDefaultsCmdBoss

 

Stefano

TOPICS
How to , SDK
941
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
Community Expert ,
Aug 23, 2023 Aug 23, 2023

I discovered how to do this after a long search not so long ago, but I've forgotten it. I was looking for (and eventually found) the equivalent of 

app.documents[0].textDefaults.appliedParagraphStyle = ...

to set a new default paragraph style.

 

Something similar to set a default object and/or graphic style exists, and because it's nowhere near where you expect it, it's not easy to find.

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
Community Expert ,
Aug 23, 2023 Aug 23, 2023

And then I remembered:

app.activeDocument.pageItemDefaults.appliedTextObjectStyle = (object style)

app.activeDocument.pageItemDefaults.appliedGraphicObjectStyle = (object style)
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
Community Expert ,
Aug 24, 2023 Aug 24, 2023

@Peter Kahrel does this actually work for graphic frames? Since day one I've found manually setting a default style for graphic frames is irrelevant (at least for drawn frames). Regardless of what is set as the default, as soon as the frame is drawn it recverts to [None].

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
LEGEND ,
Aug 24, 2023 Aug 24, 2023

Someone on another thread shown a screenshot where you can set default ObjectStyle - will try to find it. 

 

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
LEGEND ,
Aug 24, 2023 Aug 24, 2023

In fact it's in the Adobe help:

 

https://helpx.adobe.com/uk/indesign/using/object-styles.html#:~:text=To%20change%20the%20default%20s...

 

But it's not possible for placeholder frames. 

 

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
Community Expert ,
Aug 24, 2023 Aug 24, 2023

Not quite sure what you're saying here Robert. In my experience the help file is wrong regarding default object styles for graphics frames, and it doesnt seem to matter if you draw the frame before placing, or if the frame is drawn by InDesign as you place.

You can set anything you like, that part works -- the panel says it's the new default. It's just irrelevant since the frame will revert to [None] as soon as it is drawn.

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
LEGEND ,
Aug 24, 2023 Aug 24, 2023

I'm sorry, I'm on my phone but if you say it's not working, then I won't argue. Thanks for the clarification. 

 

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
LEGEND ,
Aug 24, 2023 Aug 24, 2023

Maybe it can be fixed via "on event" script? 

 

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
Community Expert ,
Aug 24, 2023 Aug 24, 2023

You're right, @Peter Spier, it doesn't work for graphic frames.

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
Community Expert ,
Aug 24, 2023 Aug 24, 2023

My presumption here is that this is some leftover hard code from version 1 that was overlooked when object styles were invented and it probably wouldn't be that hard to fix if the team actually took the time to do it.

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
Community Expert ,
Aug 23, 2023 Aug 23, 2023

Hi @Stefano5C37,

There isn't much we an do if we have undocumented IPMUnkown interfaces, we don't have the header files included for the interface hence we can't possibly use it. In your case did you trace the process by doing the process manually and then checking the commands InDesign fires and the interfaces it shows in the trace. I suppose you are thinking on the same lines as I see your post that asked to how do this manually.

-Manan

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
Community Expert ,
Aug 24, 2023 Aug 24, 2023

so @Stefano5C37 seems to have the same experience I do. I'd love to find out I'm wrong, but I've seen this over every version since object styles were introduced, over multiple installs on multiple machines, through new prefs and anything else you can think of.

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
Mentor ,
Aug 25, 2023 Aug 25, 2023
LATEST

Unfortunately this generated documentation is very incomplete. The debug build already shows some more information. E.g. many interface IDs are just to have a minimum comment, or to allow duplicate use of the same interface. The backing implementation ID is one way to tell more, and you can even look up its name. This information is available e.g. from IObjectModel, IClassInfo. Likely the debug build even has some deeply nested submenu to output all of them as text, I don't know because I use my own that also includes the data from the interfaces, as far I have covered them over the years.

 

Let's have a look at that kChangeDefaultTFObjStyleCmdBoss :

IID_IAPPLYATTRS_DATA : kBoolDataImpl, IID_IAPPLYDEFAULTFRAMEGRIDCMD : kFalseInitBoolDataImpl are IBoolData.  IID_IDISPLAYUIDATA is not so obvious, but another IBoolData. Not sure where I found out about that a decade ago. IID_ICLEAROVERRIDECATEGORIES_DATA : kObjStylesAttrCategoriesListImpl , so that would be an IID_IOBJSTYLESATTRCATEGORIESLIST => IObjStylesAttrCategoriesList.

Of course that IID_IPMUNKNOWNDATA points to another boss, now – the first time that I looked at this – that would be an kObjectStylesTargetBoss which I don't remember having come across. Pretty similar interfaces to an object style itself, but that's where I'd also burn a few hours to see what they all mean, especially in this context, how to prefill them etc.

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