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

Convert existing node trees to Geometry Script #8

Open
BradyAJohnston opened this issue Feb 12, 2023 · 9 comments · May be fixed by #13
Open

Convert existing node trees to Geometry Script #8

BradyAJohnston opened this issue Feb 12, 2023 · 9 comments · May be fixed by #13

Comments

@BradyAJohnston
Copy link

Hi mate!

I don't suppose you've got functionality for going the other direction, converting nodes to code? This would save me a lot of time for not having to rebuild all of the node trees in code form manually.

I've created and maintain a project that relies on a bunch of pre-built geometry nodes groups (https://github.com/BradyAJohnston/MolecularNodes) which I am looking to convert to actual code (geometry-script) so that it can be version-controlled better than the currently opaque .blend file that they live in.

Any advice? cheers for the great project, which I will definitely be utilising in the future!

@BradyAJohnston BradyAJohnston changed the title Converty existing node trees to Geometry Script Convert existing node trees to Geometry Script Feb 12, 2023
@carson-katri
Copy link
Owner

This should definitely be possible, I'll look into it. Your use case is very interesting, looking forward to seeing some geometry script in there!

@BradyAJohnston
Copy link
Author

I gave a talk at BCON last year on the use case if you want to hear me talk more about it: https://www.youtube.com/watch?v=adhTmwYwOiA

I'll hold off on converting anything immediately to see if there is an easy solution, but otherwise I'll go through and start converting them manually probably in like a month or so when I've got some more time to dedicate to it. I also personally find that prototyping functions manually inside of Blender is faster, to then be able to quickly save it out as code for git to read would be great.

@carson-katri
Copy link
Owner

I have a prototype for this implemented in #13. Let me know if you have any problems converting more complex node trees.

@BradyAJohnston
Copy link
Author

Ooh very exciting, thanks for the quick turn around. I'll give it a test run and try it out!

@carson-katri carson-katri linked a pull request Mar 2, 2023 that will close this issue
@tbscode
Copy link

tbscode commented Sep 3, 2023

I've been playing around with geometry script for some time now, and I love it!
This would be a killer feature for existing geometry node projects, I see that there is already a draft implemented.

Is this still in development? Can I try this somewhere?

@carson-katri
Copy link
Owner

@tbscode If you go to this page (or just select the nodes-to-script branch), you should be able to download the addon ZIP. Let me know any issues you run into when converting.

@tbscode
Copy link

tbscode commented Sep 3, 2023

Thanks, jup using this link I could download the current build: https://github.com/carson-katri/geometry-script/archive/refs/heads/nodes-to-script.zip

Though I think I still need some missing commits for the blender 3.5 update ( I'm on 3.6 & linux ).
Currently I'm just getting:

*some weird lib error*
Read prefs: "/home/tim/.config/blender/3.6/config/userpref.blend"
Traceback (most recent call last):
  File "/home/tim/Data/local/programms/blender-3.6.2-linux-x64/3.6/scripts/modules/addon_utils.py", line 333, in enable
    mod = __import__(module_name)
  File "/home/tim/.config/blender/3.6/scripts/addons/geometry-script-nodes_to_script/__init__.py", line 22, in <module>
    from .api.tree import *
  File "/home/tim/.config/blender/3.6/scripts/addons/geometry-script-nodes_to_script/api/tree.py", line 9, in <module>
    from .node_mapper import *
  File "/home/tim/.config/blender/3.6/scripts/addons/geometry-script-nodes_to_script/api/node_mapper.py", line 124, in <module>
    category.draw(CategoryStub(), None)
  File "/home/tim/Data/local/programms/blender-3.6.2-linux-x64/3.6/scripts/startup/bl_ui/node_add_menu_geometry.py", line 459, in draw
    if context.preferences.experimental.use_new_volume_nodes:
AttributeError: 'NoneType' object has no attribute 'preferences'

I suppose just cloning this repo to $HOME/.config/blender/3.6/scripts/addons/* should also work, so I'll try merging this locally and test it then.

@tbscode
Copy link

tbscode commented Sep 3, 2023

Yeah got it to work.
Seems to work generally pretty well, so far I saw one issue.
The new Simulation nodes output doesn't seem to be correctly serialized:

paired_output=<bpy_struct, GeometryNodeSimulationOutput("Simulation Output") at 0x7fb804f59988>

Should I report my findings somewhere else, as separate issues?

@WenbinTan
Copy link

i think that function (Convert existing node trees to Geometry Script) is useful, When i have an idea, i usually use node trees to validate it. if it work, then i will convert it to python code.
So I'm also looking forward to this feature too

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

Successfully merging a pull request may close this issue.

4 participants