THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 12/10/2007 at 05:52, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 10
Platform: Windows ;
Language(s) : C++ ;
---------
Hello,
I am trying to write a plugin which, among other things, inserts a camera into a scene. Here is my code for the insertion of a camera object as a child object of the current active object:
> _AddCameraObject()
> {
> CameraObject* camera = (CameraObject* )BaseObject::Alloc(Ocamera);
>
> if ( !camera ) {
> GePrint("CameraObject creation failed!");
> } else {
> GePrint("CameraObject creation success!");
> }
>
> BaseDocument *actdoc = GetActiveDocument();
> BaseObject *actobj = actdoc->GetActiveObject();
>
> actdoc->InsertObject(camera, actobj, NULL, TRUE);
> }
> _
The problem is that I have no idea where to call my function.
I tried to write an tag plugin and call my function in Execute() or in Init() but obviously those funtions are evaluated multiple times so more and more cameras were inserted. Also the SDK states that no InsertObject() should be called in those functions.
The next thing I tried was to write an object plugin with the same functionality. I tried to set my camera as the return value of GetVirtualObjects() with the result that no camera was inserted at all.
So my question is where to call AddCameraObject() or more explicitly InsertObject(camera,...) so that the plugin stops creating hundreds of cameras? Or am I using a wrong plugin type?
Thanks in advance for your help,
mfranke