Skip to content
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

Failure to run the simulation_zone example on blender 4.0 (and 3.6) #41

Open
tsatse opened this issue Nov 18, 2023 · 5 comments
Open

Failure to run the simulation_zone example on blender 4.0 (and 3.6) #41

tsatse opened this issue Nov 18, 2023 · 5 comments

Comments

@tsatse
Copy link

tsatse commented Nov 18, 2023

Hello,
I'm starting from the default cube on which I add a geometry node modifier,
I then type the following script (from the documentation) in the built-in editor :

from geometry_script import *

@tree
def test_sim(geometry: Geometry):
    @simulation_zone
    def my_sim(delta_time, geometry: Geometry, value: Float):
        return (False, geometry, value)
    return my_sim(geometry, 0.26).value

I get the following error message :

    Python: Traceback (most recent call last):
      File "\Text", line 4, in <module>
      File "C:\Users\tsatse\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\geometry-script-main\api\tree.py", line 149, in tree
        return build_tree(name)
      File "C:\Users\tsatse\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\geometry-script-main\api\tree.py", line 113, in build_tree
        outputs = builder(**builder_inputs)
      File "\Text", line 8, in test_sim
      File "C:\Users\tsatse\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\geometry-script-main\api\static\simulation.py", line 21, in wrapped
        simulation_in = State.current_node_tree.nodes.new(bpy.types.GeometryNodeSimulationInput.__name__)
    AttributeError: 'NoneType' object has no attribute 'nodes'

(my OS is windows 10)

@tsatse
Copy link
Author

tsatse commented Nov 18, 2023

I tried to figure out in your code why the state's current node tree wasn't defined but I'm still trying to figure things out. I also tried to make it work with blender 3.6 and your commit that refactors simulation API to use "simulation_zone" but it didn't work either, with a similar error message, ie missing attribute 'nodes' in current_node_tree.

@rsaccon
Copy link

rsaccon commented Nov 20, 2023

I cannot try the example (I am on Blender 3.6, on newer Blender my graphic card is not supported), but looking at the code, especially the signature of my_sym, it looks to me like you are calling it with wrong arguments, the delta_time is missing.
Update: I can run the example on Blender 3.6, but also does not work for me

@tsatse
Copy link
Author

tsatse commented Nov 20, 2023

yes, I tried adding that first argument but it didn't change anything. It looks like the simulation code tries to access the tree while it hasn't been built. I'm trying to understand all the code but I need to read about blender's api now

@tsatse tsatse changed the title Failure to run the simulation_zone example on blender 4.0 Failure to run the simulation_zone example on blender 4.0 (and 3.6) Nov 20, 2023
@alphadito
Copy link
Contributor

alphadito commented Dec 12, 2023

Make sure the geometry script add-on folder is called 'geometry_script'. This will ensure that the correct state module is used instead of relying on __init __.py to manually set sys.modules which unfortunately doesn't work in all cases.

@tsatse
Copy link
Author

tsatse commented Dec 12, 2023

Yesss ! It worked. Thank you so much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants