Hello. For a long time I wanted to create something by Python in Houdini, and I saw an interesting work in one of Cinema 4D groups in Telegram (https://t.me/learning_xpresso) - the Rubik snake toy, I really liked it and wanted to do something like that.
How it works: here, each element affects the others (FK), but I need to consider the possibility of switching the direction of FK since collecting everything in one direction only will be very inconvenient. To create FK, I used a CHOP network in which I switched between parents using a button (when you click on the button, the offset for the new parent is updated first, then switch nodes are switched).
Using Python, I made copying for a group of nodes and automatically registered paths for parents in CHOP, made a Clear button(delete nodes with a rig) and an Import button (for easy saving)
The algorithm of work with the toy:
- select the element size and the length of the snake (number of elements) and click the Create button - the entire rig will be created automatically (after creating the rig, changing the number of modules will not affect the created rig in any way). Pressing the Create button again will offer to delete the created rig and create it again with the specified number of modules;
- controllers have only one degree of freedom;
- the Change FK direction button changes the direction of forward kinematic;
- Clear button - will delete the created rig and Import button - will make a separate geo node in the same hip file with object merge node in which there will be only toy geometry (merge geometry from all modules);
- the color of the toy can be changed at any time before Import.

The Point only switch allows you to export points with the orient attribute to create your own modules. With the import of points, a node is created with the bounding geometry of one module.






This is not an hda, all Python code is located in the hou.session module. This is the first thing I did with rigging and Python, so I will be glad to any hints or adjustments as it could be made easier, more convenient or more correct.