how to set the camera name?
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 30/07/2007 at 04:31, xxxxxxxx wrote:
User Information:
Cinema 4D Version:
Platform: Windows ;
Language(s) : C++ ;---------
when I adding a new camera after, I want to rename it; but I change the name using camobj->SetName("mycam"); c4d system break and exit arose error. when without is the working fine. someone can help me ;this my code:
bool DoAddCamera()
{
BaseDocument* doc = GetActiveDocument();
if (!doc) return false;
BaseObject* null = doc->GetActiveObject();
if (!null)
{
null = doc->GetFirstObject();
if (!null)
{
return false;
}
}
CameraObject* cam = (CameraObject* )BaseObject::Alloc(Ocamera);
if ( !cam )
{
MessageDialog("CameraObject Create Fail!");
return false;
}
doc->InsertObject(cam, NULL, NULL);
DrawViews(DA_FORCEFULLREDRAW);
Vector objvcr = null->GetMg().off;
Vector camvcr;
camvcr.x = objvcr.x - 500;
camvcr.y = objvcr.y + 500;
camvcr.z = objvcr.z - 500;
cam->SetPos( camvcr );
cam->SetRot(Vector(-0.8, -0.6, 0)); // Set rotation (radians, HPB)cam->SetZoom( 1.0 );
cam->SetAperture( 36.0 );
cam->SetFocus( 36.0 );
EventAdd();
BaseObject* oldcam = doc->GetRenderBaseDraw()->GetSceneCamera(doc);
doc->GetRenderBaseDraw()->SetSceneCamera(cam);
Bool bFindResult = TRUE;
LONG Id_Cam = 1;
while ( bFindResult )
{
String camname("TSPCam"+ LongToString(Id_Cam));
BaseObject* camobj = doc->SearchObject( camname );
if ( !camobj )
{
bFindResult = FALSE;
cam->SetName(camname);
}
else
{
++Id_Cam;
}
DrawViews(DA_FORCEFULLREDRAW);
EventAdd();
}}