Skip to main content

HPaste

Ω HPaste is a small and usefull utility that makes exchange of node snippets really easy and fast. You can send them directly through any text messaging application
when you add the plugin to you project, a new shelf HPaste will become available:
It has some buttons, but the most usefull are HCopyWeb and HPasteWeb.
When you select some nodes in the node editor and press HCopyWeb - a link appear in your system clipboard, and you can paste it into any messenger as text. It looks kinda like this:
8BIQqJvciteWgQNx@WePaste
Then anyone who sees this link can select it, copy it to his system clipboard and press HPasteWeb button in houdini, that will create the whole same node structure that the sender selected, with all animations, channels, expressions and connections! Note that received nodes will be pasted into currently active Node Editor window.

If current Node Editor window shows different context from what the sender sent (for ex. OBJ, when sender copied SOP nodes) - the receiver will be prompted about correct context, and no nodes will be pasted.



You can use it for free forever, any suggestions, bug reports or any other help is welcome
the plugin together with it's installation instructions you will find on the github page: https://github.com/pedohorse/hpaste

How does it work

Now let's dive under the hood how it works.

  • The core of nodes serialization is based on a hou functions saveItemsToFile and loadItemsFromFile, that became available in Houdini16, but has a fallback to saveChildrenToFile and loadChildrenFromFile for previous versions of houdini that do ALMOST the same job in general.
  • Generated serialized code is then compressed with bzip and converted into url safe base64 to be safely stored in any text-based storage, such as url, or ascii text message
  • Code is passed to a web plugin that returns a short url that he can decrypt back into the code, and that you can paste into a messenger to share with someone

Shelf buttons HCopy and HPaste operate the same way as HCopyWeb and HPasteWeb, but directly with processed code, not short urls. You can work with this code directly without using web versions of buttons if you wish so, but the code tend to be pretty big and clumsy, bigger then most messengers' maximum message size allows, that makes it very hard to exchange these kind of raw snippets

So that's where web plugins come in.

web plugins

folder hpastewebplugins is scanned for modules that contain classes derived from WebClipBoardBase, all classes are loaded and stored for use.
the main abstract methods there are webPackData and webUnpackData. webPackData one should be able to receive ascii string and return a short url that identifies it, and that can be passed to webUnpackData that will convert it to the exact same data that was passed to the first method. so:
webUnpackData(webPackData(string))==string  (1)
The HPaste picks one of the plugin (based generally on network speed),cuts it up based on the value of maxStringLength() method, that the plugin must also define, cuts the compressed serialized ascii nodes code into pieces that fit into maxStringLength value, feeds each part to webPackData (in general parts can be of different size and each part can be going to different plugin) that returns web id that is appended with @pluginName string concatinated with all other parts with # symbol, so in general the final link would look like:
randomid1@plugin1#randomid2@plugin2#randomid3@plugin3
And the receiving part of the plugin does the same in reverse: splits that url above by # into parts, detects each part's plugin by @plugin, and feeds randomid to corresponding plugin's webUnpackData method, then concatenates all the parts, debase64 it, decompresses it and feeds into houdini. And it is that simple!


So and what exactly methods webPackData and webUnpackData do - is totally up to programmer as long as condition (1) is met, and result of webPackData is a string that consists only from url-safe ascii symbols, WITHOUT @ and # symbols.
All current plugins use some kind of online clipboard now to save the long code, so beware - theoretically your pasted code is public, and it's lifetime is up to the hosting site

If you want to implement your own plugin - you just need to implement 4 methods:
webPackData(str) -> str 
webUnpackData(str) -> str 
maxStringLength() -> int  
speedClass() -> int
first 3 we have already talked about, the last one should return integer of range 0-9 representing a priority of use. HPaste will sort plugins according to this priority level, and randomly choose a plugin from the highest priority list, if all of them fail - HPaste will fall back to the next priority, and so on, until no plugins are left.

Inherit WebClipBoardBase class and implement those methods, put that py file into hpastewebplugins folder, your new plugin will be added to list on houdini restart, or hpaste.hpastewebplugins.rescanPlugins() method called (which you can call manually, when testing/debugging your plugin)

In examples folder you will find an example plugin that saves serialized code to a local network drive, that can be used inside company network, and inaccessable from outside even if someone has an id of the snippet.


P.S.

There is a lot of stuff to work on and improve still, like for example if you are trying to copy a huuge scene, or your network is reeally slow, or just the plugin's servers are laggy at the moment - the upload is synchronous, so you will be just sitting there, watching the waiting cursor, not able to work until your code is finally uploaded or timeout occurred. That can easily be solved with asynchronous upload, that i just need time to implement.
So support and contribute if you like the idea!