On 02/05/2013 at 19:45, xxxxxxxx wrote:
User Information:
Cinema 4D Version: R14
Platform: Windows ;
Language(s) : C++ ;
---------
Hi Folks,
I'm trying to retrieve the position of an object before and after a move. However, using both object->GetRelPos() or going through the DescLevel attributes gives me the same position values (shown when I GePrint them..). My process is as follows:
1)Get Objects first position
2)Object is moved
3)object->Message(MSG_UPDATE) (have tried different messages here)
4)EventAdd() (have tried different flags here..)
5)Get object's new position
But the initial and new object positions are being returned as the same values? Some code:
GeData gedata;
MainObject->GetParameter(ID_TAB_OBJECT_LINKED,gedata,DESCFLAGS_GET_0); // BaseObject with a link field...
LinkedObject = (BaseObject* )gedata.GetLink(doc); // BaseObject taken from the MainObject's link field...
GeData gedataNew;
DescID posXid = DescID(DescLevel(ID_BASEOBJECT_REL_POSITION, DTYPE_VECTOR,0), DescLevel(VECTOR_X, DTYPE_REAL,0));
DescID posYid = DescID(DescLevel(ID_BASEOBJECT_REL_POSITION, DTYPE_VECTOR,0), DescLevel(VECTOR_Y, DTYPE_REAL,0));
DescID posZid = DescID(DescLevel(ID_BASEOBJECT_REL_POSITION, DTYPE_VECTOR,0), DescLevel(VECTOR_Z, DTYPE_REAL,0));
LinkedObject->GetParameter(posXid, gedataNew, DESCFLAGS_GET_0);
Real X = gedataNew.GetReal();
LinkedObject->GetParameter(posYid, gedataNew, DESCFLAGS_GET_0);
Real Y = gedataNew.GetReal();
LinkedObject->GetParameter(posZid, gedataNew, DESCFLAGS_GET_0);
Real Z = gedataNew.GetReal();
Vector T_Pos_Editor = Vector(X,Y,Z);//LinkedObject->GetAbsPos();
// Prints of the object's initial position done here...
if(Active == TRUE)
{
ObjectSelected = TRUE; // irrelevant to the object move
Active = FALSE;
}
// LinkedObject is moved below by (what I thought was..) updating the MainObject's Execution function
Pattribute.ExecutionRefresh = 1; // Bool flag to allow MainObject's execution to move LinkedObject
MainObject->Message(MSG_UPDATE);
LinkedObject->Message(MSG_UPDATE);
EventAdd(EVENT_ANIMATE); // different flags called here...
Vector Th = LinkedObject->GetRelPos(); //instead of the DescLevel way, I tried GetRelPos() here instead...
X = Th.x;
Y = Th.y;
Z = Th.z;
// Second prints are done here, but they return the same values as the first prints...!?
I've tried combinations of all sorts of things. And while the object is moved, the GePrint values are always the same (both prints the initial values)? What else can I try here?
WP.
P.S. these spaced line prints are irritating - they don't show in Notepad or Notepad++, or in the message form text edit field...