On 10/04/2014 at 13:51, xxxxxxxx wrote:
That line of code looks ok to me. The problem must be coming from someplace else.
The error seems to indicate that you might be using a vector as the iterator. Instead of LONG(i).
Also make sure that your objList variable is written like this:
InExcludeData *objList = (InExcludeData* )d.GetCustomDataType(CUSTOMDATATYPE_INEXCLUDE_LIST);
Also don't forget about the In/Exclude counter bug too.
If you delete an object from the OM that's in that list. Your code will crash C4D because the iteration count is no longer accurate.
This is a workaround for handling that scenario:
//There is a bug in the In/Exclude list that the count value doesn't update when an object is deleted from the OM
//This is a workaround to that manually deletes an object from the list if the object doesn't exist in the OM
BaseObject *mylight = doc->SearchObject("Light"); //A pointer to the light object with an inexclude list on it
BaseContainer *data = mylight->GetDataInstance(); //Get the lights data
//Get the light's in/exclude list and assign it to a variable
InExcludeData *in_ex_List = (InExcludeData* )data->GetCustomDataType(LIGHT_EXCLUSION_LIST, CUSTOMDATATYPE_INEXCLUDE_LIST);
if(in_ex_List && in_ex_List->GetObjectCount() > 0)
for(int i=0; i < in_ex_List->GetObjectCount(); ++i)
//Find the objects that are in the in/exclude List and assign them to a variable
BaseList2D *ListObj = in_ex_List->ObjectFromIndex(doc,i);
//An object that has been deleted from the OM does not update the list's count value(BUG?)
//So we have to manually subtract one from the count value
if(!in_ex_List->DeleteObject(i)) break; //Delete the object from the In/Exclude list it's not in the OM anymore