Jump to content
saca

python date

Recommended Posts

 

hi,
I have set deadline Job-Name by python script, from $HIPNAME and "python-date". 
Some Output(ROP) are executed into dependencies.
so the "date" strings are changing on ROP by ROP because the submitting needs some seconds.
of course we can use minute, but the submitting needs over one minutes, the batch group is split some groups.

*)bad example, splitted some batch-groups

<s001_001_Fx_fire_v001.hip  [2021-07-09 15:23:48.642000]>
|-s001_001_Fx_fire_v001.hip/out/abc/vdb_rocks
<s001_001_Fx_fire_v001.hip  [2021-07-09 15:23:49.343000]>
|-s001_001_Fx_fire_v001.hip/out/vdb/vdb_fire
<s001_001_Fx_fire_v001.hip  [2021-07-09 15:24:03.132000]>
|-s001_001_Fx_fire_v001.hip/out/ass/Ar_fire
|-s001_001_Fx_fire_v001.hip -Arnold- /out/ass/Ar_fire

*)the case I want

<s001_001_Fx_fire_v001.hip  [2021-07-09 15:23:48.642000]>
|-s001_001_Fx_fire_v001.hip/out/abc/vdb_rocks
|-s001_001_Fx_fire_v001.hip/out/vdb/vdb_fire
|-s001_001_Fx_fire_v001.hip/out/ass/Ar_fire
|-s001_001_Fx_fire_v001.hip -Arnold- /out/ass/Ar_fire

*)the python code

import datetime
hipFile=hou.expandString("$HIPNAME")
dt=str(datetime.datetime.now())

return (hipFile + '.hip [' + dt + ']')


do you have any good idea to being one batch group names from date?

like that the way store value other variables, i do not know it in houdini.


thanks.

Share this post


Link to post
Share on other sites

You probably want to store the time in a previous node, that does not "recook" between your outputs
you can use a detail (global) variable for that, if you need code reference for that, look for:

hou.node
and
hou.geometry

in the documentation

then you can reference this stored value in your rop nodes, that should not change, unless you change the input, above the node that stores the time.

Share this post


Link to post
Share on other sites
Posted (edited)

very thanks your idea.
i will try and report some days later.

 

Edited by saca

Share this post


Link to post
Share on other sites

I have a related problem...

I'm making an HDA to do an OpenGL render, then composite the result of that with some details, like shot name etc and I want to add the date and time the render was started, then finally spit out an mp4.

So my setup is using a TOPnet to do the OpenGL render, then the COPs one and then FFMPEG the result...

I thought I had it working by using a prerender script in the OpenGL ROP that set the comment field on itself, then I can reference that with a font COP. It was working while I was testing but if I run it through TOPs it comes out blank.

I've changed it for now so that the timestamp is live - I've put an expression on the comment field itself and am referencing that but of course if the render takes more than a minute the value increments... It's not a big deal but I'd like to figure out how to set the timestamp from when the render is started.

 

this is what I set on the Pre Render Script parm of the OpenGL ROP - it works in my session but not through TOPs:

from datetime import datetime
now = datetime.now()
date_str = now.strftime("%d/%m/%Y")
time_str = now.strftime("%H:%M")

now_str = "date : " + date_str + "   time : " + time_str

rop = hou.pwd()
rop.parm('vm_image_comment').set(now_str)

return 1

so now I have this script on the comment field instead :

from datetime import datetime
now = datetime.now()
date_str = now.strftime("%d/%m/%Y")
time_str = now.strftime("%H:%M")

now_str = "date : " + date_str + "   time : " + time_str

return now_str

which works but the time ticks up as the render progresses

 

Thanks for reading

Share this post


Link to post
Share on other sites

In case it's of use to anyone I got round this by making a null with 2 string parms, one called 'now' with an expression as above and one called 'snapshot'. I put a callback on the TOPs cook button to set 'snapshot' using the value on 'now' and reference that in my font COP.

So it just gets set the once at the start of cooking and so doesn't tick up...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×