geometry-script icon indicating copy to clipboard operation
geometry-script copied to clipboard

Convert existing node trees to Geometry Script

Open BradyAJohnston opened this issue 2 years ago • 9 comments

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 avatar Feb 12 '23 10:02 BradyAJohnston

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!

carson-katri avatar Feb 12 '23 16:02 carson-katri

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.

BradyAJohnston avatar Feb 12 '23 23:02 BradyAJohnston

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

carson-katri avatar Mar 02 '23 01:03 carson-katri

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

BradyAJohnston avatar Mar 02 '23 01:03 BradyAJohnston

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?

tbscode avatar Sep 03 '23 15:09 tbscode

@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.

carson-katri avatar Sep 03 '23 16:09 carson-katri

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 avatar Sep 03 '23 16:09 tbscode

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?

tbscode avatar Sep 03 '23 21:09 tbscode

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

WenbinTan avatar Dec 29 '23 18:12 WenbinTan