Updated
This commit is contained in:
@ -0,0 +1,55 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
import os
|
||||
import subprocess
|
||||
# from pathlib import Path
|
||||
import maya.cmds as cmds
|
||||
|
||||
def create_folder_link(src_path, dst_path):
|
||||
"""
|
||||
创建文件夹符号链接
|
||||
|
||||
Args:
|
||||
src_path: 源文件夹路径
|
||||
dst_path: 目标链接路径
|
||||
|
||||
Returns:
|
||||
bool: 是否创建成功
|
||||
"""
|
||||
try:
|
||||
# src = Path(src_path)
|
||||
# dst = Path(dst_path)
|
||||
|
||||
if not os.path.exists(src_path):
|
||||
print("找不到 QuadRemesher: ", src_path)
|
||||
return 0
|
||||
|
||||
if os.path.exists(dst_path):
|
||||
print("QuadRemesher 已安装: ", dst_path)
|
||||
return 1
|
||||
|
||||
# 创建父目录
|
||||
os.makedirs(os.path.dirname(dst_path), exist_ok=True)
|
||||
|
||||
# 创建符号链接
|
||||
if os.name == 'nt': # Windows
|
||||
cmd = 'mklink /j "{}" "{}"'.format(dst_path, src_path)
|
||||
|
||||
subprocess.run(cmd, shell=True, check=True)
|
||||
else: # Linux/Mac
|
||||
os.symlink(src_path, dst_path)
|
||||
|
||||
cmds.confirmDialog(title="QuadRemesher", message=u"成功安装 QuadRemesher, 重启 Maya 后生效!", button="OK")
|
||||
|
||||
return 2
|
||||
|
||||
except Exception as e:
|
||||
print("创建符号链接失败: {}".format(e))
|
||||
return 0
|
||||
|
||||
def quick_install():
|
||||
src = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
|
||||
dst = r"C:\ProgramData\Autodesk\ApplicationPlugins\QuadRemesher"
|
||||
print(src, dst)
|
||||
|
||||
return create_folder_link(src, dst)
|
Reference in New Issue
Block a user