Hello! Does anyone know how to change the code below from "Object Style 1" to the currently selected object style that's selected? So that I don't need to input the style name, but click on the object and it'll find the other objects that have the same object style applied.
app.findObjectPreferences.appliedObjectStyles = app.selection.appliedObjectStyle.name;
Thank you a ton!!
this trick not work for Object Style inside Group? I tried to modfiy it and make some reseach but no success, something like that came to my imagination (not work) :
var myOSGStyle = app.selection.parent.constructor.name == "ObjectStyleGroup" app.findObjectPreferences.appliedObjectStyles = myOSGStyle.appliedObjectStyle.name;
So this is not work, but maybe you have another experince with this problem, and thanks in advance
Try the following
app.findObjectPreferences.appliedObjectStyles = app.selection.appliedObjectStyle
It's not strange, you need to be a bit more thoughtful while reading the API definition. appliedObjecStyle can take argument in the form of a string or object I suppose. So if the name is giving you pains which makes sense due to it being inside a group then you can use the style object and that should work, if you have a valid object it does not matter where it resides in the panel. Just a bit of informed guess I would say.