1
$\begingroup$

Hey guys I got a question! Is it possible to get the text from blenders geo nodes out to a text file? Like at the very least copy the final string to use it outside of blender? So I'd like to have merged text test copied so i can paste it into a text file. Or a python code to acces the data of the geo node so i can copy it from a print or somethingenter image description here

$\endgroup$
2
  • $\begingroup$ Apparently can't be done as it would require accessing the data from a node socket and that's not supported. $\endgroup$ Apr 9, 2022 at 17:46
  • $\begingroup$ I don't know if it works but maybe you can create the strings with a python script where you can export them to a txt file and use the script to pass the string to geometry nodes $\endgroup$
    – Timmethy
    Apr 9, 2022 at 21:48

1 Answer 1

1
$\begingroup$

I just tried and it works, you can use a script to pass a string to your geometry nodes and save it as a txt file. just set up your geometry nodes tree with one String node like this: enter image description here

and then use the following script to change the string:

import bpy

my_string = "replace with your string"


def main(my_string):
    
    #Make sure that 'Geometry Nodes' is the name of your Node tree. If it is not you have to change it in the line below.
    bpy.data.node_groups['Geometry Nodes'].nodes['String'].string = my_string
    
    #This will create the txt file in the same folder your .blend file is in  
    text_file = open(bpy.path.abspath("//my_string.txt"), "w")
    text_file.write(my_string)
    text_file.close()
    
main(my_string)

To run the script, open a text editor window in blender, paste the code and press the run script button.

An alternative way is to check the Join String node you have for its inputting nodes and get the strings from there:

import bpy

my_string = ""
for i in bpy.data.node_groups['Geometry Nodes'].nodes['Join Strings'].inputs[1].links:
    my_string += i.from_node.string
text_file = open(bpy.path.abspath("//my_string.txt"), "w")
text_file.write(my_string)
text_file.close()
    
$\endgroup$
2
  • $\begingroup$ tbh you don't read the output data. You write back the string you set to the text file. He wants to get the output string (group output result) You write/fill one node in GN - that works, but the OP wanted to have the result of the join strings in his text file. $\endgroup$
    – LuckyOne
    Apr 10, 2022 at 3:17
  • $\begingroup$ True, the second approach in my answer extraxts the strings from the join string node though. $\endgroup$
    – Timmethy
    Apr 10, 2022 at 8:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .