# Python node that replaces itself in the editor with a group?

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?

• 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 2:56