复制RevitAPI的DLL文件
2024年11月10日小于 1 分钟
// 思路:遍历dll所在的文件夹,对比文件名,如果是需要的dll就复制
// 填写dll所在目录,这填的是安装目录,如果没有安装,也可以全部解压,把目录替换成安装包的目录
var paths = new List<string>()
{
@"C:\Program Files\Autodesk\Revit 2016",
@"C:\Program Files\Autodesk\Revit 2017",
@"C:\Program Files\Autodesk\Revit 2018",
@"C:\Program Files\Autodesk\Revit 2019",
@"C:\Program Files\Autodesk\Revit 2020",
@"C:\Program Files\Autodesk\Revit 2021",
@"C:\Program Files\Autodesk\Revit 2022",
@"C:\Program Files\Autodesk\Revit 2023",
@"C:\Program Files\Autodesk\Revit 2024"
};
// 要提取的dll文件名
var apiFileNames = new List<string>()
{
"AdWindows.dll",
"UIFrameworkRes.dll",
"UIFramework.dll",
"UIFrameworkServices.dll",
"RevitAddInUtility.dll",
"RevitNET.dll",
"RevitAPIBrowserUtils.dll",
"RevitAPI.dll",
"RevitAPIUI.dll",
"RevitAPIMacros.dll",
"RevitAPIUIMacros.dll",
};
// 要复制到哪个目录下?
var rootDir = @"D:\Test\RevitAPI";
// 开始遍历判断,满足条件则复制
foreach (var item in paths)
{
var curVersionDir = new DirectoryInfo(item);
var targetDir = Path.Combine(rootDir, curVersionDir.Name);
if (!Directory.Exists(targetDir))
{
Directory.CreateDirectory(targetDir);
}
var files = curVersionDir.GetFiles();
foreach (var f in files)
{
if (f.Extension != ".dll") continue;
if (!apiFileNames.Contains(f.Name)) continue;
string targetFile = Path.Combine(targetDir, f.Name);
File.Copy(f.FullName, targetFile);
}
}