On 15/02/2013 at 00:33, xxxxxxxx wrote:
Hello All, I wonder how it is possible to get the previous position of an Object after I moved it.
I thought I could do an undo and check the Position and than compare it. But it is returning always the current position.
Any Clues? Thank you in advance.
Here is the Code I tried:
selec = doc.GetActiveObject()
c4d.CallCommand(12105) # Undo
print "newpos:", newpos
print "oldpos:", oldpos
On 15/02/2013 at 01:11, xxxxxxxx wrote:
it depends. It depends on how your code is executed: Script Manager, Python Tag/Genreator/XPresso
When you're not in the Script Manager, you shouldn't perform an undo, or any CallCommand()
actually. When you are, it's fine to perform an undo, but can you assure the last action you've done
is moving the object? It is actually impossible to grab the previous position of an object from the
Script Manager since you can not be 100% sure the last undo-action has moved the object, nor
doing an undo for this is a nice approach.
From an Expression (Python Tag/Generator/XPresso Node), you can store the position of the object
in a global variable and read it out another time your code is executed.
On 15/02/2013 at 02:58, xxxxxxxx wrote:
Hi Niclas, Thanks for your respond.
I want to execute this in the Scriptmanager. But somehow I get not the OldPosition after an Undo. It is always returning the current Position. Well, to be sure I have moved the Object I could ask if Oldpos=newpos. So I would know I have moved the Object.
On 15/02/2013 at 04:21, xxxxxxxx wrote:
Interesting. I can't get it to work properly, too.
old_pos = op.GetAbsPos()
new_pos = op.GetAbsPos()
print '~' * 20
When I move the object in the editor (using mouse-drag) and execute the script, I get two
times the same position. When I set the position of the object in the Attribute Manager and
execute the script, I get the expected result: two different vectors.
On 15/02/2013 at 04:34, xxxxxxxx wrote:
You are right. Change values in the AM will return two diferent Vectors...smells like a Bug?
On 15/02/2013 at 12:54, xxxxxxxx wrote:
You are looking for a previous state of an -un- animated object?
Else AnimateObject() would be the way.