Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.
Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).
Hi,
it's nice to have the examples for CustomGuis and CustomDataTypes in the SDK in customdata_customgui.cpp. But how is it actually used? Is there any example code of how to use this in e.g. an ObjectData? You know, set data, get data, et cetera.
customdata_customgui.cpp
I know how to use CustomDataTypes in general, but what about one that's not from the API? Last time I did that was 10+ years ago, and I can't remember.
This did not work:
In the .res file:
DOTS OTEST_DOTS { }
Code in the object plugin:
iCustomDataTypeDots* dotsData = (iCustomDataTypeDots*)bc->GetCustomDataType(OTEST_DOTS, ID_SDK_EXAMPLE_CUSTOMDATATYPE_DOTS); const maxon::Int count = dotsData->_points.GetCount();
Thanks in advance!
Cheers, Frank
hi,
what is not working? including the DOTS in the resource file or the code?
I did try updating the objectdata_description plugin to make it work with this custom data example. I didn't try using "DOTS" on a .res file.
Remember that the data could not be stored inside the basecontainer. It is better to use GetParameter and SetParameter
Setting parameter can be done like this :
GeData dotData = GeData(ID_SDK_EXAMPLE_CUSTOMDATATYPE_DOTS, DEFAULTVALUE); iCustomDataTypeDots* dotDataP = (iCustomDataTypeDots*)dotData.GetCustomDataType(ID_SDK_EXAMPLE_CUSTOMDATATYPE_DOTS); if (dotDataP) { iferr (dotDataP->_points.Append(Vector(3, 1, 0))) { break; } } node->SetParameter(DescID(ID_DYNAMIC_ELEMENT + DESCRIPTIONELEMENTS::DOTDATA), dotData, DESCFLAGS_SET::NONE);
getting data is pretty simple:
const Bool success = node->GetParameter(DescID(ID_DYNAMIC_ELEMENT + DESCRIPTIONELEMENTS::DOTDATA), data, DESCFLAGS_GET::NONE); // check type if (success && data.GetType() == ID_SDK_EXAMPLE_CUSTOMDATATYPE_DOTS) { iCustomDataTypeDots* dotDataP = (iCustomDataTypeDots*)data.GetCustomDataType(ID_SDK_EXAMPLE_CUSTOMDATATYPE_DOTS); if (dotDataP) { const Int32 pointCount = dotDataP->_points.GetCount(); String result = FormatString("Number of data stored @", pointCount); node->SetParameter(DescID(ID_RESULT_TEXT), result, DESCFLAGS_SET::NONE); } }
cheers, Manuel
Hi Manuel,
ah, this works! With the code I posted, I got crashes when trying to access any members of dotDataP. I guess, that was because I didn't properly initialize it.
dotDataP
Thanks!
Hi again,
sorry for setting this to "unsolved" again.
I could not find the changes to objectdata_description you mentioned on GitHub. Therefore, I'm writing here again.
objectdata_description
I have one last remaining problem in CustomDataTypeClass::CopyData(): The call const iCustomDataTypeDots* const s = static_cast<const iCustomDataTypeDots*>(src); always returns the data I have set in my ObjectData's Init() function. For some reason, the new data is not carried over.
CustomDataTypeClass::CopyData()
const iCustomDataTypeDots* const s = static_cast<const iCustomDataTypeDots*>(src);
Init()
Are there some typical stumblestones that may lead to this problem?
I've set it back to SOLVED again.
Just a hint for anyone else who might run into a similar problem: Make sure your CustomDataTypeClass::Compare() impementation does not falsely return 0 under certain conditions.
CustomDataTypeClass::Compare()
The SDK example goes the easy route: It even says in the comments: "this just compares the number of points ... a better implementation would also compare the values of the points". What would be a good way to compare arbitrary data like the maxon::BaseArray<Vector> from the SDK example, and assign the "1" or "-1" results?
maxon::BaseArray<Vector>
Sometimes, the data isn't less or greater, sometimes it's just different.
sorry i didn't had time to investigate yesterday. I'm happy that you find out the solution.
Cheers, Manuel