Vector
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 17/02/2004 at 18:40, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 8.100
Platform: Windows ;
Language(s) : C++ ;---------
Hi all,
I am trying to get the rotation of the particular object. The code is like this:
** BaseDocument *doc = GetActiveDocument();
BaseObject *obj = BaseObject::Alloc(Ocube);
obj = doc->GetActiveObject();** **
Vector rotation = obj->GetRot();**
But I am getting the error in C4D that the memory could not be read. Can anyone tell me what's wrong with this code.
Thanks for the reply in advance
Regards -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 17/02/2004 at 19:27, xxxxxxxx wrote:
When you get that error it means that a pointer has been accessed that isn't properly initialized, or is NULL. To find out where the issue is you have to start a debug session, then step through the lines to find out where it fails.
By programming defensively, e.g. checking or asserting all pointers before you access them, you can avoid much of the hassle. For example, always put in stuff like "if (!obj) return FALSE;".
Finding the above error (which is glaringly obvious, and might be a typo) would be a good way to learn your development environment. But in case you just want to know what it is, I've included a spoiler below.
Spoiler: In the third line you get the active object in the scene, but I suspect that no object is active. Thus obj gets assigned the NULL value. Then on the fourth line there's an error when you try to get the rotation of "no object". How you would change the code depends on what you were trying to do in the first place. (Select the paragraph to see it.) -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 17/02/2004 at 19:35, xxxxxxxx wrote:
Ok, thanks Mikael for the reply
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 17/02/2004 at 19:48, xxxxxxxx wrote:
Nice trick btw. Mikael ;o)