[Sidefx-houdini-list] String manipulation

Peter Bowmar pbowmar at gmail.com
Thu May 31 14:44:27 EDT 2007

I and others have written a variety of custom expressions that do
things like this. So for example, what you want would be, as a custom

string strip_suffix(string orig; string sepchar)
    string returnme = orig;

    float lastSep = rindex(orig, sepchar);

    if ( lastSep >= 0 )
        returnme = substr(orig,0,lastSep);

    return returnme;

Now you can just use `strip_suffix($HIPNAME,".")`

I have a lot of little things like this, as do most people. You just
keep adding them to your facility's shop-wide Houdini install. Sadly,
that's not super easy since there is no easy way to load custom
expressions. We use something in 456.cmd that scans a directory and
loads all the files with .func on the end using the "exread" command.

This stuff will be easier in 9 when Python is integrated that's for sure!


Peter B

On 31/05/07, jordibares <jordibares at the-mill.com> wrote:
> Hi all, I am trying using $HIPNAME and $OS to build the actual output name
> of my sequence but I need $HIPNAME to return the name without the extension.
> Intead of
> > myscene.hip
> I need
> > myscene
> I had a look at the expression documentation and managed to do it by running
> this
> > Echo `substr($HIPNAME, 0, strlen($HIPNAME)-4)`
> But I was wondering if there is another way as this seems too convoluted for
> something that at first seem very very necessary.
> May be like in the csh
> > Echo $HIPNAME:r  ? ????
> Thanks in advance
> Jb
> PS. Can¹t wait to have python inside houdini...
> _______________________________________________
> 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