2

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?

David
  • 49,291
  • 38
  • 159
  • 317
cdbfoster
  • 121
  • 1
  • 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) – sambler Mar 27 '14 at 02:56

1 Answers1

1

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.

Oskar Świerad
  • 584
  • 3
  • 10