AutoAddSequence returns NULL. Why?

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 17/04/2005 at 04:42, xxxxxxxx wrote:

User Information:
Cinema 4D Version:   9.1 Demo 
Platform:   Windows  ;   
Language(s) :     C++  ;

---------
Hello...

I have a problem with the AutoAddSequence method. I want to check if there is still a sequence. If not, the program should add a sequence to the track. I use the CreateKey method which I have found in the MorphMixer.cpp example. Now, in some cases, this method returns NULL because no sequence could be added.
See this:

  
static AnimValue* CreateKey(BaseDocument *doc, BaseObject *op, const BaseTime &time;, LONG index, LONG sid, Real value)  
{  
     // check if track exists  
     BaseTrack *track = op->FindTrack(DescID(DescLevel(index), DescLevel(sid, DTYPE_REAL,0)));  
     if (!track)  
     {  
          track = AllocValueTrack(op,DescID(DescLevel(index), DescLevel(sid, DTYPE_REAL,0))); if (!track) {return NULL;}  
          op->InsertTrackLast(track);  
     }  
  
     // check for sequence  
     BaseSequence *seq=NULL;  
     for (seq = track->GetFirstSequence(); seq; seq=seq->GetNext())  
          if (time>=seq->GetT1() && time<=seq->GetT2())  
               break;  
  
     if (!seq)  
     {  
          seq = track->AutoAddSequence(doc,time);   
          if (!seq) {/*MessageDialog("no seq" + RealToString(time.Get()));*/return NULL;}  
     }  
  
     BaseKey *key = BaseKey::Alloc(seq->GetType()); if (!key) {return NULL;}  
     AnimValue *av = GetKeyValue(key); if (!av) {return NULL;}  
  
     av->value = value;  
       
  
     key->SetTime(time);  
     seq->InsertKey(key);  
     return av;  
}  

Why doesn't AutoAddSequence() work? Why isn't a sequence added?

Can you help me?

Regards,

jacqui.

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 21/04/2005 at 13:33, xxxxxxxx wrote:

Any special sequence configurations that cause this error, or is it totally random?

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 05/07/2005 at 10:55, xxxxxxxx wrote:

When I open an empty project in Cinema4D and call this plugin, which generates a new animation sequence, I get this error, that means this method returns NULL.

When I again call this plugin (i.e. this method) while the same Cinema4D project is open, it works...!?

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 05/07/2005 at 11:28, xxxxxxxx wrote:

I'm surprised it doesn't crash! It is entirely possible for 'op' to be NULL. Unless you are ensuring that before calling CreateKey(). Has 'op' been BaseDocument->InsertObject(op,etc.)'d before calling the method?