using SAGA.DotNetUtils.Revit; using System; using System.Diagnostics; using System.IO; namespace StartVisionSelector { public class Program { public static void Main(string[] args) { string path = @"E:\导出测试\testR17.rvt"; //path = @"E:\导出测试\testR18.rvt"; //path = @"E:\导出测试\testR16.rvt"; Console.WriteLine("start"); #region 保存版本号 //保存版本号 var runPath = AppDomain.CurrentDomain.BaseDirectory; var revitVision = RevitVisionUtil.GetRevitVision(path); File.WriteAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, SelectorConst.RevitFileVisionFile), revitVision); #endregion #region 删除生成的Revit dll var dllsPath = Path.Combine(Directory.GetParent(runPath).Parent.FullName, "Dlls"); var loadingRevitPath = Path.Combine(dllsPath, SelectorConst.LoadingRevit); //先删除,后Copy,如果可以指定Revit的安装目录,不需要Copy #region Del RevitDll foreach (string loadingItem in File.ReadAllLines(loadingRevitPath)) { string destFile = Path.Combine(runPath, $"{loadingItem}.dll"); if(File.Exists(destFile)) File.Delete(destFile); } #endregion #endregion #region Copy RevitAddInUtility.dll //var revitAddInDll = revitdllDirectoryInfo.GetFiles(SelectorConst.RevitAddInUtilityDll); //if (revitAddInDll.Length != 0) // foreach (FileInfo fileInfo in revitAddInDll) // { // string destFile = Path.Combine(runPath, fileInfo.Name); // fileInfo.CopyTo(destFile, true); // } #endregion #region 启动 Process process = new Process();//AppDomain.CurrentDomain.BaseDirectory + process.StartInfo.FileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ExportStart.exe");//执行的exe路径 process.StartInfo.UseShellExecute = false;//不显示shell process.StartInfo.CreateNoWindow = true;//不创建窗口 process.StartInfo.RedirectStandardInput = true;//打开流输入 process.StartInfo.RedirectStandardOutput = true;//打开流输出 process.StartInfo.RedirectStandardError = true;//打开错误流 process.StartInfo.Arguments = "\"" + path + "\"";//输入参数,多个参数使用空间分割,如果一个参数包含空格,使用""包括此参数 process.Start();//执行 string msg = process.StandardOutput.ReadToEnd();//读取输出 process.WaitForExit();//等待执行完成 process.Close();//结束 #endregion Console.WriteLine("end"); //Console.ReadKey(); } } }