samesami Posted September 18, 2023 Share Posted September 18, 2023 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 Quote Link to comment Share on other sites More sharing options...
lugnut Posted September 19, 2023 Share Posted September 19, 2023 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 1 Quote Link to comment Share on other sites More sharing options...
samesami Posted September 19, 2023 Author Share Posted September 19, 2023 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 Thank you for your help. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.