1
$\begingroup$

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.

$\endgroup$
0
$\begingroup$

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)
$\endgroup$
  • $\begingroup$ So how can I get the path? I can print the variable, how can I use it in other functions? $\endgroup$ – schustudrai Apr 25 '16 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$ – Jacques Lucke Apr 25 '16 at 14:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.