Default Object: How to apply those defaults?
-
Follow-up: The behavior is the same when using the FieldList of any Effector. Adding a Field from the FieldList does not add the default object that the user has set.
So I guess it's nothing we can change. Or is there a way to load those default settings from somewhere and apply them? There must be, as the code that adds objects from the Create or the plugin's menu obviously does it
-
hi,
sorry for the delay, the default properties are stored in the Browser. you can retrieve them with GetDefaultObject. You will find more information on that page
BaseObject* myDefaultObject = static_cast<BaseObject*>(SDKBrowser::GetDefaultObject(Opyramid)); if (myDefaultObject == nullptr) myDefaultObject = BaseObject::Alloc(Opyramid); if (myDefaultObject == nullptr) return maxon::NullptrError(MAXON_SOURCE_LOCATION);
Cheers,
Manuel -
Hi,
oops, sorry, didn't see your reply earlier (I never get notification emails).
Thank you very much, that should be the solution at least for the objects I create in my code
However, I guess, there is no way to use the default object for Fields created by the
FieldList
customgui, right?Cheers,
Frank -
@fwilleke80 said in Default Object: How to apply those defaults?:
However, I guess, there is no way to use the default object for Fields created by the FieldList customgui, right?
I don't think so. But what's strange is that it does create your default field if you use the palette (icon on top).
We could maybe consider that as a bug.
I need to check the code to see why there's such a difference between the palette and the customGUI.Cheers,
Manuel -
Good to know, thank you for looking into it!
Cheers,
Frank -
@m_magalhaes said in Default Object: How to apply those defaults?:
I don't think so. But what's strange is that it does create your default field if you use the palette (icon on top).
We could maybe consider that as a bug.
I need to check the code to see why there's such a difference between the palette and the customGUI.I guess, that's because menus and palettes create the objects using menu item resource IDs like
PLUGIN_CMD_440000266
(e.g. in/resource/c4dplugin/menus/c4d_m_editor.res
), which I guess was a quick solution back when it was coded. It's a kind ofCommandData
that creates the objects, apparently invokingSDKBrowser::GetDefaultObject()
. This has probably just been forgotten in theFieldListCustomGui
.I wonder if there's a way to call that 'secret' CommandData from a plugin.
Cheers,
Frank -
hi,
those commands are created whenever you register a plugin/tools etc.
after having a look at it, i confirm it's a bug, the object is allocated without checking for the content browser.
if it's in your objectData, you could maybe listen to the message
MSG_DOCUMENTINFO_TYPE_OBJECT_INSERT
, check if it's a field object and check if it's the default one or the browser one. Than replace according to what you want.
I didn't tested it myself but it could work.But that's maybe too mush work for a "detail"
Cheers,
Manuel -
Oh, that is actually a good idea, thank you!
I'll try that!Cheers,
Frank -
@m_magalhaes said in Default Object: How to apply those defaults?:
MSG_DOCUMENTINFO_TYPE_OBJECT_INSERT
Sadly, it seems that
MSG_DOCUMENTINFO
is not sent when adding a Field via theFieldList
CustomGui. I had been hoping that message would be triggered byBaseDocument::InsertObject()
andGeListNode::InsertUnder()
(and related functions).
I guess, we have to do without default objects in this caseCheers,
Frank -
well sorry for the misleading.
I was thinking it should work because the object is inserted withdoc->InsertObject
Cheers,
Manuel