Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    FILENAME attribute extension filter

    Cinema 4D SDK
    c++
    2
    5
    1.1k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • rsodreR
      rsodre
      last edited by

      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?

      1 Reply Last reply Reply Quote 0
      • S
        s_bach
        last edited by

        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

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

        rsodreR 1 Reply Last reply Reply Quote 3
        • rsodreR
          rsodre @s_bach
          last edited by

          @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 );
          }
          
          1 Reply Last reply Reply Quote 0
          • S
            s_bach
            last edited by

            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

            MAXON SDK Specialist

            Development Blog, MAXON Registered Developer

            rsodreR 1 Reply Last reply Reply Quote 0
            • rsodreR
              rsodre @s_bach
              last edited by

              @s_bach Ok, I can revert the values to the base container. That solves my issue, thanks!

              1 Reply Last reply Reply Quote 0
              • First post
                Last post