[Sidefx-houdini-list] String manipulation

ken ken at corefa.com
Thu May 31 14:48:32 EDT 2007


nope.

FYI --> there are other ways to do string manipulation with "rindex, 
index, strlen, substr and strreplace", but your example works.

I've done things like this:

in my HDA I put an eventScript --> Before First Create
exread opdef:/$arg1?filePath.expr

that filePath.expr is a 'section' of my HDA so it travels with it no 
matter what

Then I can call on the expression to do my dirty work.

`filePath(chs(imagepath_1),chs(frame_1))`

here's the filePath.expr

string
filePath(string rest_string, float frame) {
 
    string directoryName = substr(rest_string,0,rindex(rest_string,"/")+1);
    string fileName = 
substr(rest_string,rindex(rest_string,"/")+1,strlen(rest_string));
    string baseFileName = substr(fileName,0,index(fileName,"."));
    string extFileName = 
substr(fileName,rindex(fileName,".")+1,strlen(fileName));
    string imgPath = directoryName + baseFileName + "." + frame + "." + 
extFileName;

    return imgPath;
}


I know this is the same as your above case, but I had to use the 
expression language here as doing this all in on normal expression 
resulted in it not working :(

The above just really cut it up and allowed me to reconstruct the 
filePath with my own increment. It was one of things I had to do for 
assetManagement and ease of use for the user.. long story.. so I'll stop 
now.

-k

jordibares 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