THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 19/08/2007 at 19:37, xxxxxxxx wrote:
Can't really help much there. I'm using VS 6.0 for Windows 32-bit plugins and don't have an R9.5 api lib. I do 8.2, 8.5, 9.1, 9.6, and 10.1 only due to feature support differences.
Are you getting any warnings or errors during build of the api library or your plugin project?
One thing that you may want to try is setting the name after inserting the camera into the document:
String camname;
BaseDocument* doc = GetActiveDocument();
if (!doc) return false;
BaseObject* null = BaseObject::Alloc(Onull);
if (!null)
{
return false;
}
doc->InsertObject(null, NULL, NULL, TRUE);
CameraObject* cam = (CameraObject* )BaseObject::Alloc(Ocamera);
if ( !cam )
{
MessageDialog("CameraObject Create Fail!");
return false;
}
//set camera name
LONG Id_Cam = 1;
BaseObject* camobj;
for (;;)
{
if (nTypeObj == 0)
{
camname = String("0_TSPCam"+ LongToString(Id_Cam));
}
else
{
camname = String("1_TSPCam"+ LongToString(Id_Cam));
}
camobj = doc->SearchObject( camname );
if ( !camobj )
{
break;
}
else
{
++Id_Cam;
}
}
doc->InsertObject(cam, NULL, NULL, FALSE);
//set camera name
cam->SetName(camname);
......
}
Also note that instead of wasting a variable for a basically 'infinite loop', you can just break the loop and set the name as shown. I'd also pull the BaseObject* camobj declaration outside of the loop just for memory and speed purposes - just reuse the variable in the loop, but declare it once just before the loop. You've also already established that no other has the name, so you can use FALSE for the InsertObject() argument.