# 家具导出插件编译脚本 # 自动检测 AutoCAD 安装路径并编译插件 $ErrorActionPreference = "Stop" Write-Host "========================================" -ForegroundColor Cyan Write-Host " 家具导出插件编译工具" -ForegroundColor Cyan Write-Host "========================================" -ForegroundColor Cyan Write-Host "" # 检测 AutoCAD 安装路径 $acadPaths = @( "C:\Program Files\Autodesk\AutoCAD 2024", "D:\Program Files\Autodesk\AutoCAD 2024", "E:\Program Files\Autodesk\AutoCAD 2024", "C:\Autodesk\AutoCAD 2024", "D:\Autodesk\AutoCAD 2024", "E:\Autodesk\AutoCAD 2024" ) $foundPath = $null # 检查环境变量 if ($env:ACAD_PATH -and (Test-Path "$env:ACAD_PATH\accoremgd.dll")) { $foundPath = $env:ACAD_PATH Write-Host "[√] 使用环境变量 ACAD_PATH: $foundPath" -ForegroundColor Green } else { # 自动检测 Write-Host "[*] 正在检测 AutoCAD 2024 安装路径..." -ForegroundColor Yellow foreach ($path in $acadPaths) { if (Test-Path "$path\accoremgd.dll") { $foundPath = $path Write-Host "[√] 找到 AutoCAD 2024: $foundPath" -ForegroundColor Green break } } } if (-not $foundPath) { Write-Host "" Write-Host "[×] 未找到 AutoCAD 2024 安装目录!" -ForegroundColor Red Write-Host "" Write-Host "请执行以下操作之一:" -ForegroundColor Yellow Write-Host " 1. 设置环境变量 ACAD_PATH 指向 AutoCAD 2024 安装目录" Write-Host " 例如: `$env:ACAD_PATH = 'D:\你的路径\AutoCAD 2024'" Write-Host "" Write-Host " 2. 或者直接输入路径:" -ForegroundColor Yellow $inputPath = Read-Host " 请输入 AutoCAD 2024 安装路径" if ($inputPath -and (Test-Path "$inputPath\accoremgd.dll")) { $foundPath = $inputPath Write-Host "[√] 路径有效: $foundPath" -ForegroundColor Green } else { Write-Host "[×] 路径无效或不包含 AutoCAD 2024 文件" -ForegroundColor Red exit 1 } } # 设置环境变量 $env:ACAD_PATH = $foundPath Write-Host "" Write-Host "[*] 开始编译..." -ForegroundColor Yellow Write-Host "" # 编译 Push-Location "$PSScriptRoot\FurnitureExporter" try { dotnet build -c Release if ($LASTEXITCODE -eq 0) { Write-Host "" Write-Host "========================================" -ForegroundColor Green Write-Host " 编译成功!" -ForegroundColor Green Write-Host "========================================" -ForegroundColor Green Write-Host "" Write-Host "输出文件位置:" -ForegroundColor Cyan Write-Host " $PSScriptRoot\FurnitureExporter\bin\Release\net48\FurnitureExporter.dll" Write-Host "" Write-Host "使用方法:" -ForegroundColor Cyan Write-Host " 1. 打开 AutoCAD 2024" Write-Host " 2. 输入命令: NETLOAD" Write-Host " 3. 选择上述 DLL 文件" Write-Host " 4. 使用命令: FEXPORT 导出单资产模型" Write-Host " 旧整套兼容导出: FEXPORTPRODUCT" Write-Host "" } else { Write-Host "" Write-Host "[×] 编译失败!请检查错误信息。" -ForegroundColor Red exit 1 } } finally { Pop-Location }