Checking If In Preferences Dialog

On 21/02/2018 at 00:48, xxxxxxxx wrote:

User Information:
Cinema 4D Version:   R18 
Platform:   Windows  ;   
Language(s) :     C++  ;

Hi all,

I'm currently developing a plugin for opening SMD files in Cinema 4D. The plugin allows the loading of either SMD or QC files, these are related files, a QC file can point to a number of SMD files, and an SMD can point to a QC (for texture lookup and other tasks).

The problem I've run into is I have an option in my Description Resource for using the QC file, if I load a QC file I want to set the Use QC option to enabled and lock it. My code will check if it is a QC file and then set a member bool m_qc_file to true if it is, however if the user then cancels the load dialog, and without restarting c4d tries to change the defaults via the preferences window they will find that the qc option is locked.

So, what I'm trying to do is change the enabling based on what window the user is currently in (how they accessed the description).

Bool SMDLoader::Init(GeListNode *node)
		// Member variable declarations
		m_qc_file = false;
		return true;
	Bool SMDLoader::Identify(BaseSceneLoader* node, const Filename& name, UChar* probe, Int32 size)
		// unfortunately SMD/QC is an ascii format so we will just assume
		// that the file-type is SMD/QC based on the extension alone.
		if (name.GetSuffix().ToLower() == "qc")
			m_qc_file = true;
			return true;
		return name.GetSuffix().ToLower() == "smd" ? true : false;
Bool SMDLoader::GetDEnabling(GeListNode *node, const DescID &id, const GeData &t_data, DESCFLAGS_ENABLE flags, const BaseContainer *itemdesc)
		if (!node)
			return false;
		switch (id[0].id)
			case SMD_IMPORT_QC:
				if (m_qc_file)
					return false;
					return true;
		// call parent
		return SceneLoaderData::GetDEnabling(node, id, t_data, flags, itemdesc);

Thank-you for any and all help !

On 21/02/2018 at 02:44, xxxxxxxx wrote:


welcome to the Plugin Café forums :slightly_smiling_face:

I'm not saying, I understand your issue completely. So, please bare with me, if my answer misses the actual point.

I'm wondering, why you need to store two different information in one boolean member variable (file type and lock state)? Wouldn't it be sufficient in your case to simply set the lock state only after successful import of the file, instead of doing it in Identify()?

On 21/02/2018 at 02:52, xxxxxxxx wrote:

I am only storing the one piece of information (whether or not the identified file is a QC file or not).
I need to set that during the identify so that the resulting window that opens during import shows the QC file as being used.

Maybe these pictures will clear it up:

User Opens an SMD File

User Opens a QC File (this is how I want it)

User cancels out of the previous menu and goes to preferences
(this is where this issue lies)

On 21/02/2018 at 05:09, xxxxxxxx wrote:

Sorry, to insist, from point of view, you are still storing two information in one boolean member variable. The file type (which needs to be stored during identify, I understand) and the locking of the preferences option, which should only be set after successful import.
Wouldn't it work, if you had two bools (m_qc_file and m_lock_prefs), set the first in Identify() and the latter after successful import in Load(). Disabling any preferences options would depend only on the later or maybe a certain combination of the two.

On 21/02/2018 at 05:32, xxxxxxxx wrote:

Oh, okay I think I see where the misunderstanding is from.

So, an SMD file has a QC file associated with it, I have an option (Use QC) that asks if the user wants to use the QC file instead of the SMD file. The QC file will point to multiple SMD files to import. So for instance the SMD may contain a character model, but the QC file for that SMD will also point to shared models (such as a helmet all character models wear).

I want users to have the option when importing a SMD to use the QC file instead, but when a user is importing a QC file directly, this option should be disabled since you're already selecting the QC file. The problem is that this lock setting cannot be reverted after being set by identify if the user cancels the dialog. Causing the option to lock in the preferences menu.

At no point do I want the Use QC option locked in preferences, I want it to always be unlocked there, but I want it to lock if the user loads a QC file.

Hopefully that clears things up.

On 22/02/2018 at 03:00, xxxxxxxx wrote:

Ah, ok, now I got it. Thanks for the explanation. Sorry, sometimes the penny needs some time to drop.

Unfortunately I'm out of good ideas. 
A quite horrible approach could be to use a timer (see MessageData) to reset the flag. But that's so ugly I'd probably rather go without disabling the parameter.

On 23/02/2018 at 17:22, xxxxxxxx wrote:

Hmmm, yeah that would be an ugly solution no doubt. Well I'll leave it as is right now and post here if I find a solution :-) Thanks for the help irregardless :)