I am working on a new node for myself for the Animation nodes Addon. I need to open a File-Browser via that node, similar with what happens in the "Bake Sound"-Node.
I looked at the code and have figured out how to add a filebrowser. What I can not figure out is how to get the path from the file browser for use in the code.
1 Answer
That is actually very simple because I developed a system to simplify tasks like this one.
You just have to call the invokePathChooser function in your drawing code and give it a callback (the name of the function that handles the result). AN will do the rest for your.
class MyNode(...):
# ...
def draw(self, layout):
self.invokePathChooser(layout, "setFilepath", text = "Find File")
def setFilepath(self, path):
print(path)
-
$\begingroup$ So how can I get the path? I can print the variable, how can I use it in other functions? $\endgroup$ Apr 25, 2016 at 12:31
-
$\begingroup$ Well you can do whatever you want with the path in the 'setFilepath' function. Maybe you want to store the path inside the node? For that you have to create a StringProperty... $\endgroup$ Apr 25, 2016 at 14:14