2
$\begingroup$

This might be a bit of a weird one, but I'm looking to write a Python node that will, upon a user's input of a folder path, replace itself with a node group that contains itself and other nodes based on the contents of the folder. I'm trying to perform this transformation:

MyNode

User inputs folder path

MyNodeGroup:
    MyNode
    Other Nodes

Is this possible?

I imagine I'd have to create and instance the group immediately, then move my node into it along with any other new nodes that I need. If it's not possible to move an existing node into a group, could I create an identical node and then delete the old?

Any advice on this problem is greatly appreciated!

Edit: Or, if groups are not the most appropriate mechanism for this, is it possible to maintain other nodes inside my node internally?

$\endgroup$
  • $\begingroup$ Not sure that replacing the node is the way to go but you can customise the contents of a node. In blenders text editor goto Templates->Python->Custom nodes. Also see the chosen answer to this question. Another option would be an addon that creates a panel in the toolbar where the user chooses the folder and clicks generate. (look at the node wrangler addon) $\endgroup$ – sambler Mar 27 '14 at 2:56
1
$\begingroup$

You can probably write a script that generates such node setup after being given a file path. Use the single selected node to read its inputs and outputs, then delete it by the script and attach generated nodes' IO to what you read.

$\endgroup$

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.