Crash of a filter plugin
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 06/03/2006 at 11:26, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 9.5
Platform: Windows ;
Language(s) : C.O.F.F.E.E ;---------
Hi everybody.
I'm beginning developping little plugins in C.O.F.F.E.E and I experience a problem trying to make a filter plugin which simply writes objects coords of a scene in a file. To do that, I've created a coords_exporter class inherited from the FilterPlugin class and I've registered it in the main() function. But, when I execute my script, Cinema4D crashes after I select the file to write and I really don't know why...
There is my code :class coords_exporter : FilterPlugin { public: coords_exporter(); GetName(); GetID(); Identify(probe,fname); Save(doc,fname,obj,mat,env,dialog); }; coords_exporter::coords_exporter() { super(); } coords_exporter::GetID() { return 1000001; } coords_exporter::GetName() { return "coords_exporter"; } coords_exporter::Identify(probe,fname) { return TRUE; } coords_exporter::Save(doc,fname,obj,mat,env,dialog) { var object=new(BaseObject); object=doc->GetFirstObject(); var file=new(BaseFile); file->Open(fname,GE_WRITE,FILE_DIALOG,GeGetByteOrder()); var pos; while(object!=NULL) { pos=object->GetPosition(); file->WriteReal(pos.x); file->WriteReal(pos.y); file->WriteReal(pos.z); object=object->GetNext(); } } main(doc,op) { Register(coords_exporter); }
Could you tell me where I'm mistaking ?
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 06/03/2006 at 13:27, xxxxxxxx wrote:
Why are you doing this:
var object=new(BaseObject);
object=doc->GetFirstObject();You are creating a new BaseObject and then filling it with another (the return value)! Do this:
var object = doc->GetFirstObject();
Not certain if that is the cause, but it's a place to begin.
Also, why are you doing this:
main(doc,op)
I've never seen that and it certainly caused a COFFEE error on load. Do this instead:
main()
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 06/03/2006 at 14:21, xxxxxxxx wrote:
I've written
var object = doc->GetFirstObject();
instead of
var object=new(BaseObject); object=doc->GetFirstObject();
and this haven't resolved my crash problem. So, I've tried to suppress the main() function parameters but, when I do that, I get the following error in the console :
"[FAIL] Script 'coords_exporter' : Too many parameters"Do you have other ideas ?
Thank you for your help. -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 06/03/2006 at 15:18, xxxxxxxx wrote:
That's interesting since I tested the script in R9.5 just as you gave it and there was a COFFEE error in the Console Window. As soon as the 'doc,op' were removed from main(), not only did the plugin load but it worked (with the other modification noted)!
So now I have to wonder if there isn't something else going on here: bad C4D install or a test PluginID conflict? I used 1000003 since others were already used.
Any particular modifications to your install? Close Cinema, move all other plugins in the 'Plugins' folder to another folder like 'plugins_back', and restart Cinema with only your plugin. See if the crash continues to occur.
One other thing noted: You say that you 'execute your script'. Are you doing this from the File->Export menu or in some other fashion? Since it is an imort/export plugin, it should be called from File->Export.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 07/03/2006 at 10:28, xxxxxxxx wrote:
I've found my error. Instead of creating a .cof file and putting it in the "plugins" folder, I was just writing my code in the "Script Manager" window and then clicking on the "Exectute" button.
Now, suppressing "doc,op" in the main() declaration and loading the plugin at Cinema4D launch with a .cof file, the script works, except that, after choosing my save file, Cinema4D displays the following error dialog :
"Invalid file operation in file name_of_my_file"Do you know what it is about ?
Thank you a lot.