THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 15/10/2007 at 16:49, xxxxxxxx wrote:
Don't we all! 
Here's my standard fare which is pretty close:
_//*---------------------------------------------------------------------------*
Bool SetKey(BaseDocument* doc, const BaseTime & insert, BaseObject* base, const DescID& descID, Real value)
//*---------------------------------------------------------------------------*
{
// *** TRACK ***
CTrack* track = base->FindCTrack(descID);
// There is no track
if (!track)
{
track = CTrack::Alloc(base, descID);
if (!track)
{
MessageDialog("Error! SetKey.track");
return FALSE;
}
base->InsertTrackSorted(track);
doc->AddUndo(UNDO_NEW, track);
}
doc->AddUndo(UNDO_CHANGE, track);
// *** SEQUENCE ***
// Continually update document's time frame to fit animation
// - This fixes issues with Timeline extending that differs from document min/max
if (doc->GetMinTime() > insert) doc->SetMinTime(insert);
else if (doc->GetMaxTime() < insert) doc->SetMaxTime(insert);
CCurve* seq = track->GetCurve();
// - This should never happen in R10+
if (!seq)
{
MessageDialog("Error! SetKey.seq");
return FALSE;
}
// *** KEY ***
// Create and Set keyframes
CKey* key = seq->FindKey(insert);
if (key)
{
// Undo before changing data
doc->AddUndo(UNDO_CHANGE, key);
key->SetValue(seq, value);
// Interpolation was already set (? - see below)
}
// Add Key if none exists on seq for frameTime
else
{
key = CKey::Alloc();
key = seq->AddKey(insert);
if (!key)
{
MessageDialog("Error! SetKey.key");
return FALSE;
}
doc->AddUndo(UNDO_NEW, key);
doc->AddUndo(UNDO_CHANGE, key);
key->SetValue(seq, value);
// Set key interpolation
key->SetInterpolation(seq, CINTER_SPLINE);
key->SetParameter(DescID(ID_CKEY_AUTO), GeData(TRUE), 0L);
}
// Update Editor
track->AnimateTrack(doc, base, insert, ANIMATE_NO_CHILDS, NULL);
return TRUE;
}_
The difficult part here is the DescID descID. This is the id that binds the track/key to the parameter.
You'll need to get used to finding things in the Resource/res/description folder. If you look in the Obase.res file, you'll find this line:
LONG ID_BASEOBJECT_VISIBILITY_EDITOR { CYCLE { OBJECT_UNDEF; OBJECT_ON; OBJECT_OFF; } }
This will need to be passed as something like this in the above 'const DescID & descID' argument of the SetKey method:
DescID(DescLevel(ID_BASEOBJECT_VISIBILITY_EDITOR,DTYPE_LONG,0))
And the 'value' argument will be one of the three choices : OBJECT_UNDEF, OBJECT_ON, or OBJECT_OFF.