| | |
| | | using System; |
| | | using ExportMap.Models; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Diagnostics; |
| | | using System.IO; |
| | | using System.Linq; |
| | | using System.Web; |
| | | |
| | |
| | | /// <summary> |
| | | /// 工作配置 |
| | | /// </summary> |
| | | public static string jobConfig = "{ \"format\": \"3dtiles\", \"mode\": 0, \"outputPath\": \"{0}\", \"outputOptions\": null, \"levelOfDetail\": -1, \"levelOfDetailText\": \"Auto\", \"georeferenced\": null }"; |
| | | public static string JobConfig = "{ \"format\": \"3dtiles\", \"mode\": 0, \"outputPath\": \"{0}\", \"outputOptions\": null, \"levelOfDetail\": -1, \"levelOfDetailText\": \"Auto\", \"georeferenced\": null }"; |
| | | |
| | | /// <summary> |
| | | /// Roamer.exe |
| | | /// </summary> |
| | | public static string RoamerExe = "\"C:\\Program Files\\Autodesk\\Navisworks Manage 2020\\Roamer.exe\""; |
| | | |
| | | /// <summary> |
| | | /// 模型转换 |
| | | /// </summary> |
| | | public static int Convert(List<int> ids) |
| | | { |
| | | int count = 0; |
| | | string uploadFolder = Tool.GetSetting("uploadFolder"); |
| | | string tilesFolder = Path.Combine(Tool.GetSetting("lfData"), "3d\\3dtiles"); |
| | | |
| | | List<SysMeta> list = XYZUtils.selectMetas(ids, "type in ('ifc', 'fbx', 'rvt')"); |
| | | foreach (SysMeta meta in list) |
| | | { |
| | | try |
| | | { |
| | | string modelFile = Path.Combine(uploadFolder, meta.path); |
| | | if (!File.Exists(modelFile)) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | string configFile = Path.Combine(Tool.BaseDir, ExportUtil.DateStr + ".json"); |
| | | string outPath = Path.Combine(tilesFolder, meta.type, meta.id.ToString()); |
| | | |
| | | if (!Directory.Exists(outPath)) Directory.CreateDirectory(outPath); |
| | | WriteText(configFile, string.Format(JobConfig, outPath)); |
| | | |
| | | ExecNavisworks(modelFile, configFile); |
| | | |
| | | count++; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogOut.Error(ex.StackTrace); |
| | | } |
| | | } |
| | | |
| | | return count; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 运行Navisworks |
| | | /// </summary> |
| | | public static string ExecNavisworks(string modelFile, string outPath) |
| | | { |
| | | try |
| | | { |
| | | string exe = @"C:\Program Files\Autodesk\Navisworks Manage 2020\Roamer.exe"; |
| | | string cmd = string.Format("\"{0}\" -licensing AdLM -OpenFile \"{1}\" -ExecuteAddInPlugin SmartEarth \"{2}\" -NoGui -NoCache -Exit", exe, modelFile, outPath); |
| | | string args = string.Format("-licensing AdLM -OpenFile \"{0}\" -ExecuteAddInPlugin SmartEarth \"{1}\" -NoGui -NoCache -Exit", modelFile, outPath); |
| | | |
| | | Process p = new Process(); |
| | | p.StartInfo.UseShellExecute = false; |
| | | p.StartInfo.ErrorDialog = true; |
| | | p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; |
| | | p.StartInfo.RedirectStandardError = false; |
| | | p.StartInfo.FileName = exe; |
| | | p.StartInfo.Arguments = cmd; |
| | | p.StartInfo.CreateNoWindow = true; |
| | | p.Start(); |
| | | Process p = new Process(); |
| | | p.StartInfo.UseShellExecute = false; |
| | | p.StartInfo.ErrorDialog = true; |
| | | p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; |
| | | p.StartInfo.RedirectStandardError = false; |
| | | p.StartInfo.FileName = RoamerExe; |
| | | p.StartInfo.Arguments = args; |
| | | p.StartInfo.CreateNoWindow = true; |
| | | p.Start(); |
| | | |
| | | return string.Empty; |
| | | } |
| | | catch(Exception ex) |
| | | { |
| | | return ex.Message; |
| | | } |
| | | return string.Empty; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 写文本文件 |
| | | /// </summary> |
| | | private static void WriteText(string file, string str) |
| | | { |
| | | File.WriteAllText(file, str); |
| | | } |
| | | } |
| | | } |