File SOP Write Path based on File SOP Read Path

   4976   3   1
User Avatar
Member
102 posts
Joined: 5月 2006
Offline
Hi guys,
I need some help but it is a bit hard to explain:

So I'm using a FileSOP to read an .FBX file then I do a bunch of changes to the geometry and then I'm using another FileSOP to write the changed geometry to an .OBJ file named as the original plus a suffix, in a subfolder of the original path.

Since I need to do this many many times I'm looking for a way to automatically set the write path based on the path from the read file sop but in a sub-folder, add a suffix to the filename and change the extension from .fbx to .obj.

Don't know to what extend file paths can be manipulated using script in Houdini but hopefully there's a way to do this.

Thanks a bunch,
-Adrian
User Avatar
Member
238 posts
Joined: 11月 2013
Offline
Guess Python Expression would be suitable for that
http://www.sekowfx.com [www.sekowfx.com]
User Avatar
Member
238 posts
Joined: 11月 2013
Offline
must say that I love Houdini for that:

set the expression language to python on a rop geomtry sop.
klick into the output parameter field, set a keyframe and pres alt+e
paste following code, change the channel reference

hope that helps


# python
path = ch(“../pathToYourFileNode/file”).split('/')
file = path.pop().split('.')
file.append('obj')
file.insert(0,'prefix')
file = ('.').join(file)
path.append('subfolder')
path = ('/').join(path)
return ('/').join()

Attachments:
fileIO.hip (55.9 KB)

http://www.sekowfx.com [www.sekowfx.com]
User Avatar
Member
102 posts
Joined: 5月 2006
Offline
Works great, thanks Sekow! I really need to learn python.

I have another short one, is there a way to count primitive groups in Python?
In hscript I can do something like this: argc(primgrouplist(“/obj/geo1/out_my_boxes”)) but I needed in Python since I use the result in a python expression. Unless there's a way to read the result of a hscript expression in a python expression.

Thank you
  • Quick Links