Copy link to clipboard
Copied
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
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
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______()
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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
And then I remembered:
app.activeDocument.pageItemDefaults.appliedTextObjectStyle = (object style)
app.activeDocument.pageItemDefaults.appliedGraphicObjectStyle = (object style)
Copy link to clipboard
Copied
@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].
Copy link to clipboard
Copied
Someone on another thread shown a screenshot where you can set default ObjectStyle - will try to find it.
Copy link to clipboard
Copied
In fact it's in the Adobe help:
But it's not possible for placeholder frames.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Maybe it can be fixed via "on event" script?
Copy link to clipboard
Copied
You're right, @Peter Spier, it doesn't work for graphic frames.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now