THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 03/03/2009 at 13:53, xxxxxxxx wrote:
Cinema 4D Version: 11
Platform: Windows ;
Language(s) : C.O.F.F.E.E ; C++ ;
What I'm trying to do is to load a scene, then save it to the different file format (obj) in background, i.e. without GUI. That's the major task. What I've got is this:
1. I've tried to write simple script for loading/saving file using COFFEE
\> //loading part \> var filename = new(Filename); \> filename->SetFullString("mypath/mymodelname.c4d"); \> var res = LoadDocument(filename); \> println(res); \> \> //saving part \> var filename2 = GeGetStartupWritePath(); \> filename2->AddLast("template.c4d"); \> \> res = doc->Save(filename2); \> println(filename2->GetFullString(), res); \>
It works great if I run the Cinema4D and then run a script. However there's no option in the COFFEE SDK to save the file in the different format doc->Save always saves to the cinema file format.
Anyway, that was good, but I need to run this in background with no ui visible. After some research I've found that if I start cinema 4D with -nogui command line option and then pass *.csc script as a parameter cinema will execute it and quit. Here comes the first problem:
It doesn't want to save the file from COFFEE script if the script passed as a command line parameter
doc- >Save just returns false. Any ideas why this could happen?
Ok, then I tried another approach using C++ plugins
2. I've decided to write a plugin, that will call save scene function, and which will be executed by the script via CallCommand func.
I've ended up with:
\> Filename file("mypath/mymodel.c4d"); \> LoadFile(file); \> //so far so good \> \> Filename file2("mypath/othermodel.obj"); \> SaveDocument(GetActiveDocument(), file2, 0, FORMAT_OBJEXPORT); \>
It works great with one major problem:
Cinema 4D always brings me up Save As dialog even if I don't specify SAVEAS flag. Any ideas how not to bring this dialog? Especially with "show SAVEAS dialog" flag available in the SDK, I'm thinking I'm missing something.
Any ideas? Big thanks for help!