[Sidefx-houdini-list] Save hou.session.listX with hip file

Andrew Lyons tstexture at gmail.com
Sun Apr 8 16:57:31 EDT 2012


Yep. This is the way to go if you *have* to store data in the hipfile.

The SESI docs:
http://www.sidefx.com/docs/houdini12.0/hom/nodeuserdata

Cheers

On 8 April 2012 13:54, Graham Thompson <captainhammy at gmail.com> wrote:
> There is no direct way to store a Python object in a hip file: it
> needs to be serialized to a string that can be stored somewhere.  As
> Lars mentioned, you basically need to save the dictionary as a string
> and store that representative string somewhere (eg. user data or a
> string parameter).
>
> As Andrew also posted with that link to the module from my site, you
> can see an example of storing a data structure in node data and then
> reconstructing it.  This is more complex than the repr/eval method
> that Lars posted, however depending on the size and complexity of the
> data you need to store, it can be much faster and will deal with more
> advanced data types better.
>
> def writeToUserData(node, user_data_name, data):
>    """ Store a data structure in a node's user data dictionary.
>
>        The structure to be stored must support pickling.
>    """
>    node.setUserData(user_data_name, cPickle.dumps(data))
>
>
> def readFromUserData(node, user_data_name):
>    """ Read a data structure stored in a node's user data dictionary. """
>    return cPickle.loads(node.userData(user_data_name))
>
> On Sun, Apr 8, 2012 at 12:20 PM, Nick van Zutphen <nvanzutphen at live.com> wrote:
>> That sounds very clever, but am I right that userdata is limited to strings? Unfortunately I would like to store a rather complicated dictionary.
>> I'm building an automatic node color system which can be fully configured by an .otl. In its core it works perfectly, how ever it still depends on a file on disk which is loaded into hou.session. This limits per file color adjustments, I'm eigher  to get that working. The task at hand is rather simple in its description:
>>
>> How do I save an dictionary with an .hip file?
>>
>> Be Nick, be Nimble
>> ----
>> http://www.nickvanzutphen.com/ngtl
>>
>>
>>
>>
>> On Apr 8, 2012, at 7:57 PM, Graham Thompson wrote:
>>
>>> Can you not just store all your data on the root node ('/')?
>>>
>>> On Sun, Apr 8, 2012 at 11:50 AM, Nick van Zutphen <nvanzutphen at live.com> wrote:
>>>> Maybe I should be a bit more specific, this data needs to be available to onCreate.py. I guess node specific data isn't?
>>>>
>>>> Cheers,
>>>>
>>>> Be Nick, be Nimble
>>>> ----
>>>> http://www.nickvanzutphen.com/ngtl
>>>>
>>>>
>>>>
>>>>
>>>> On Apr 8, 2012, at 7:28 PM, Graham Thompson wrote:
>>>>
>>>>> The best way to save data is to use node user data:
>>>>> http://www.sidefx.com/docs/houdini12.0/hom/nodeuserdata
>>>>>
>>>>> On Sun, Apr 8, 2012 at 11:11 AM, Nick van Zutphen <nvanzutphen at live.com> wrote:
>>>>>> Hi!
>>>>>>
>>>>>> I just discovered that hou.session is not saved with the hip file :-(. I would like to store a dictionairy or a list for simplicities sake, which is accessible by scripts and saved with the hip file.
>>>>>> I discovered: hou.appendSessionModuleSource, but its not totally clear what its proper usage is. Any suggestions?
>>>>>>
>>>>>> Be Nick, be Nimble
>>>>>> ----
>>>>>> http://www.nickvanzutphen.com/ngtl
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> Sidefx-houdini-list mailing list
>>>>>> Sidefx-houdini-list at sidefx.com
>>>>>> https://lists.sidefx.com:443/mailman/listinfo/sidefx-houdini-list
>>>>> _______________________________________________
>>>>> Sidefx-houdini-list mailing list
>>>>> Sidefx-houdini-list at sidefx.com
>>>>> https://lists.sidefx.com:443/mailman/listinfo/sidefx-houdini-list
>>>>>
>>>>
>>>> _______________________________________________
>>>> Sidefx-houdini-list mailing list
>>>> Sidefx-houdini-list at sidefx.com
>>>> https://lists.sidefx.com:443/mailman/listinfo/sidefx-houdini-list
>>> _______________________________________________
>>> Sidefx-houdini-list mailing list
>>> Sidefx-houdini-list at sidefx.com
>>> https://lists.sidefx.com:443/mailman/listinfo/sidefx-houdini-list
>>>
>>
>> _______________________________________________
>> Sidefx-houdini-list mailing list
>> Sidefx-houdini-list at sidefx.com
>> https://lists.sidefx.com:443/mailman/listinfo/sidefx-houdini-list
> _______________________________________________
> Sidefx-houdini-list mailing list
> Sidefx-houdini-list at sidefx.com
> https://lists.sidefx.com:443/mailman/listinfo/sidefx-houdini-list



-- 
=======================================
Andrew D Lyons | Digital Artist | http://www.tstex.com
=======================================



More information about the Sidefx-houdini-list mailing list