Houdini vscode hou信息补全stubs文件

文件说明

在vscode使用hou模块时,我们希望hou可以自动补全与写法信息提示,单纯依靠houdini安装文件提供的hou相关文件是有问题的,还需要生成stubs文件用于vscode的信息查找,如果你不想自己生成,那么你就可以使用我们提供的这个stubs文件。

使用方法

1.将下载好的stubs文件解压后放入电脑任意一个文件夹内,并记录好该路径(非中文)。

2.打开houdini,在geo节点里创建一个python节点,里面输入下面的代码,需要将vscode_settings['python.analysis.stubPath']这个路径更改为刚刚放置stubs的路径。

import sys
import pathlib
import json

vscode_settings = {}

# 获取 Houdini 使用的 Python 解释器路径
pythonexe_path = pathlib.Path(sys.prefix).resolve().joinpath('python.exe')
vscode_settings['python.defaultInterpreterPath'] = pythonexe_path.as_posix()

# 获取 sys.path 中的路径,并去重,同时保留顺序
sys_paths = [pathlib.Path(p).resolve() for p in sys.path]
unique_sys_paths = list(dict.fromkeys(sys_paths))
vscode_settings['python.analysis.extraPaths'] = [p.as_posix() for p in unique_sys_paths]

# 设置 Python 分析的 stubPath,指向你的 Stubs 文件夹
vscode_settings['python.analysis.stubPath'] = 'D:/pyro/stubs'

# 打印出配置的 JSON 内容
print(json.dumps(vscode_settings, indent=4))

3.输入之后会在控制台出现相关的json设置,如果没有可以打开python shell窗口再次运行python节点查看。将这些信息放到vscode软件的设置json文件里。

也可以参考下面的代码

{
    "python.defaultInterpreterPath": "D:/Program Files/Side Effects Software/Houdini 20.5.278/python311/python.exe",
    "python.analysis.extraPaths": [

        "D:/Program Files/Side Effects Software/Houdini 20.5.278/python311/lib/site-packages-ui-forced",
        "D:/Program Files/Side Effects Software/Houdini 20.5.278/python311/lib/site-packages-forced",
        "D:/Program Files/Side Effects Software/Houdini 20.5.278/bin/python311.zip",
        "D:/Program Files/Side Effects Software/Houdini 20.5.278/python311/dlls",
        "D:/Program Files/Side Effects Software/Houdini 20.5.278/python311/lib",
        "D:/Program Files/Side Effects Software/Houdini 20.5.278/bin",
        "D:/Program Files/Side Effects Software/Houdini 20.5.278/python311",
        "D:/Program Files/Side Effects Software/Houdini 20.5.278/packages/sculpt/python3.11libs",
        "D:/Program Files/Side Effects Software/Houdini 20.5.278/packages/kinefx/python3.11libs",
        "D:/Program Files/Side Effects Software/Houdini 20.5.278/packages/apex/python3.11libs",
        "D:/Program Files/Side Effects Software/sidefx_packages/SideFXLabs20.5/scripts/python",
        "D:/Program Files/Side Effects Software/Houdini 20.5.278/packages/kinefx/viewer_states",
        "D:/Program Files/Side Effects Software/Houdini 20.5.278/packages/apex/viewer_states",
        "D:/Program Files/Side Effects Software/Houdini 20.5.278/houdini/viewer_states",
        "D:/Program Files/Side Effects Software/Houdini 20.5.278/packages/kinefx/viewer_handles",
        "D:/Program Files/Side Effects Software/Houdini 20.5.278/houdini/viewer_handles",
        "D:/Program Files/Side Effects Software/sidefx_packages/SideFXLabs20.5/viewer_states"
    ],
    "python.analysis.stubPath": "D:/pyro/stubs"
}

4.重启vscod,输入hou相关函数查看效果。

Houdini vscode hou信息补全stubs文件-数字折叠
Houdini vscode hou信息补全stubs文件
此内容为免费资源,请登录后查看
0
限时特惠
10
提供远程协助
支持需求定制
适用软件Houdini vscode
语言英文
大小100kb
工具使用问题请联系qq1990781688
免费资源
© 版权声明
THE END
喜欢就支持一下吧
点赞9 分享
评论 共1条

请登录后发表评论