-
Notifications
You must be signed in to change notification settings - Fork 342
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Difficulty reading updated scene information in a script #1250
Comments
This seems like the issue reported in #1171, is this the issue you are having? |
I've tried to render my animation and it seems to behave as expected. |
So the issue only occur when you are rendering from the command line? |
I'm not even rendering. My aim is to export animation data. So for every frame I captura object transform and store it. But I don't render anything. |
So you have a node tree that sets the transformation of the object, and then you run a script that access the transformation of the object? |
That's correct.
…On Fri, 6 Dec 2019, 18:12 Omar Emara, ***@***.***> wrote:
So you have a node tree that sets the transformation of the object, and
then you run a script that access the transformation of the object?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1250?email_source=notifications&email_token=AAEZGV2HLSJWAG7EMACKEYTQXKBXRA5CNFSM4JW4ZYN2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEGEX3ZQ#issuecomment-562658790>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAEZGVYZBLFWXQMKNOYKCKLQXKBXRANCNFSM4JW4ZYNQ>
.
|
Can you share a minimal file that reproduces the issue? |
I will prepare one. Thanks for prompt response.
…On Fri, 6 Dec 2019, 18:25 Omar Emara, ***@***.***> wrote:
Can you share a minimal file that reproduces the issue?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1250?email_source=notifications&email_token=AAEZGV7UMS7MLQINOX5XH5TQXKDJ5A5CNFSM4JW4ZYN2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEGEZCQI#issuecomment-562663745>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAEZGVZEZXY6I7BMLMTIPO3QXKDJ5ANCNFSM4JW4ZYNQ>
.
|
Hi and sorry for delay. My toy export script looks like this: import bpy
def printObjectPosition(obj):
print(obj.name, obj.matrix_world.to_translation())
def convertAnimation(scene):
objs = scene.objects
scene.frame_set(scene.frame_start)
printObjectPosition(objs["Plane"])
printObjectPosition(objs["Plane.001"])
scene.frame_set(scene.frame_start+100)
printObjectPosition(objs["Plane"])
printObjectPosition(objs["Plane.001"])
convertAnimation(bpy.data.scenes['Scene']) and blender invocation looks like this:
My attached blend file contains two objects: "Plane" which is driven by AN and "Plane.001" which moved via key frames. Note how position of "Plane.001" changes between This worked fine in 2.7x. Am I missing a trick in 2.8x? |
Animation Nodes needs to execute when you change the current frame in order for the object location to be updated. Animation Nodes can only see such change in the current frame after the script finish execution, so Auto Execution is not an option. To fix this, you just need to execute the node tree yourself when needed. Your script should be something like: import bpy
def printObjectPosition(obj):
print(obj.name, obj.matrix_world.to_translation())
def convertAnimation(scene):
objs = scene.objects
scene.frame_set(scene.frame_start)
printObjectPosition(objs["Plane"])
printObjectPosition(objs["Plane.001"])
scene.frame_set(scene.frame_start+100)
bpy.data.node_groups['NodeTree'].execute() # Execute node tree after changing frame.
printObjectPosition(objs["Plane"])
printObjectPosition(objs["Plane.001"])
convertAnimation(bpy.data.scenes['Scene']) Makes sense? |
Yes. That makes perfect sense. I'm only curious why this wasn't necessary
in 2.79? Regards.
…On Wed, 11 Dec 2019, 09:36 Omar Emara, ***@***.***> wrote:
Animation Nodes needs to execute when you change the current frame in
order for the object location to be updated. Animation Nodes can only see
such change in the current frame after the script finish execution, so Auto
Execution is not an option. To fix this, you just need to execute the node
tree yourself when needed. Your script should be something like:
import bpy
def printObjectPosition(obj):
print(obj.name, obj.matrix_world.to_translation())
def convertAnimation(scene):
objs = scene.objects
scene.frame_set(scene.frame_start)
printObjectPosition(objs["Plane"])
printObjectPosition(objs["Plane.001"])
scene.frame_set(scene.frame_start+100)
bpy.data.node_groups['NodeTree'].execute() # Execute node tree after change frame.
printObjectPosition(objs["Plane"])
printObjectPosition(objs["Plane.001"])
convertAnimation(bpy.data.scenes['Scene'])
Makes sense?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1250?email_source=notifications&email_token=AAEZGV5JJKADRL6K6BA77GTQYCYBVA5CNFSM4JW4ZYN2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEGSPF2Y#issuecomment-564458219>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAEZGV6S7K4W225ALJTVNELQYCYBVANCNFSM4JW4ZYNQ>
.
|
Blender 2.8 removed the ALWAYS event handler we used in 2.7x to implement Auto Execution, so now we use an infinite timer. I don't know exactly why this happens, but that must be the cause of this. |
Thanks. But if my node uses "frame changed" handler then shouldn't that
work? I never use ALWAYS for updates as this drains the CPU a lot.
…On Wed, 11 Dec 2019 at 10:36, Omar Emara ***@***.***> wrote:
Blender 2.8 removed the ALWAYS event handler we used in 2.7x to implement
Auto Execution, so now we use an infinite timer. I don't know exactly why
this happens, but that must be the cause of this.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1250?email_source=notifications&email_token=AAEZGV2ERT7GTXDJALDQKGTQYC7CPA5CNFSM4JW4ZYN2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEGSU3OQ#issuecomment-564481466>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAEZGVZHHWEZ4P3CO6KGNHTQYC7CPANCNFSM4JW4ZYNQ>
.
|
If you enable Auto Execution, Animation Nodes is always executing as many times as possible, even if the Always option is disabled. Animation Nodes does not use a proper trigger system for auto execution. For instance, when you enable Frame Changed, in the background, the frame value is retrieved and stored as a string, then it is compared to the previously stored value, if Animation Nodes notices that the value changed, it then executes the node tree. To summarize, if you disable the Always option, Animation Nodes is still always executing an internal trigger mechanism. |
Ok, thanks. I'll try your solution when I'll get back home. Regards.
…On Wed, 11 Dec 2019 at 11:46, Omar Emara ***@***.***> wrote:
If you enable Auto Execution, Animation Nodes is always executing as many
times as possible, even if the *Always* option is disabled. Animation
Nodes does not use a proper trigger system for auto execution. For
instance, when you enable *Frame Changed*, in the background, the frame
value is retrieved and stored as a string, then it is compared to the
previously stored value, if Animation Nodes notices that the value changed,
it then executes the node tree.
To summarize, if you disable the *Always* option, Animation Nodes is
still always executing an internal trigger mechanism.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1250?email_source=notifications&email_token=AAEZGV2Q6IOMWJ4BHFL3CCTQYDHIFA5CNFSM4JW4ZYN2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEGS2RSQ#issuecomment-564504778>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAEZGV2SR26NDXGWK2RNPEDQYDHIFANCNFSM4JW4ZYNQ>
.
|
|
Yes, it works with the blend file you sent. |
Position of "Plane" stays the same after calling execute. Could that be platform difference?
|
It seems to work for me now from within Blender, but not when executed from the commandline. |
hmmmm, no. Can you update the matrices from the script itself. See: Otherwise, I would consider this a bug as in #1171. |
I see my |
In this case, I would need to investigate this further. Might take some time, sorry. |
Thanks! I tried to find a relevant build but had no luck. Is that available? |
Should be available in https://animation-nodes.com/ |
See #1240. |
Thanks. I can run it now. Sadly, the above toy script still doesn't work. I've tried all your earlier suggestions (except bpy.data.node_groups['NodeTree'].execute() which doesn't seem to work at all). |
hmm, let me test this again. |
It seems to be working fine for me: ┌─[omar]──[~/Desktop]
└─╼ blender -noaudio -y --background an_test.blend -P export_example.py
Blender 2.83 (sub 4) (hash dcb905a58f59 built 2020-02-17 14:36:20)
Read prefs: /home/omar/.config/blender/2.83/config/userpref.blend
/run/user/1000/gvfs/ non-existent directory
Registered Animation Nodes
Read blend: /home/omar/Desktop/an_test.blend
Plane <Vector (0.3774, 1.7612, 0.0000)>
Plane.001 <Vector (4.2274, 0.1166, 0.0000)>
Plane <Vector (-2.3628, -1.3816, 0.0000)>
Plane.001 <Vector (0.5983, -0.7396, 0.0000)>
Blender quit This was using your original toy script: import bpy
def printObjectPosition(obj):
print(obj.name, obj.matrix_world.to_translation())
def convertAnimation(scene):
objs = scene.objects
scene.frame_set(scene.frame_start)
printObjectPosition(objs["Plane"])
printObjectPosition(objs["Plane.001"])
scene.frame_set(scene.frame_start+100)
printObjectPosition(objs["Plane"])
printObjectPosition(objs["Plane.001"])
convertAnimation(bpy.data.scenes['Scene']) We now execute automatically on Can you test with 2.83? Just so that we have the same setup and can debug this better. |
Ok, it seem to work on 2.83... But I had to remove the "Update Object Matrices" node. Is this what you'd expect? Regards |
Not exactly. Does it fail with the |
Yes, It fails to update the positions. |
I am not entirely sure why this is the case. It could be that the depsgraph at this point is not up to date. But look at the bright side, it works. 😀 |
Indeed. Thanks! :) |
I have an export script which I execute in Blender 2.81 in headless mode (on commandline). It's meant to export and animation I've created using Animation Nodes. My script worked fine in 2.79. In 2.81 my object animation is not updated: for every scene.frame_set() position, rotatino etc. is the same.
Can you help me get to the bottom of the problem? I must be missing something that was introduced in Blender 2.8?
Regards
The text was updated successfully, but these errors were encountered: