Jump to content

How do i get Houdini to display Time and Date in font sop


samesami

Recommended Posts

I  have  a sample  scene for Houdini to get the time and date using python and display it using font sop but it's now working. I will be grateful if somebody can help me.

 

Thanks

node = hou.pwd()
geo = node.geometry()

# Add code to modify contents of geo.
# Use drop down menu to select examples.

import datetime
import hou

# Get the current system time
current_time = datetime.datetime.now()

# Convert the datetime object to a string
time_string = current_time.strftime("%Y-%m-%d %H:%M:%S.%f")

point = geo.createPoint()

current_time_attrib = point.addAttrib(hou.attribType.Point, "current_time", 0.0)


point.setAttribValue(current_time_attrib, time_string)

 

Get_OS_Time.hipnc

Link to comment
Share on other sites

1-  addAttrib is a method of geo, not point

2- since you are referencing a detail attrib in the font sop you want to use a detail attrib which is attrib type Global ( lines 19 and 22 in python sop)

3- with the addAttrib functions, the default value tells you what flavor of attrib ( int, float string etc) so a string attrib needs a default string, in this case ""

4- you get a string from a detail attrib with the details() expression not detail() ( in the font sop)

5- also in the font sop you referenced the attrib by the wrong name, the variable in the python code is "current_time_attrib" but you named the attrib simply "current_time"

 

Hope this helps!
-jb

pythontime.JPG

  • Thanks 1
Link to comment
Share on other sites

2 hours ago, lugnut said:

1-  addAttrib is a method of geo, not point

2- since you are referencing a detail attrib in the font sop you want to use a detail attrib which is attrib type Global ( lines 19 and 22 in python sop)

3- with the addAttrib functions, the default value tells you what flavor of attrib ( int, float string etc) so a string attrib needs a default string, in this case ""

4- you get a string from a detail attrib with the details() expression not detail() ( in the font sop)

5- also in the font sop you referenced the attrib by the wrong name, the variable in the python code is "current_time_attrib" but you named the attrib simply "current_time"

 

Hope this helps!
-jb

pythontime.JPG

 

Thank you for your help.

  • Like 1
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...