hou.allowEnvironmentToOverwriteVariable works on JOB only

   4142   7   0
User Avatar
Member
11 posts
Joined: June 2008
Offline
Hi all,

Does anybody know why
hou.allowEnvironmentToOverwriteVariable works on $JOB only?
And not for any other variables…
User Avatar
Staff
4445 posts
Joined: July 2005
Offline
hou.allowEnvironmentToOverwriteVariable is designed to provide a very specific capability of allowing values set in the environment to take precedence over similar values stored in a hip file. That being said, it should work for any global variable saved into a hip file (look for set -g commands in your hip file in your favorite text editor to see what is saved in a particular file).

What exactly are you doing that makes you say this function only works for $JOB?

Thanks,
Mark
User Avatar
Member
11 posts
Joined: June 2008
Offline
A few variables defined in my scene files (JOB, WORK, PRJ, RENDER, and so…), it's all about paths…
Unfortunately since certain time - my disk path had been changed, and i have to manualy update every variable in every scene…
I tried to use subj to automatically replace all that variables - using script like this:
hou.allowEnvironmentToOverwriteVariable(“JOB”,True)
hou.allowEnvironmentToOverwriteVariable(“PRJ”,True)
hou.allowEnvironmentToOverwriteVariable(“PROJECTS”,True)
hou.allowEnvironmentToOverwriteVariable(“LIBRARY”,True)

and then load the scene, but only JOB variable updating from system environment variable (i tried to start shell from houdini to check that system variables PRJ, LIBRARY etc… is set properly. Everything is ok.) - but the scene PRJ, LIBRARY are remain their old values)
User Avatar
Staff
4445 posts
Joined: July 2005
Offline
This worked fine for me. I opened a fresh Houdini. In the hscript textport I did “set -g FOO=BAR”. Then saved the hip file to vars.hip. Then I closed Houdini.

Next in a shell I did “export FOO=BLAH; houdini &” to start Houdini again. In a python shell I did “hou.allowEnvironmentToOverwriteVariable('FOO',True)”. Then I loaded vars.hip. In a textport I did “echo $FOO”, and it said “BLAH” indicating it was using the value from the system environment rather than the value form the hip file.

So I'm pretty confident this function is working as designed… Did your procedure differ from the above steps at all?

Mark
User Avatar
Member
11 posts
Joined: June 2008
Offline
Nope, doesn't working.
I tryed to do exactly the same thing, and after i do hou.allowEnvironmentToOverwriteVariable('FOO',True), and load the scene, FOO is switched back to “BAR” (while in system the FOO is “BLAH”)
User Avatar
Member
11 posts
Joined: June 2008
Offline
Finally i found out the difference between your and my approaches…
It won't update the variable from system if variable had been defined before i load the scene… Even if it has same value as system has…

But if there no such variable before we load the scene - it updates successfully.

In my case all project variables are set before any scenes loading (in order to set right variables for newly created scenes) - thus they not updated from the system ones

Excepting the $JOB - it updates anyway.
User Avatar
Staff
4445 posts
Joined: July 2005
Offline
I'm still not clear on how you are setting your variable values… I set them in the shell prior to launching Houdini. You say your variables are “set before any scenes loading”, but that doesn't tell me how they are being set or why they would behave differently than what I was doing. Apologies if I'm missing something obvious.

Another approach you could take would be to set the variable values in 456.cmd or 456.py which are scripts that get run after loading a hip file. Then it doesn't matter what the hip file says the variables are, you could just overwrite the values.

Mark
User Avatar
Member
11 posts
Joined: June 2008
Offline
Okey )
For the test i had set the SYSTEM variable FOO - to “BLAH”, and started houdini all from command shell. I have a scene - with variable FOO (set to “BAR”). If i do hou.allow….. (“FOO”, True) and then load the scene - the FOO variable in the scene set to “BLAH” - everything is ok!
But if before loading the scene, i create variable FOO in houdini (with “BLAH” or anything else) - and then do hou.allow….. (“FOO”, True) and then load the scene - the FOO in scene remains it's old value (“BAR”), not the SYSTEM variable value.

In my setup i have a .py script that loading in empty houdini and sets all the project variables (from system ones) - this necessary then i want to start new empty scene (to set all project variables). So - every time houdini starts - it have all variables are set and up to date. But some old scenes has its own values in that variables - and i cannot override it with hou.allow…. because of that peculiarity (if variable set in houdini before i will load the scene - the houdini wouldnt check the system variable value for it)
  • Quick Links