CommandLineRendering example in SDK

On 25/05/2015 at 06:33, xxxxxxxx wrote:

User Information:
Cinema 4D Version:    
Platform:      
Language(s) :

---------
Hi
I'm just starting out with c++ (coming from Python) so bare with me 🙂
I'm trying to get the CommandLineRendering part of the SDK to work. In "main.ccp" theres a section under "PluginMessage" with code for command line rendering:

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

If i uncomment this like this, add "Bool RegisterCommandLineRendering();" to "main.h" and Build it:

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

I get theese errors:

  
Undefined symbols for architecture x86_64:   
"CommandLineRendering(C4DPL_CommandLineArgs* )", referenced from:   
      PluginMessage(int, void* ) in main.o   
ld: symbol(s) not found for architecture x86_64   
clang: error: linker command failed with exit code 1 (use -v to see invocation)   

What am i doing wrong?

Cheers
Bonsak

On 25/05/2015 at 08:22, xxxxxxxx wrote:

Hi,

Originally posted by xxxxxxxx

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

If i uncomment this like this, add "Bool RegisterCommandLineRendering();" to "main.h" and Build it:

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

You've uncommented the line

             
//void CommandLineRendering(C4DPL_CommandLineArgs* args);   

and you shouldn't. It's there in the comment to show the prototype of the function to call for the CommandLineRender example in commandlinerender.cpp.

On 25/05/2015 at 11:44, xxxxxxxx wrote:

Hm, i must be doing something else wrong because only uncommenting "CommandLineRendering((C4DPL_CommandLineArgs* )data);" in main.ccp gives the same error on compile.

Cheers
Bonsak

On 26/05/2015 at 08:19, xxxxxxxx wrote:

Hi Bonsak,

The code in the SDK for the CommandLineRendering example needs some fixes and has to be changed.
I'll try to explain the changes:

In commandlinerender.cpp remove the "#if 0" macro at the beginning and its respective "#endif" at the end of the file:

 ~~#if 0~~
  
#include "c4d.h"
#include <string.h>
#include <ctype.h>
 ~~#endif~~

In the same file change the definition of CommandLineRendering() function from

static void CommandLineRendering(C4DPL_CommandLineArgs* args)

to

void CommandLineRendering(C4DPL_CommandLineArgs* args)

Add its declaration in main.h :

Bool RegisterCustomDatatypeCustomGUI();
  
void CommandLineRendering(C4DPL_CommandLineArgs* args);
  
#endif // MAIN_H__

And include "main.h" in commandlinerender.cpp:

#include "main.h"
  
Float lastProgressValue = -1.0;
RENDERPROGRESSTYPE lastProgressType = RENDERPROGRESSTYPE_AFTERRENDERING;

The SDK example for CommandLineRendering will be fixed and updated online soon in its GitHub PluginCafe repository.

On 26/05/2015 at 10:04, xxxxxxxx wrote:

Thanks a alot! It's pretty intimidating starting out with C++ so your help is very much appreciated.
I'm still getting an error on compile after changing what you suggested:

commandlinerender.cpp:243:22: No viable conversion from 'Char *' (aka 'char *') to 'AutoGeFree<char>'

But i just commented out the whole block from here (commandlinerender.cpp) :

else if (!strcmp(args->argv[i], "-sdk_oformat"))

This compiles fine and is perfectly ok for now.

Cheers
Bonsak

On 26/05/2015 at 11:50, xxxxxxxx wrote:

In "main.h" i think it needs to be something like:

CommandLineRendering((C4DPL_CommandLineArgs* )data);

to actually call the function in "commandline.ccp" not:

void CommandLineRendering(C4DPL_CommandLineArgs* args);

as that is the same as the declaration?

Cheers
Bonsak

On 26/05/2015 at 23:49, xxxxxxxx wrote:

Originally posted by xxxxxxxx

In "main.h" i think it needs to be something like:

CommandLineRendering((C4DPL_CommandLineArgs* )data);

to actually call the function in "commandline.ccp" not:

void CommandLineRendering(C4DPL_CommandLineArgs* args);

as that is the same as the declaration?

Yes in main.cpp you can remove the line with the function prototype for  CommandLineRendering() and just keep the line calling it.

On 27/05/2015 at 00:57, xxxxxxxx wrote:

Thanks! It works fine on the command line now. But it crashes cinema when i start c4d in gui mode with commandlinerender plugin in the plugin dir. I'll investigate more.

Cheers
Bonsak