Jump to content

python date


saca

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.

Link to comment
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.

Link to comment
Share on other sites

  • 2 weeks later...

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

Link to comment
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...

Link to comment
Share on other sites

  • 2 months later...

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

Add the content you want to preprocess to "preCode" string widget and
add "My_Submit" button instead of the standard "(Deadline)Submit" button.
If you hide the standard "Submit" button, you can use it as same.

in this way set date-time at once.2021-10-04_14h37_49.thumb.png.3fa92a8c2a09bd8d1954a3a9ac403774.png

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