[Sidefx-houdini-list] [python] hou.session persistence

Simon Kapeniak szymon.kapeniak at gmail.com
Thu Dec 4 15:48:05 EST 2008


Thank you Graham, this might be an option. String repr. is a kinda
limitation, but for what purpose we have pickles anyway ;).

I'm not saving anything huge. I'm modifying scene with external hython
session and I'd like to give it some tips about current state of a scene
which are not saved in a hip file. Just didn't want to bother with saving it
in file.

2008/12/4 Graham Thompson <captainhammy at gmail.com>

> Depending on what it is exactly you are attempting to store in the module
> you might be able to take advantage of
> functions dealing with the Session Module Source, which is what you see
> when
> you open up the editor.
>
> For example if you have a giant list or dictionary or something that you
> use
> use elsewhere in code and want to save in the module source you can use use
> hou.appendSessionModuleSource() to add things that can be represented as
> strings to the module code.
>
> For example:
>
> >>> the_list = range(10)
> >>> dir(hou.session)
> ['__builtins__', '__doc__', '__file__', '__name__', 'hou']
> >>> hou.appendSessionModuleSource('the_list = ' + repr(the_list))
> >>> dir(hou.session)
> ['__builtins__', '__doc__', '__file__', '__name__', 'hou', 'the_list']
> >>> hou.session.the_list
> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]�
>
> If you open up the editor you now see the code necessary to create that
> list.
>
> This does have issues however since you can only really store objects that
> can be expressed as a string to recreate them.
>
>
> On Thu, Dec 4, 2008 at 9:04 AM, Andrew D Lyons <tstexture at gmail.com>
> wrote:
>
> > That might be a python reference artifact. Depending on where you are
> > creating your object you may just be getting a shallow copy to your
> > hou.session module. Take a look at the deepcopy module in python:
> > http://www.python.org/doc/2.5.2/lib/module-copy.html
> >
> > Perrhaps you might monkey patch the hou module using 123.py . With
> > that done you can read/write to disk python objects.
> > http://en.wikipedia.org/wiki/Monkey_patch
> >
> > Cheers
> >
> >
> >
> >
> > 2008/12/4 Simon Kapeniak <szymon.kapeniak at gmail.com>:
> > > Yes, and I deal with a same *file but different sessions.  This is what
> I
> > > know from H9.0. But if so, why Python Source Editor refers to this
> module
> > > and successfully saves object across sessions of one hip file, while
> > scripts
> > > commands can't do the same thing although those scripts see perfectly
> > > objects saved in hou.session via PSE... this is weird, isn't it?
> > >
> > > 2008/12/4 Alvaro Castaneda <varomix at gmail.com>
> > >
> > >> the session module is just for the current file and that how it
> supposed
> > to
> > >> work
> > >> there a master class on python at sidefx.com they talk in-depth about
> > all
> > >> this, check it out
> > >>
> > >>
> > >> On Fri, Dec 5, 2008 at 7:33 AM, Simon Kapeniak <
> > szymon.kapeniak at gmail.com
> > >> >wrote:
> > >>
> > >> > Hello All,
> > >> > does anybody know why if I use Python Source Editor (PSE)  to save
> > >> objects
> > >> > in hou.session, it's saved in a hip file, while doing the same thing
> > from
> > >> a
> > >> > script (like Shelf Tool) doesn't work. I can test in texport:
> > >> > dir(hou.session), and my objects exists, but if they are not saved
> by
> > >> hand
> > >> > in PSE, I'm loosing it in a next session. Is it expected behavior?
> Do
> > we
> > >> > need this inconsistence?
> > >> > _______________________________________________
> > >> > Sidefx-houdini-list mailing list
> > >> > Sidefx-houdini-list at sidefx.com
> > >> > https://lists.sidefx.com:443/mailman/listinfo/sidefx-houdini-list
> > >> >
> > >>
> > >>
> > >>
> > >> --
> > >> varomix DaGreit
> > >>
> > >> intelia_animate
> > >> www.intelianimate.com
> > >> _______________________________________________
> > >> 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
> > =======================================
> > _______________________________________________
> > 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
>


More information about the Sidefx-houdini-list mailing list