Solved SDK example CommandLineRendering

I am a bit confused about the SDK example CommandLineRendering.
I compiled it ok, using R20, Windows 10 and VC++ 2017.
I can see that it is loaded / started.

Bool PluginStart()
{
	GePrint("CommandLineRendering Start in PluginStart"_s);
	return true;
}

But it looks as if it is not called.
It gets the parameters ok: Command line arguments : "-nogui" "-sdk_render" "cube.c4d"
But I get the message "Warning: Unknown arguments: -sdk_render"

So it seems as if CommandLineRendering() is not called.

Here the command I use to start.

"C:\Program Files\Maxon\CINEMA 4D R20.026\CINEMA 4D.exe" -nogui -sdk_render cube.c4d" > "C:\Program Files\Maxon\CINEMA 4D R20.026\plugins\CommandLineRendering\report.txt" 

I did not change anything in CommandLineRendering()
Here main.cpp, that I changed a bit.


#include "main.h"
#include "c4d.h"

Bool PluginStart()
{
	GePrint("CommandLineRendering Start in PluginStart"_s);
	return true;
}

void PluginEnd()
{
	//FreeGLTestObject();
	//FreeExampleSNHook();
	//FreePaintAdvanced();
}

Bool PluginMessage(Int32 id, void* data)
{
	switch (id)
	{
		case C4DPL_INIT_SYS:
		{
			if (!g_resource.Init())
				return false;		// don't start plugin without resource

			// register example datatype. This is happening at the earliest possible time
			// if (!RegisterExampleDataType())
			//  	return false;

			// serial hook example; if used must be registered before PluginStart(), best in C4DPL_INIT_SYS
			// if (!RegisterExampleSNHook()) return false;

			return true;
		}

		case C4DMSG_PRIORITY:
			// react to this message to set a plugin priority (to determine in which order plugins are initialized or loaded
			// SetPluginPriority(data, mypriority);
			return true;

		case C4DPL_BUILDMENU:
			// react to this message to dynamically enhance the menu
			// EnhanceMainMenu();
			break;

		case C4DPL_COMMANDLINEARGS:
			// sample implementation of command line rendering:
			// CommandLineRendering((C4DPL_CommandLineArgs*)data);

			// react to this message to react to command line arguments on startup
			/*
			{
				C4DPL_CommandLineArgs *args = (C4DPL_CommandLineArgs*)data;
				Int32 i;

				for (i = 0; i<args->argc; i++)
				{
					if (!args->argv[i]) continue;

					if (!strcmp(args->argv[i],"--help") || !strcmp(args->argv[i],"-help"))
					{
						// do not clear the entry so that other plugins can make their output!!!
						ApplicationOutput("\x01-SDK is here :-)");
					}
					else if (!strcmp(args->argv[i],"-SDK"))
					{
						args->argv[i] = nullptr;
						ApplicationOutput("\x01-SDK executed:-)");
					}
					else if (!strcmp(args->argv[i],"-plugincrash"))
					{
						args->argv[i] = nullptr;
						*((Int32*)0) = 1234;
					}
				}
			}
			*/
			break;

		case C4DPL_EDITIMAGE:
			/*{
				C4DPL_EditImage *editimage = (C4DPL_EditImage*)data;
				if (!data) break;
				if (editimage->return_processed) break;
				ApplicationOutput("C4DSDK - Edit Image Hook: "+editimage->imagefn->GetString());
				// editimage->return_processed = true; if image was processed
			}*/
			return false;
	}

	return false;
}

The plugin, is it a real plugin(?), is also not registered?

Hi @pim thanks for reaching out us.

With regard to your request, well just having the "special" command-line args recognized is as easy as uncommenting this line.

It's indeed a working plugin and it should not be registered since it's not a plugin but rather a behavior defined when a C4DPL_COMMANDLINEARGS is intercepted.

Best, R

Ok, thank you.
I should have spotted that myself.

-Pim