FILENAME attribute extension filter
-
hello,
I have a resource file containing a FILENAME attribute.
I want it to be able to select only files of a specific extension.
Usually I configure custom GUI attributes in GetDDescription, but I don't find anything in customgui_filename.h to set the extension.Is it possible? How?
-
Hello,
a FILENAME parameter has no options to set a suffix.
If you want to only select files of a specific type you could implement SetDParameter() to check if the given Filename is acceptable.
best wishes,
Sebastian -
@s_bach Hi Sebastian,
How exactly can I reject the file selected by the user?
This is what I tried, I can see the message dialog when the user selects an unexpected file, but the value is always set, independent if I return true, false, or unset the flags.Bool AnimationModifier::SetDParameter( GeListNode* node, const DescID& id, const GeData& t_data, DESCFLAGS_SET& flags ) { auto paramId = id[0].id; if ( paramId == anm_FilePathAttribute ) { auto suffix = t_data.GetFilename().GetSuffix().ToLower(); if ( suffix != "abc"_s ) { MessageDialog( "Select an Alembic file with extension .abc"_s ); //flags &= ~DESCFLAGS_SET_PARAM_SET; //return true; return false; } } return SUPER::SetDParameter( node, id, t_data, flags ); }
-
Hello,
you could try to write an empty value into the BaseContainer when the suffix is wrong. Something like this:
case EXAMPLE_FILENAME_PARAM: { const maxon::String suffix = t_data.GetFilename().GetSuffix().ToLower(); if (suffix != "abc"_s) { BaseContainer& bc = static_cast<BaseList2D*>(node)->GetDataInstanceRef(); bc.SetFilename(EXAMPLE_FILENAME_PARAM, Filename()); flags |= DESCFLAGS_SET::PARAM_SET; return true; } }
Please notice there is no "official" solution to this; just use what works for you.
Best wishes,
Sebastian -
@s_bach Ok, I can revert the values to the base container. That solves my issue, thanks!