カレントフォルダを開く

現在開いているファイルのフォルダを開くシェルフツールのスクリプト。

シェルフ上で右クリックしてNew Tool…を選択してウインドウが開いたらOptionsに名前やラベルを入力する。

Scriptタブを押し、コードを入力する。

import re
import subprocess
 
fileName = hou.hipFile.basename()
if fileName == "untitled.hip":
    print('No Scene!')
else:
    filePath = hou.hipFile.path()
    filePath = filePath.replace(fileName, "")
    filePath = [re.sub("/", "\\\\", filePath)]
 
    subprocess.Popen(['explorer', filePath])

追記

こちらのほうが短くてよいかもしれない。

import os
import hou

hipDir = os.path.dirname(hou.hipFile.path()).replace('/','\\')
os.system("explorer " + hipDir)

タイトルとURLをコピーしました