konstantin magnus Posted April 23, 2018 Share Posted April 23, 2018 I am building a shelf tool that imports all *.PLY-files from a folder. It works, just how can I convert this into an absolute path? hipdir = os.environ["HIP"] folder = hou.ui.selectFile(title="Choose directory:", file_type=hou.fileType.Directory) Quote Link to comment Share on other sites More sharing options...
anim Posted April 24, 2018 Share Posted April 24, 2018 abspath = hou.expandString(folder) Quote Link to comment Share on other sites More sharing options...
konstantin magnus Posted April 24, 2018 Author Share Posted April 24, 2018 Cool, thank you! Quote Link to comment Share on other sites More sharing options...
konstantin magnus Posted April 24, 2018 Author Share Posted April 24, 2018 (edited) Btw. here is the code I have so far. It merges all geometry files from a folder into a single merge node. I am more than open to suggestions and improvements.. import os # CHOOSE DIRECTORY folder = hou.ui.selectFile(title="Choose directory:", file_type=hou.fileType.Directory) path = hou.expandString(folder) # FILE LIST extensions = ['obj', 'ply', 'dae'] files = [file for file in sorted(os.listdir(path)) if any(file.endswith(ext) for ext in extensions)] file_count = len(files) print "Importing " + str(file_count) + " files from " + path # CREATE GEO NODE container = hou.node('/obj').createNode('geo') container.setName('cache_import') for child in container.children(): child.destroy() # CREATE MERGE AND FILE-NODES merge = container.createNode('merge') for i in range(file_count): file_node = container.createNode('file') file_name = path + files[i] file_node.parm('file').set(file_name) merge.setNextInput(file_node, 0, False) # CREATE OUT-NODE out = container.createNode('null') out.setName('OUT') out.setInput(0, merge, 0) out.setDisplayFlag(True) container.layoutChildren() Edited August 10, 2018 by konstantin magnus 2 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.