Jump to content

hou.hipFile.save problems - need help


danielsweeney

Recommended Posts

Hi Everyone,

Hope you are all well. We have not been using houdini long. We are long time soft users and we are testing out software to move too and see the strengths of them. Houdini is our first choice for the sheer scope of it, so we have started looking at this first. Anyways, explaination of the problem below.

 

I am trying to script a "simple" saving function through a HDA via Python (I dont know if this is a correct way of doing it, so please If I am going in the wrong direction, shout) it will create a few folders based on some parameters in the HDA interface and save the file with the name specified. I am setting environment variables through this and using that to generate the path for the file save and also will hopefully re-use the Environment variables later for ROP output ETC for the scene.

I am running into an error with what I believe is to do with the hou.hipFile.save function. I have not been coding for very long either so please bare with me if my Termanology is off also.

I have attached some code snippets.

I am basically trying to save the files to a structured job folder system. something like below.

$JOB/scene/[WORKCATAGORY]/[SHOTFOLDER]/SHOTNAME.hipnc

 

I have defined some functions in the Python Module in the HDA, and these are being called by the callback script on each parameter. 

It is really weird, It has worked once or twice. But then I try to save again and it does not work again.

I did some debugging and the Error that houdini generates, it definately works when I take out the SHOTFOLDER in the string for the path to save to. If my file path is just saved in the WORKCATAGORY section it saves. 

 

My defined functions (sorry code is messy)

def shotName(parm):
    hou.putenv("SHOTNAME", parm)
    test = parm
    print test
    
def folderName(parm):
    fname = "NN_" + parm
    hou.putenv("FOLDERNAME", fname)
    test = fname
    print test

def workCatagory(node, parm):
    a = hou.parm(parm.path()).eval()
    labelName = hou.parm(parm.path()).menuLabels()[a]
    testA = parm
    hou.putenv("WORKCATAGORY", labelName)
    print labelName
    
    
    
    

def customSave():
    #Pull in Enviroment Variables    
    work = hou.getenv("WORKCATAGORY")
    shot = hou.getenv("SHOTNAME")
    folder = hou.getenv("FOLDERNAME")
    
    # Houdini save path FULL
    savePath = "$JOB/scene/" + work + "/" + folder + "/" + shot + ".hipnc"
    
    # Houdini save path with a job catagory but not job name folder
    #savePath = "$JOB/scene/" + work + "/" + shot + ".hipnc"
    
    exSavePath = hou.expandString(savePath)
    exSavePath = exSavePath.replace('//', '/')
    #hou.putenv("SAVEPATH", exSavePath )
    hou.hipFile.save(exSavePath, False)
    
    print exSavePath

 

 

the error it generates is

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "opdef:/Object/Northforge3_testa?PythonModule", line 40, in customSave
  File "C:/PROGRA~1/SIDEEF~1/HOUDIN~1.600/houdini/python2.7libs\houpythonportion.py", line 1287, in decorator
    return func(*args, **kwargs)
  File "C:/PROGRA~1/SIDEEF~1/HOUDIN~1.600/houdini/python2.7libs\hou.py", line 28330, in save
    return _hou.hipFile_save(*args, **kwargs)
OperationFailed: The attempted operation failed.
Error creating file: W:/Work/Development/D00026_Houdini_test/3.3d/D00026_Houdini_test_HOUDINI/scene/rend/NN_test/test.hipnc

 

working enviroment is.

Windows 10

Houdini Apprentice 16.0

saving to a NAS drive

I hope some of that makes sense. Cheers

 

Link to comment
Share on other sites

  • Make sure the path is writeable
  • Do not concatenate path strings manually, use os.path.join
  • Maybe Houdini has a hard time writing to NAS drive. A quick workaround: save to a temp file, and then copy the file with Python (shutil module)
Link to comment
Share on other sites

Hi Stalker.

Thanks for the reply. much appreciated

I Took your advice on using the os.path.join. Works well and of course is the correct way to do it. But I was still getting the problem though. Found out it was down to creating the whole path that was the problem for some reason. So I broke up creating the work category and the whole file path. like

#create work catagory folder
    if os.path.exists(exWorkCatagPath) == False:
        os.mkdir(exWorkCatagPath)
    else:
        printMe = "no Directory created!!"
        print printMe
    
    
    # save full file
    hou.hipFile.save(exSavePath, False)

But I do have another question. As I am creating the variables for this like below.

hou.putenv("FOLDERNAME", fname)

It is storing this in an environment variable I believe. Which I think might not be the best option. Is their anyway I can store these variables in the HIP file so I can pull them into other areas like ROPS for instance via $FOLDERNAME. a Local variable that is only available in the hip file that has been saved.

Thanks for your help again.

 

Daniel

Link to comment
Share on other sites

I am only asking as when reloading the scene. Either the variable is not there anymore or it does not reflect the information that is sitting in the HDA.

 

So I need a way for that Data to stay within the HIP file so when it is re opened the Global data for that file in still available.

Any ideas?

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...