how to specify file directory in Python in Houdini in Mac OS

   5258   2   0
User Avatar
Member
479 posts
Joined: Dec. 2009
Offline
How to specify the directory of a file in a Python type operator in Houdini which is running on Mac OS system? Is it the same as in Windows system?

e.g. I want to write Python script in a Python type operator to export certain attribute of all the primitives to a text file, then what is the Python code to write this list of attribute values to a specific text file within a specific folder on the harddisk of a Mac computer?

Thanks!
User Avatar
Member
1926 posts
Joined: Nov. 2006
Offline
It's no different on any operating system. You just open a file path to write to, write the data and close it.

You can also just create a file parameter on your SOP to point to where you want the file to be and then use that to get the path.

filepath = hou.pwd().evalParm(“file”)
f = open(filepath, “w”)

f.write(your data)
f.close()
Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
479 posts
Joined: Dec. 2009
Offline
Dear graham, Thank you very much for your kind help!

will try later according to your suggestion.


graham
It's no different on any operating system. You just open a file path to write to, write the data and close it.

You can also just create a file parameter on your SOP to point to where you want the file to be and then use that to get the path.

filepath = hou.pwd().evalParm(“file”)
f = open(filepath, “w”)

f.write(your data)
f.close()
  • Quick Links