一键导入工程文件目录下的usd文件
本文最后更新于 2024-09-25,文章内容可能已经过时。
import os
import hou
stage = hou.node("/stage")
def find_hip_path():
hippath = hou.hipFile.path()
hippath = os.path.dirname(hippath)
return hippath
hip_path = find_hip_path()
print(hip_path)
def is_usd_extension(file_name):
# 使用os.path.splitext分离文件名和扩展名
extension = os.path.splitext(file_name)[1]
return extension.lower() == ".usd"
def get_usd_path(hip_path=hip_path):
file_paths = []
for root, _, files in os.walk(hip_path):
for file in files:
# 构建完整的文件路径
if is_usd_extension(file):
file_path = os.path.join(root, file)
new_path = file_path.replace("\\", "/")
file_paths.append(new_path)
else:
continue
return file_paths
path_list = get_usd_path()
def get_ABC_name(path_list=path_list, stage=stage):
for path in path_list:
file_name = os.path.basename(path)
name = os.path.splitext(file_name)[0]
node = stage.createNode("reference::2.0", name)
node.parm("filepath1").set(path)
get_ABC_name(path_list=path_list, stage=stage)
本文是原创文章,采用 CC BY-NC-ND 4.0 协议,完整转载请注明来自 蜗牛菌
评论
隐私政策
你无需删除空行,直接评论以获取最佳展示效果

