THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 16/02/2010 at 10:34, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 11.5
Platform: Windows ;
Language(s) : C++ ;
---------
Hello,
I have written an import filter to import a custom file format for mass information. The file contains names of Scenes to merge into the current document and it then sets animation keys for them and renames them. The plugin was working fine with 9.52 32bit.
I now installed the upgrade to 9.6 and tried porting to 64bit, which caused some trouble in getting Visual C++ Express Edition 2008 to produce x64 code, but finally succeeded and the plugin worked fine with 9.6 32bit(when compiled for 32bit), but caused a crash (access violation) in C4D 64bit when compiled for x64, at a SetName() statement.
Since I'm expecting the 11.5 upgrade to arrive this week, I decided not to bother with 9.6 and installed the 11.5 demo to try and get it to work there.
But no luck, after adopting everything that changed regarding AnimationTracks and getting it to compile, I still get Access Violations at the SetName statement.
Here is a code snippet:
LONG STLLoaderData::Load(PluginSceneLoader *node, const Filename &name, BaseDocument *doc, LONG flags, String *error, BaseThread *thread)
{
BaseContainer bc;
LONG i=0;
STLLOAD stl;
String fields[50];
LONG NF;
Vector v;
if (!stl.file) return FILEERROR_MEMORY;
if (!stl.file->Open(name,GE_READ,FILE_NODIALOG,GE_INTEL)) return stl.file->GetError();
stl.flags = flags;
stl.filelen = stl.file->GetLength();
GeConsoleOut(String("Starting Processing"));
while ((stl.filepos<stl.filelen && stl.ReadArg())) { //&&(i<500)) {
String currline(stl.str);
NF=0;
GeConsoleOut(String("Processing")+currline);
while (currline!="") {
LONG pos;
if (currline.FindFirst(";",&pos,0)) {
fields[NF++]=currline.SubStr(0,pos);
currline.Delete(0,pos+1);
} else {
fields[NF++]=currline;
currline="";
}
}
if (fields[0]=="MinFrame") {
GeConsoleOut(String("1a"));
doc->SetFps(25);
BaseTime t(fields[1].StringToReal());
doc->SetMinTime(t);
MinFrame=fields[1].StringToReal();
} else if (fields[0]=="MaxFrame") {
doc->SetFps(25);
BaseTime t(fields[1].StringToReal());
doc->SetMaxTime(t);
MaxFrame=fields[1].StringToReal();
} else if (fields[0]=="ObjectId") {
BaseObject *newobj;
MergeDocument(doc,Filename(fields[13]),flags,thread);
newobj=doc->SearchObject("Darwinian");
if (newobj==NULL) {
GeConsoleOut(String("I really need a Darwinian!!"));
return FILEERROR_WRONG_VALUE;
}
GeConsoleOut(String("Gonna set name'")+fields[1]+"'");
newobj->SetName(fields[1]); // <- here it fails
}
v.x=fields[2].StringToReal();
v.y=fields[3].StringToReal();
v.z=fields[4].StringToReal();
newobj->SetPos(v);
v.x=fields[5].StringToReal();
v.y=fields[6].StringToReal();
v.z=fields[7].StringToReal();
newobj->SetRot(v);
The error message I get is:
Unhandled exception at 0x0000000140df3800 in CINEMA 4D Demo 64 Bit.exe: 0xC0000005: Access violation at location 0x0000000140df3800.
The "Gonna set name..." GeConsoleOut statement works as expected and prints out the name correctly, so the string seems to be ok (it contains "0000000Header").
Any ideas?
BTW, When I open the file to be imported, the console reads out "Checking type" twice, before my plugin is called. Any ideas what this means, or if it is relevant?
Thanks for helping
Mike