Jump to content

(SOLVED) Create a variable based off of $HIP?


Recommended Posts

I want to create a variable called $CACHE that copies the $HIP path but replaces the drive letter from C: to X:. I know I can set variables in the environment file but I'm not sure how to do it for this or even if that's the right way.

 

Any help would be appreciated.

Edited by chase2110
solved
Link to comment
Share on other sites

I figured it out. Just posting in case anyone else is trying to do something like this.

I created a file called 456.py and placed it in in my $HOUDINI_USER_PREF_DIR in a folder called scripts. This file gets run every time houdini opens a .hip file. Inside the file I used this as my code:

import re

CACHE = str(hou.expandString('$HIP'))
CACHE = re.sub('\AC:|D:', 'X:', CACHE, 1)
hou.hscript('setenv -s CACHE=%s'%(CACHE))

It copies the hip path

Searches the beginning for C: or D: and replaces it with X: 

Then sets the environment variable.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...