Member variables in ObjectData

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

On 27/10/2004 at 23:01, xxxxxxxx wrote:

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

---------
I have an object derived from ObjectData. I have one member variable in this object (e.g. String). But i can not save any data in this variable. Why?
...
class MyObjectData: public ObjectData
{
INSTANCEOF(MyObjectData,ObjectData)
public:
    static NodeData *Alloc(void){return gNew MyObjectData;}
    virtual Bool Init(GeListNode *node);
    void ShowValue();
private:
    String text;
};
...
...
Bool MyObjectData::Init(GeListNode *node)
{
    text = "hello";       //assigning a value
    return TRUE;
}
...
...
void MyObjectData::ShowValue()
{
    GePrint("Text:" + text);        //variable text is empty
}
...
Thanks,
Torsten

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

On 28/10/2004 at 08:59, xxxxxxxx wrote:

First, you could easily store the String in a BaseContainer with an id (i.e.: node->GetDataInstance()->SetStaticText(MYOBJECTDATA_TEXT, "hello")), but that's beside the point. 🙂

Everything looks proper. Init() is called directly after the constructor during gNew, so it should have a valid value afterwards. Have you tried GePrint() within Init()? Are you at least getting "Text:" to show in the console?

Robert

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

On 03/11/2004 at 11:09, xxxxxxxx wrote:

I can't see either why this wouldn't work in the code posted. Perhaps your object is cloned? You'd need to implement the CopyTo(), Read() and Write() functions to make the data persistent.