CURRENTSTATETOOBJECT of a Null

On 02/06/2017 at 03:22, xxxxxxxx wrote:

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

---------
I am still struggling with the SendModelingCommand()+MCOMMAND_CURRENTSTATETOOBJECT.

A standard Sphere is ok, but wat to do with a Null.
Are there issues or things to check when CST a Null?

Here my code.

ModelingCommandData cd;
cd.doc = GetActiveDocument();
//cd.op = (BaseObject* )obj->GetClone(COPYFLAGS_NO_BITS, nullptr);
cd.op = obj;								//Do not Clone!!!
if (!SendModelingCommand(MCOMMAND_CURRENTSTATETOOBJECT, cd)) return false;
cstObject = (BaseObject* )cd.result->GetIndex(0);
if (!cstObject) return nullptr;

-Pim

On 02/06/2017 at 03:40, xxxxxxxx wrote:

Found it.
I did not take the correct document (virtual / cache object);

//cd.doc = GetActiveDocument();
cd.doc = obj->GetDocument();

-Pim