Design Express Res initial commit
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
# Design Express Res - SolidWorks Link 部署脚本 (无需管理员权限, 但 HKLM 注册需手动确认一次)
|
||||
# 说明: 首次部署后需正常退出并重启 SolidWorks 一次, 让选项卡定义持久化到注册表
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
$swDir = Join-Path $env:APPDATA "DesignExpress\SolidWorks"
|
||||
$clsid = "{4A7E023E-EDD8-4642-B337-425E02394C81}"
|
||||
$progId = "DesignExpress.SolidWorksLink.SwAddin"
|
||||
$asmName = "DesignExpress.SolidWorksLink, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"
|
||||
|
||||
$srcCore = Join-Path $PSScriptRoot "DesignExpress.Core.dll"
|
||||
$srcLink = Join-Path $PSScriptRoot "DesignExpress.SolidWorksLink.dll"
|
||||
if (-not (Test-Path $srcCore)) { Write-Host "未找到 DesignExpress.Core.dll"; exit 1 }
|
||||
if (-not (Test-Path $srcLink)) { Write-Host "未找到 DesignExpress.SolidWorksLink.dll"; exit 1 }
|
||||
|
||||
New-Item -ItemType Directory -Force -Path $swDir | Out-Null
|
||||
Copy-Item -LiteralPath $srcCore -Destination (Join-Path $swDir "DesignExpress.Core.dll") -Force
|
||||
$dstLink = Join-Path $swDir "DesignExpress.SolidWorksLink.dll"
|
||||
Copy-Item -LiteralPath $srcLink -Destination $dstLink -Force
|
||||
Write-Host "DLL 已复制: $swDir"
|
||||
|
||||
# 每用户 COM 注册 (HKCU)
|
||||
$clsBase = "HKCU:\Software\Classes\CLSID\$clsid"
|
||||
Remove-Item -Path $clsBase -Recurse -Force -ErrorAction SilentlyContinue
|
||||
New-Item -Path $clsBase -Force | Out-Null
|
||||
Set-ItemProperty -Path $clsBase -Name "(default)" -Value $progId
|
||||
New-Item -Path "$clsBase\InprocServer32" -Force | Out-Null
|
||||
Set-ItemProperty -Path "$clsBase\InprocServer32" -Name "(default)" -Value "mscoree.dll"
|
||||
Set-ItemProperty -Path "$clsBase\InprocServer32" -Name "Class" -Value $progId
|
||||
Set-ItemProperty -Path "$clsBase\InprocServer32" -Name "Assembly" -Value $asmName
|
||||
$codebase = "file:///" + ($dstLink.Replace('\', '/'))
|
||||
Set-ItemProperty -Path "$clsBase\InprocServer32" -Name "CodeBase" -Value $codebase
|
||||
Set-ItemProperty -Path "$clsBase\InprocServer32" -Name "ThreadingModel" -Value "Both"
|
||||
|
||||
$progBase = "HKCU:\Software\Classes\$progId"
|
||||
Remove-Item -Path $progBase -Recurse -Force -ErrorAction SilentlyContinue
|
||||
New-Item -Path "$progBase\CLSID" -Force | Out-Null
|
||||
Set-ItemProperty -Path "$progBase\CLSID" -Name "(default)" -Value $clsid
|
||||
|
||||
# SolidWorks 加载项注册 (当前用户, 启动时加载)
|
||||
$swAddinKey = "HKCU:\Software\SolidWorks\AddIns\$clsid"
|
||||
Remove-Item -Path $swAddinKey -Recurse -Force -ErrorAction SilentlyContinue
|
||||
New-Item -Path $swAddinKey -Force | Out-Null
|
||||
Set-ItemProperty -Path $swAddinKey -Name "(default)" -Value 1 -Type DWord
|
||||
Set-ItemProperty -Path $swAddinKey -Name "Title" -Value "Design Express Res"
|
||||
Set-ItemProperty -Path $swAddinKey -Name "Description" -Value "设计标注检查与设计数据查询工具"
|
||||
|
||||
$swStartupKey = "HKCU:\Software\SolidWorks\AddInsStartup\$clsid"
|
||||
New-Item -Path $swStartupKey -Force | Out-Null
|
||||
Set-ItemProperty -Path $swStartupKey -Name "(default)" -Value 1 -Type DWord
|
||||
Write-Host "SolidWorks 加载项已注册(启动时自动加载)"
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "=== 下一步(重要) ==="
|
||||
Write-Host "1. 若首次安装, 请以管理员身份导入注册表(加载项清单需要 HKLM):"
|
||||
Write-Host " reg add ""HKLM\SOFTWARE\SolidWorks\AddIns\$clsid"" /ve /t REG_SZ /d 1 /f"
|
||||
Write-Host " reg add ""HKLM\SOFTWARE\SolidWorks\AddIns\$clsid"" /v Title /t REG_SZ /d ""Design Express Res"" /f"
|
||||
Write-Host "2. 启动 SolidWorks, 在 工具→插件 中勾选 Design Express Res"
|
||||
Write-Host "3. 打开一个零件文档 -> 出现 Design Express Res 选项卡"
|
||||
Write-Host "4. 正常退出 SolidWorks 并重新打开(持久化选项卡定义)"
|
||||
Reference in New Issue
Block a user