Design Express Res initial commit
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,83 @@
|
||||
# Design Express Res 部署脚本: 复制 DLL + 注册每用户 COM + 生成 .addin (无需管理员权限)
|
||||
# 架构: DesignExpress.Core.dll(独立核心) + DesignExpress.InventorLink.dll(Inventor 适配)
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
$invVer = "2022"
|
||||
$addinDir = Join-Path $env:APPDATA "Autodesk\Inventor $invVer\Addins"
|
||||
$clsid = "{D422E0BF-02D0-4DAE-958A-7BBA80B718E9}"
|
||||
$progId = "DesignExpress.InventorLink.AddInServer"
|
||||
$asmName = "DesignExpress.InventorLink, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"
|
||||
|
||||
$srcCore = Join-Path $PSScriptRoot "DesignExpress.Core.dll"
|
||||
$srcLink = Join-Path $PSScriptRoot "DesignExpress.InventorLink.dll"
|
||||
if (-not (Test-Path $srcCore)) { Write-Host "未找到 DesignExpress.Core.dll"; exit 1 }
|
||||
if (-not (Test-Path $srcLink)) { Write-Host "未找到 DesignExpress.InventorLink.dll"; exit 1 }
|
||||
|
||||
New-Item -ItemType Directory -Force -Path $addinDir | Out-Null
|
||||
Copy-Item -LiteralPath $srcCore -Destination (Join-Path $addinDir "DesignExpress.Core.dll") -Force
|
||||
$dstLink = Join-Path $addinDir "DesignExpress.InventorLink.dll"
|
||||
Copy-Item -LiteralPath $srcLink -Destination $dstLink -Force
|
||||
Write-Host "DLL 已复制: $addinDir"
|
||||
|
||||
# 每用户 COM 注册 (HKCU\Software\Classes)
|
||||
$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
|
||||
Write-Host "COM 注册完成 (HKCU)"
|
||||
|
||||
# 生成 .addin
|
||||
$addinXml = @"
|
||||
<Addin Type="Standard">
|
||||
<ClassId>$clsid</ClassId>
|
||||
<ClientId>$clsid</ClientId>
|
||||
<DisplayName>Design Express Res</DisplayName>
|
||||
<Description>设计标注检查与设计数据查询工具(Core+Link 架构)</Description>
|
||||
<Assembly>$dstLink</Assembly>
|
||||
<LoadOnStartUp>1</LoadOnStartUp>
|
||||
<UserUnloadable>1</UserUnloadable>
|
||||
<Hidden>0</Hidden>
|
||||
<SupportedSoftwareVersionGreaterThan>25..</SupportedSoftwareVersionGreaterThan>
|
||||
<DataVersion>1</DataVersion>
|
||||
<UserInterfaceVersion>1</UserInterfaceVersion>
|
||||
</Addin>
|
||||
"@
|
||||
$addinFile = Join-Path $addinDir "DesignExpress.InventorLink.addin"
|
||||
[System.IO.File]::WriteAllText($addinFile, $addinXml, [System.Text.Encoding]::UTF8)
|
||||
Write-Host ".addin 已生成: $addinFile"
|
||||
|
||||
# 清理旧版本文件
|
||||
Remove-Item (Join-Path $addinDir "InventorDesignCheck.dll") -Force -ErrorAction SilentlyContinue
|
||||
Remove-Item (Join-Path $addinDir "InventorDesignCheck.addin") -Force -ErrorAction SilentlyContinue
|
||||
|
||||
# 关键: 修复 AddInLoadRules(加载规则文件), 确保本加载项允许加载
|
||||
# 该文件为 UTF-16 二进制, 每条记录: "{GUID}" + DWORD(0=允许, 1=禁止)
|
||||
$rulesFile = Join-Path $addinDir "AddInLoadRules"
|
||||
if (Test-Path $rulesFile) {
|
||||
$b = [System.IO.File]::ReadAllBytes($rulesFile)
|
||||
$u = [System.Text.Encoding]::Unicode.GetString($b)
|
||||
$guid = "{D422E0BF-02D0-4DAE-958A-7BBA80B718E9}"
|
||||
$pos = $u.IndexOf($guid)
|
||||
if ($pos -ge 0) {
|
||||
$bytePos = $pos * 2 + $guid.Length * 2
|
||||
if ([BitConverter]::ToUInt32($b, $bytePos) -ne 0) {
|
||||
$b[$bytePos] = 0; $b[$bytePos + 1] = 0; $b[$bytePos + 2] = 0; $b[$bytePos + 3] = 0
|
||||
[System.IO.File]::WriteAllBytes($rulesFile, $b)
|
||||
Write-Host "已修复加载规则(允许加载)"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host "部署完成! 请重启 Inventor, 功能区将出现 [Design Express Res] 选项卡。"
|
||||
@@ -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