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); \>
\> //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); \>
\> 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!
On 25/03/2010 at 05:00, xxxxxxxx wrote:
I've a similar issue here. Any input on this? Key point i that I'd like to suppress the file dialog in BaseDocument->SaveDocument.
Eventually I actually would like to overwrite the file if it already exists, but that's a secondary concern.
On 25/03/2010 at 07:33, xxxxxxxx wrote:
There is a good base for obj script exporting done by Gord T. at DVXuser.com.
Both for geometry and .mtl.
On 25/03/2010 at 07:51, xxxxxxxx wrote:
Yep its a decent script with lots of good info in it for study.
With a little modification you can export out only single obj files, or even export only .uvs files for use in uvmapper pro.
On 25/03/2010 at 08:37, xxxxxxxx wrote:
Well, thanks for your efforts, but this is not what I'm looking for... I've written quite a number of parsers and exporters in my life, but this is exactly what I would like to avoid here.
The issue is quite simple: I just would like to use the existing exporters in a scenario w/o user interaction at this time in the process, and I would like to use the SaveDocument() method of BaseDocument for it. I have a valid filename, I can take care that the file doesn't exist, I just don't want to ask the user.
On 05/04/2010 at 07:25, xxxxxxxx wrote:
Matthias, is it possible to save a document in the background (under a new name) w/o user interaction - and w/o writing you own exporter?
Or is the file dialog an integral part of the SaveDocument() method, which can't be suppressed? However, if it can't be suppressed, what's the SAVEFLAG_SAVEAS for?
On 06/04/2010 at 00:53, xxxxxxxx wrote:
Following line should work:
SaveDocument(doc, GeGetStartupPath()+Filename("test.c4d"), 0, FORMAT_C4DEXPORT)
On 06/04/2010 at 02:08, xxxxxxxx wrote:
Ah, ok... thanks! Wasn't clear to me from the docs that the path is supposed to be delivered in the filename, not in the document's path.