| | |
| | | [HttpGet] |
| | | public ResponseMsg<string> Test() |
| | | { |
| | | string modelFile = @"E:\soft\Navisworks Manage 2020\Data\jz.rvt"; |
| | | string outPath = @"D:\xyz\3dtiles\out"; |
| | | |
| | | return ResponseMsg<string>.success("成功", ""); |
| | | string rs = ConvertUtils.ExecNavisworks(modelFile, outPath); |
| | | if (string.IsNullOrEmpty(rs)) |
| | | { |
| | | return ResponseMsg<string>.success("成功", ""); |
| | | } |
| | | else |
| | | { |
| | | return ResponseMsg<string>.fail(rs); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Diagnostics; |
| | | using System.Linq; |
| | | using System.Web; |
| | | |
| | |
| | | { |
| | | public class ConvertUtils |
| | | { |
| | | /// <summary> |
| | | /// 工作配置 |
| | | /// </summary> |
| | | public static string jobConfig = "{ \"format\": \"3dtiles\", \"mode\": 0, \"outputPath\": \"{0}\", \"outputOptions\": null, \"levelOfDetail\": -1, \"levelOfDetailText\": \"Auto\", \"georeferenced\": null }"; |
| | | |
| | | 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); |
| | | |
| | | 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(); |
| | | |
| | | return string.Empty; |
| | | } |
| | | catch(Exception ex) |
| | | { |
| | | return ex.Message; |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | CreateTemplate(args); |
| | | |
| | | string cmd = string.Format("python {0} -qgz {1} -qpt {2}", PyFile, qgz, args.qpt); |
| | | err = Tool.ExecPython(cmd); |
| | | err = Tool.ExecCmd(cmd, true); |
| | | |
| | | string qptFile = Path.Combine(SourcesPath, args.qpt); |
| | | if (File.Exists(qptFile)) |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 执行Python |
| | | /// 执行CMD |
| | | /// </summary> |
| | | /// <param name="cmd">命令行</param> |
| | | /// <returns>执行结果或出错信息</returns> |
| | | public static String ExecPython(string cmd) |
| | | public static String ExecCmd(string cmd, bool isPy = false) |
| | | { |
| | | string str = null; |
| | | try |
| | |
| | | |
| | | LogOut.Info("cmd = " + cmd); |
| | | si.AutoFlush = true; |
| | | si.WriteLine("\"C:\\Program Files\\QGIS 3.16\\bin\\python-qgis-ltr.bat\""); |
| | | if (isPy) |
| | | { |
| | | si.WriteLine("\"C:\\Program Files\\QGIS 3.16\\bin\\python-qgis-ltr.bat\""); |
| | | } |
| | | si.WriteLine(cmd); |
| | | si.WriteLine("exit"); |
| | | |
| | |
| | | if (!Directory.Exists(xyzPath)) Directory.CreateDirectory(xyzPath); |
| | | |
| | | string cmd = string.Format("python {0} -qgz {1} -file {2} -out {3} -min {4} -max {5}", PyFile, Qgz, tifFile, xyzPath, args.min, args.max); |
| | | err = Tool.ExecPython(cmd); |
| | | err = Tool.ExecCmd(cmd, true); |
| | | |
| | | return args.id; |
| | | } |