Skip to content

Commit 6c24a6e

Browse files
author
nkx111
committed
add createLink.py
1 parent f872007 commit 6c24a6e

2 files changed

Lines changed: 108 additions & 0 deletions

File tree

createLink.py

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
import os
2+
import sys
3+
import ctypes
4+
import subprocess
5+
6+
def run_as_admin():
7+
"""Run script with admin privileges"""
8+
if ctypes.windll.shell32.IsUserAnAdmin():
9+
return True
10+
11+
# Re-run with admin privileges
12+
script = os.path.abspath(sys.argv[0])
13+
params = ' '.join([script] + sys.argv[1:])
14+
ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, params, None, 1)
15+
sys.exit()
16+
17+
def find_blender_addons_path():
18+
"""Find Blender's addons directory"""
19+
username = os.getenv('USERNAME')
20+
if not username:
21+
print("Failed to get current username")
22+
return None
23+
24+
# Try to locate Blender's addons path
25+
base_path = f"C:\\Users\\{username}\\AppData\\Roaming\\Blender Foundation\\Blender"
26+
if not os.path.exists(base_path):
27+
print(f"Blender config directory not found: {base_path}")
28+
return None
29+
30+
# Find the latest Blender version
31+
versions = [d for d in os.listdir(base_path) if os.path.isdir(os.path.join(base_path, d))]
32+
if not versions:
33+
print("No Blender version directories found")
34+
return None
35+
36+
# Sort versions and pick the newest
37+
versions.sort(reverse=True)
38+
latest_version = versions[0]
39+
40+
addons_path = os.path.join(base_path, latest_version, "scripts", "addons")
41+
if not os.path.exists(addons_path):
42+
print(f"Addons directory not found: {addons_path}")
43+
return None
44+
45+
return addons_path
46+
47+
def create_symbolic_link():
48+
"""Create symbolic link with user confirmation"""
49+
# Get current directory
50+
current_dir = os.path.dirname(os.path.abspath(__file__))
51+
source_folder = os.path.join(current_dir, "io_mesh_w3d")
52+
53+
if not os.path.exists(source_folder):
54+
print(f"Source folder not found: {source_folder}")
55+
return False
56+
57+
# Get Blender addons path
58+
addons_path = find_blender_addons_path()
59+
if not addons_path:
60+
return False
61+
62+
target_path = os.path.join(addons_path, "io_mesh_w3d")
63+
64+
# Check if target already exists
65+
if os.path.exists(target_path):
66+
print(f"Target path already exists: {target_path}")
67+
return False
68+
69+
# Prepare command and display for confirmation
70+
cmd = f'mklink /D "{target_path}" "{source_folder}"'
71+
print("\nAbout to execute the following command:")
72+
print(f" {cmd}\n")
73+
74+
# Get user confirmation
75+
confirm = input("Do you want to proceed? (y/n): ").strip().lower()
76+
if confirm != 'y':
77+
print("Operation cancelled by user")
78+
return False
79+
80+
# Create symbolic link
81+
try:
82+
subprocess.run(cmd, shell=True, check=True)
83+
print(f"\nSuccessfully created symbolic link: {target_path} -> {source_folder}")
84+
return True
85+
except subprocess.CalledProcessError as e:
86+
print(f"\nFailed to create symbolic link: {e}")
87+
return False
88+
89+
if __name__ == "__main__":
90+
# Request admin privileges
91+
run_as_admin()
92+
93+
# Execute main logic
94+
print("\nBlender Addon Symbolic Link Creator")
95+
print("----------------------------------")
96+
97+
if create_symbolic_link():
98+
print("\nOperation completed successfully!")
99+
else:
100+
print("\nOperation failed")
101+
102+
# Keep window open
103+
input("\nPress Enter to exit...")

readme_plugin_cn.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ GitHub地址:https://github.com/nkx111/OpenSAGE.BlenderPlugin
1818
1. 同时导入和管理多个动画
1919
2. 动画透明度channel问题、多channel动画导出疑似存在异常
2020

21+
(0.8.2)
22+
支持多个动画
23+
支持GeometryType
24+
25+
2126
2025/6/21(0.8.1) 更新:
2227
修复了导入插件后无法识别的问题。
2328

0 commit comments

Comments
 (0)