master #2
@ -19,3 +19,5 @@
|
|||||||
## 打卡
|
## 打卡
|
||||||
|
|
||||||
1. 尹莫波-demo文件夹
|
1. 尹莫波-demo文件夹
|
||||||
|
2. 林家烁-ljs文件夹
|
||||||
|
|
||||||
|
@ -0,0 +1,109 @@
|
|||||||
|
using Autodesk.Navisworks.Api.Interop.ComApi;
|
||||||
|
using LjsGo.Navisworks.GraphicsAssignment.ExportGeometryToJson.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace LjsGo.Navisworks.GraphicsAssignment.ExportGeometryToJson
|
||||||
|
{
|
||||||
|
public class CallbackGeomListener : InwSimplePrimitivesCB
|
||||||
|
{
|
||||||
|
//static FileStream aFile = new FileStream(@"C:\Users\Don\Desktop\项目1.txt", FileMode.OpenOrCreate);
|
||||||
|
//static StreamWriter sw = new StreamWriter(aFile);
|
||||||
|
public InwLTransform3f3 LCS2WCS;
|
||||||
|
|
||||||
|
//public ModelData ModelData { get; set; }
|
||||||
|
|
||||||
|
//public List<InwSimpleVertex> vertices { get; set; }
|
||||||
|
//public List<LineTest> lines { get; set; }
|
||||||
|
|
||||||
|
public List<double> vertexes { get; set; }
|
||||||
|
|
||||||
|
public List<double> normals { get; set; }
|
||||||
|
|
||||||
|
public List<string> vertexes_str { get; set; }
|
||||||
|
|
||||||
|
public List<string> normals_str { get; set; }
|
||||||
|
|
||||||
|
public CallbackGeomListener()
|
||||||
|
{
|
||||||
|
vertexes = new List<double>();
|
||||||
|
normals = new List<double>();
|
||||||
|
vertexes_str = new List<string>();
|
||||||
|
normals_str = new List<string>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Line(InwSimpleVertex v1, InwSimpleVertex v2)
|
||||||
|
{
|
||||||
|
// do your work
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Point(InwSimpleVertex v1)
|
||||||
|
{
|
||||||
|
// do your work
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SnapPoint(InwSimpleVertex v1)
|
||||||
|
{
|
||||||
|
// do your work
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Triangle(InwSimpleVertex v1, InwSimpleVertex v2, InwSimpleVertex v3)
|
||||||
|
{
|
||||||
|
//var v1Str = TranslationUtils.TranslationCoordLCS2WCS(v1, LCS2WCS);
|
||||||
|
//vertexes.AddRange(v1Str);
|
||||||
|
//var v2Str = TranslationUtils.TranslationCoordLCS2WCS(v2, LCS2WCS);
|
||||||
|
//vertexes.AddRange(v2Str);
|
||||||
|
//var v3Str = TranslationUtils.TranslationCoordLCS2WCS(v3, LCS2WCS);
|
||||||
|
//vertexes.AddRange(v3Str);
|
||||||
|
|
||||||
|
//var n1Str = TranslationUtils.TranslationNormalLCS2WCS(v1, LCS2WCS);
|
||||||
|
//normals.AddRange(n1Str);
|
||||||
|
//var n2Str = TranslationUtils.TranslationNormalLCS2WCS(v2, LCS2WCS);
|
||||||
|
//normals.AddRange(n2Str);
|
||||||
|
//var n3Str = TranslationUtils.TranslationNormalLCS2WCS(v3, LCS2WCS);
|
||||||
|
//normals.AddRange(n3Str);
|
||||||
|
|
||||||
|
//vertexes_str.Add(TranslationUtils.TranslationCoordLCS2WCSStr(v1, LCS2WCS));
|
||||||
|
//vertexes_str.Add(TranslationUtils.TranslationCoordLCS2WCSStr(v2, LCS2WCS));
|
||||||
|
//vertexes_str.Add(TranslationUtils.TranslationCoordLCS2WCSStr(v3, LCS2WCS));
|
||||||
|
|
||||||
|
//normals_str.Add(TranslationUtils.TranslationNormalLCS2WCSStr(v1, LCS2WCS));
|
||||||
|
//normals_str.Add(TranslationUtils.TranslationNormalLCS2WCSStr(v2, LCS2WCS));
|
||||||
|
//normals_str.Add(TranslationUtils.TranslationNormalLCS2WCSStr(v3, LCS2WCS));
|
||||||
|
|
||||||
|
var v1Str = TranslationUtils.TranslationCoordLCS2WCS(v1);
|
||||||
|
vertexes.AddRange(v1Str);
|
||||||
|
var v2Str = TranslationUtils.TranslationCoordLCS2WCS(v2);
|
||||||
|
vertexes.AddRange(v2Str);
|
||||||
|
var v3Str = TranslationUtils.TranslationCoordLCS2WCS(v3);
|
||||||
|
vertexes.AddRange(v3Str);
|
||||||
|
|
||||||
|
var n1Str = TranslationUtils.TranslationNormalLCS2WCS(v1);
|
||||||
|
normals.AddRange(n1Str);
|
||||||
|
var n2Str = TranslationUtils.TranslationNormalLCS2WCS(v2);
|
||||||
|
normals.AddRange(n2Str);
|
||||||
|
var n3Str = TranslationUtils.TranslationNormalLCS2WCS(v3);
|
||||||
|
normals.AddRange(n3Str);
|
||||||
|
|
||||||
|
vertexes_str.Add(TranslationUtils.TranslationCoordLCS2WCSStr(v1));
|
||||||
|
vertexes_str.Add(TranslationUtils.TranslationCoordLCS2WCSStr(v2));
|
||||||
|
vertexes_str.Add(TranslationUtils.TranslationCoordLCS2WCSStr(v3));
|
||||||
|
|
||||||
|
normals_str.Add(TranslationUtils.TranslationNormalLCS2WCSStr(v1));
|
||||||
|
normals_str.Add(TranslationUtils.TranslationNormalLCS2WCSStr(v2));
|
||||||
|
normals_str.Add(TranslationUtils.TranslationNormalLCS2WCSStr(v3));
|
||||||
|
}
|
||||||
|
|
||||||
|
~CallbackGeomListener()
|
||||||
|
{
|
||||||
|
//sw.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,134 @@
|
|||||||
|
using Autodesk.Navisworks.Api;
|
||||||
|
using Autodesk.Navisworks.Api.Plugins;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using System.Windows;
|
||||||
|
using Application = Autodesk.Navisworks.Api.Application;
|
||||||
|
|
||||||
|
using ComApi = Autodesk.Navisworks.Api.Interop.ComApi;
|
||||||
|
using LjsGo.Navisworks.GraphicsAssignment.ExportGeometryToJson.Models;
|
||||||
|
using System.IO;
|
||||||
|
using System.Reflection;
|
||||||
|
using Autodesk.Navisworks.Api.ComApi;
|
||||||
|
using LjsGo.Navisworks.GraphicsAssignment.ExportGeometryToJson;
|
||||||
|
using Autodesk.Navisworks.Api.Interop.ComApi;
|
||||||
|
|
||||||
|
namespace LjsGo.Navisworks.GraphicsAssignment
|
||||||
|
{
|
||||||
|
//基本插件
|
||||||
|
[Plugin("Basic", "ADSK", ToolTip = "Popups", DisplayName = "TestTest")]//名字,开发者号(四位字串),提示,用户界面显示名
|
||||||
|
[AddInPlugin(AddInLocation.AddIn)]//设定插件的位置
|
||||||
|
public class ExportGeometryToJsonCmd : AddInPlugin
|
||||||
|
{
|
||||||
|
private static string AssemblyPath = Path.GetDirectoryName(typeof(ExportGeometryToJsonCmd).Assembly.Location);
|
||||||
|
public override int Execute(params string[] parameters)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
//当前文档
|
||||||
|
Document doc = Application.ActiveDocument;//application是运行了之后自动提供的
|
||||||
|
|
||||||
|
// get the current selection
|
||||||
|
ModelItemCollection oModelColl = Application.ActiveDocument.CurrentSelection.SelectedItems;
|
||||||
|
|
||||||
|
//convert to COM selection
|
||||||
|
InwOpState oState = ComApiBridge.State;
|
||||||
|
InwOpSelection oSel = ComApiBridge.ToInwOpSelection(oModelColl);
|
||||||
|
|
||||||
|
// create the callback object
|
||||||
|
|
||||||
|
|
||||||
|
var instances = new List<Instance>();
|
||||||
|
var meshs = new List<Mesh>();
|
||||||
|
var materials = new List<Material> { new Material { color = "#808080", transparent = 1.0 }};
|
||||||
|
ModelData modelData = new ModelData
|
||||||
|
{
|
||||||
|
instances = instances,
|
||||||
|
meshes = meshs,
|
||||||
|
materials = materials,
|
||||||
|
};
|
||||||
|
|
||||||
|
var instanceIndex = 0;
|
||||||
|
foreach (InwOaPath3 path in oSel.Paths())
|
||||||
|
{
|
||||||
|
Instance instance = new Instance
|
||||||
|
{
|
||||||
|
id = Guid.NewGuid().ToString(),
|
||||||
|
info = new { Name = "test" },
|
||||||
|
mesh = instanceIndex,
|
||||||
|
visible = 1,
|
||||||
|
};
|
||||||
|
instances.Add(instance);
|
||||||
|
|
||||||
|
CallbackGeomListener callbkListener = new CallbackGeomListener();
|
||||||
|
var vertices_str = new List<string>();
|
||||||
|
var normals_str = new List<string>();
|
||||||
|
var vertices = new List<double>();
|
||||||
|
var normals = new List<double>();
|
||||||
|
var indices = new List<int>();
|
||||||
|
foreach (InwOaFragment3 frag in path.Fragments())
|
||||||
|
{
|
||||||
|
InwLTransform3f3 localToWorld = (InwLTransform3f3)(object)frag.GetLocalToWorldMatrix();
|
||||||
|
callbkListener.LCS2WCS = localToWorld;
|
||||||
|
var transfrom = new List<double>();
|
||||||
|
foreach (double item in (Array)localToWorld.Matrix)
|
||||||
|
{
|
||||||
|
transfrom.Add(item);
|
||||||
|
}
|
||||||
|
instance.transform = transfrom.ToArray();
|
||||||
|
// generate the primitives
|
||||||
|
frag.GenerateSimplePrimitives(nwEVertexProperty.eNORMAL, callbkListener);
|
||||||
|
vertices_str.AddRange(callbkListener.vertexes_str);
|
||||||
|
normals_str.AddRange(callbkListener.normals_str);
|
||||||
|
vertices.AddRange(callbkListener.vertexes);
|
||||||
|
normals.AddRange(callbkListener.normals);
|
||||||
|
|
||||||
|
for (int q = 0; q < callbkListener.vertexes_str.Count && q < callbkListener.normals_str.Count; q++)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < vertices_str.Count && i < normals_str.Count; i++)
|
||||||
|
{
|
||||||
|
if (vertices_str[i] == callbkListener.vertexes_str[q] && normals_str[i] == callbkListener.normals_str[q])
|
||||||
|
{
|
||||||
|
indices.Add(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Mesh mesh = new Mesh()
|
||||||
|
{
|
||||||
|
vertices = vertices,
|
||||||
|
normals = normals,
|
||||||
|
indices = indices,
|
||||||
|
material = 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
meshs.Add(mesh);
|
||||||
|
instanceIndex++;
|
||||||
|
}
|
||||||
|
|
||||||
|
var json = Kooboo.Json.JsonSerializer.ToJson(modelData);
|
||||||
|
|
||||||
|
var fileInfo = new FileInfo(doc.FileName);
|
||||||
|
var dir = fileInfo.Directory.FullName;
|
||||||
|
|
||||||
|
var savePath = Path.Combine(dir, "test.json");
|
||||||
|
File.WriteAllText(savePath, json);
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.ToString());
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace LjsGo.Navisworks.GraphicsAssignment.ExportGeometryToJson.Models
|
||||||
|
{
|
||||||
|
public class Instance
|
||||||
|
{
|
||||||
|
public string id { get; set; }
|
||||||
|
public double[] transform { get; set; }
|
||||||
|
public double visible { get; set; }
|
||||||
|
public int mesh { get; set; }
|
||||||
|
public object info { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace LjsGo.Navisworks.GraphicsAssignment.ExportGeometryToJson.Models
|
||||||
|
{
|
||||||
|
public class InstanceInfo
|
||||||
|
{
|
||||||
|
public InstanceInfo()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using ComBridge = Autodesk.Navisworks.Api.ComApi.ComApiBridge;
|
||||||
|
using COMApi = Autodesk.Navisworks.Api.Interop.ComApi;
|
||||||
|
|
||||||
|
namespace LjsGo.Navisworks.GraphicsAssignment.ExportGeometryToJson.Models
|
||||||
|
{
|
||||||
|
public class LineTest
|
||||||
|
{
|
||||||
|
public string Start { get; set; }
|
||||||
|
public string End { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace LjsGo.Navisworks.GraphicsAssignment.ExportGeometryToJson.Models
|
||||||
|
{
|
||||||
|
public class Material
|
||||||
|
{
|
||||||
|
public string color { get; set; }
|
||||||
|
public double transparent { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace LjsGo.Navisworks.GraphicsAssignment.ExportGeometryToJson.Models
|
||||||
|
{
|
||||||
|
public class Mesh
|
||||||
|
{
|
||||||
|
public List<double> vertices { get; set; }
|
||||||
|
public List<int> indices { get; set; }
|
||||||
|
public List<double> normals { get; set; }
|
||||||
|
public int material { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace LjsGo.Navisworks.GraphicsAssignment.ExportGeometryToJson.Models
|
||||||
|
{
|
||||||
|
public class ModelData
|
||||||
|
{
|
||||||
|
public List<Instance> instances { get; set; }
|
||||||
|
public List<Mesh> meshes { get; set; }
|
||||||
|
public List<Material> materials { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,130 @@
|
|||||||
|
using Autodesk.Navisworks.Api.Interop.ComApi;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace LjsGo.Navisworks.GraphicsAssignment.ExportGeometryToJson
|
||||||
|
{
|
||||||
|
public class TranslationUtils
|
||||||
|
{
|
||||||
|
public TranslationUtils()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
public static List<double> TranslationNormalLCS2WCS(InwSimpleVertex v1, InwLTransform3f3 LCS2WCS)
|
||||||
|
{
|
||||||
|
Array array_v1 = (Array)(object)v1.normal;
|
||||||
|
|
||||||
|
//var v1Str = "[" + Convert.ToDouble(array_v1.GetValue(1)) + "," +
|
||||||
|
// Convert.ToDouble(array_v1.GetValue(2)) + "," +
|
||||||
|
// Convert.ToDouble(array_v1.GetValue(3)) + "]";
|
||||||
|
|
||||||
|
var result = new List<double>
|
||||||
|
{
|
||||||
|
Convert.ToDouble(array_v1.GetValue(1)),
|
||||||
|
Convert.ToDouble(array_v1.GetValue(2)),
|
||||||
|
Convert.ToDouble(array_v1.GetValue(3)),
|
||||||
|
};
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<double> TranslationCoordLCS2WCS(InwSimpleVertex v1, InwLTransform3f3 LCS2WCS)
|
||||||
|
{
|
||||||
|
Array array_v1 = (Array)(object)v1.coord;
|
||||||
|
double xTrans = LCS2WCS.GetTranslation().data1;
|
||||||
|
double yTrans = LCS2WCS.GetTranslation().data2;
|
||||||
|
double zTrans = LCS2WCS.GetTranslation().data3;
|
||||||
|
|
||||||
|
//var v1Str = "[" + (Convert.ToDouble(array_v1.GetValue(1)) + xTrans).ToString() + "," +
|
||||||
|
// (Convert.ToDouble(array_v1.GetValue(2)) + yTrans).ToString() + "," +
|
||||||
|
// (Convert.ToDouble(array_v1.GetValue(3)) + zTrans).ToString() + "]";
|
||||||
|
|
||||||
|
var result = new List<double>
|
||||||
|
{
|
||||||
|
Convert.ToDouble(array_v1.GetValue(1)) + xTrans,
|
||||||
|
Convert.ToDouble(array_v1.GetValue(2)) + yTrans,
|
||||||
|
Convert.ToDouble(array_v1.GetValue(3)) + zTrans
|
||||||
|
};
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string TranslationNormalLCS2WCSStr(InwSimpleVertex v1, InwLTransform3f3 LCS2WCS)
|
||||||
|
{
|
||||||
|
Array array_v1 = (Array)(object)v1.normal;
|
||||||
|
|
||||||
|
var v1Str = "[" + Convert.ToDouble(array_v1.GetValue(1)) + "," +
|
||||||
|
Convert.ToDouble(array_v1.GetValue(2)) + "," +
|
||||||
|
Convert.ToDouble(array_v1.GetValue(3)) + "]";
|
||||||
|
|
||||||
|
return v1Str;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string TranslationCoordLCS2WCSStr(InwSimpleVertex v1, InwLTransform3f3 LCS2WCS)
|
||||||
|
{
|
||||||
|
Array array_v1 = (Array)(object)v1.coord;
|
||||||
|
double xTrans = LCS2WCS.GetTranslation().data1;
|
||||||
|
double yTrans = LCS2WCS.GetTranslation().data2;
|
||||||
|
double zTrans = LCS2WCS.GetTranslation().data3;
|
||||||
|
|
||||||
|
var v1Str = "[" + (Convert.ToDouble(array_v1.GetValue(1)) + xTrans).ToString() + "," +
|
||||||
|
(Convert.ToDouble(array_v1.GetValue(2)) + yTrans).ToString() + "," +
|
||||||
|
(Convert.ToDouble(array_v1.GetValue(3)) + zTrans).ToString() + "]";
|
||||||
|
|
||||||
|
return v1Str;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<double> TranslationNormalLCS2WCS(InwSimpleVertex v1)
|
||||||
|
{
|
||||||
|
Array array_v1 = (Array)(object)v1.normal;
|
||||||
|
|
||||||
|
var result = new List<double>
|
||||||
|
{
|
||||||
|
Convert.ToDouble(array_v1.GetValue(1)),
|
||||||
|
Convert.ToDouble(array_v1.GetValue(2)),
|
||||||
|
Convert.ToDouble(array_v1.GetValue(3)),
|
||||||
|
};
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<double> TranslationCoordLCS2WCS(InwSimpleVertex v1)
|
||||||
|
{
|
||||||
|
Array array_v1 = (Array)(object)v1.coord;
|
||||||
|
|
||||||
|
var result = new List<double>
|
||||||
|
{
|
||||||
|
Convert.ToDouble(array_v1.GetValue(1)),
|
||||||
|
Convert.ToDouble(array_v1.GetValue(2)),
|
||||||
|
Convert.ToDouble(array_v1.GetValue(3))
|
||||||
|
};
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string TranslationNormalLCS2WCSStr(InwSimpleVertex v1)
|
||||||
|
{
|
||||||
|
Array array_v1 = (Array)(object)v1.normal;
|
||||||
|
|
||||||
|
var v1Str = "[" + Convert.ToDouble(array_v1.GetValue(1)) + "," +
|
||||||
|
Convert.ToDouble(array_v1.GetValue(2)) + "," +
|
||||||
|
Convert.ToDouble(array_v1.GetValue(3)) + "]";
|
||||||
|
|
||||||
|
return v1Str;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string TranslationCoordLCS2WCSStr(InwSimpleVertex v1)
|
||||||
|
{
|
||||||
|
Array array_v1 = (Array)(object)v1.coord;
|
||||||
|
|
||||||
|
var v1Str = "[" + Convert.ToDouble(array_v1.GetValue(1)) + "," +
|
||||||
|
Convert.ToDouble(array_v1.GetValue(2)) + "," +
|
||||||
|
Convert.ToDouble(array_v1.GetValue(3)) + "]";
|
||||||
|
|
||||||
|
return v1Str;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
35
20210129/ljs/LjsGo.Navisworks/LjsGo.Navisworks.csproj
Normal file
35
20210129/ljs/LjsGo.Navisworks/LjsGo.Navisworks.csproj
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net472</TargetFramework>
|
||||||
|
<UseWpf>True</UseWpf>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Kooboo.Json" Version="1.0.8" />
|
||||||
|
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="Autodesk.Navisworks.Api">
|
||||||
|
<HintPath>..\..\..\..\..\..\Program Files\Autodesk\Navisworks Manage 2019\Autodesk.Navisworks.Api.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Autodesk.Navisworks.ComApi">
|
||||||
|
<HintPath>..\..\..\..\..\..\Program Files\Autodesk\Navisworks Manage 2019\Autodesk.Navisworks.ComApi.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Autodesk.Navisworks.Controls">
|
||||||
|
<HintPath>..\..\..\..\..\..\Program Files\Autodesk\Navisworks Manage 2019\Autodesk.Navisworks.Controls.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Autodesk.Navisworks.Interop.ComApi">
|
||||||
|
<HintPath>..\..\..\..\..\..\Program Files\Autodesk\Navisworks Manage 2019\Autodesk.Navisworks.Interop.ComApi.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="PresentationCore" />
|
||||||
|
<Reference Include="PresentationFramework" />
|
||||||
|
<Reference Include="System.Windows" />
|
||||||
|
<Reference Include="System.Xaml" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
</Project>
|
25
20210129/ljs/LjsGo.Navisworks/LjsGo.Navisworks.sln
Normal file
25
20210129/ljs/LjsGo.Navisworks/LjsGo.Navisworks.sln
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 16
|
||||||
|
VisualStudioVersion = 16.0.30907.101
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LjsGo.Navisworks", "LjsGo.Navisworks\LjsGo.Navisworks.csproj", "{F8254CA1-F4FF-44B7-833B-C074B175CAC0}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{F8254CA1-F4FF-44B7-833B-C074B175CAC0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{F8254CA1-F4FF-44B7-833B-C074B175CAC0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{F8254CA1-F4FF-44B7-833B-C074B175CAC0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{F8254CA1-F4FF-44B7-833B-C074B175CAC0}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {7C1D6A6E-3C17-443C-8803-96BD4228E8EE}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
@ -0,0 +1,109 @@
|
|||||||
|
using Autodesk.Navisworks.Api.Interop.ComApi;
|
||||||
|
using LjsGo.Navisworks.GraphicsAssignment.ExportGeometryToJson.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace LjsGo.Navisworks.GraphicsAssignment.ExportGeometryToJson
|
||||||
|
{
|
||||||
|
public class CallbackGeomListener : InwSimplePrimitivesCB
|
||||||
|
{
|
||||||
|
//static FileStream aFile = new FileStream(@"C:\Users\Don\Desktop\项目1.txt", FileMode.OpenOrCreate);
|
||||||
|
//static StreamWriter sw = new StreamWriter(aFile);
|
||||||
|
public InwLTransform3f3 LCS2WCS;
|
||||||
|
|
||||||
|
//public ModelData ModelData { get; set; }
|
||||||
|
|
||||||
|
//public List<InwSimpleVertex> vertices { get; set; }
|
||||||
|
//public List<LineTest> lines { get; set; }
|
||||||
|
|
||||||
|
public List<double> vertexes { get; set; }
|
||||||
|
|
||||||
|
public List<double> normals { get; set; }
|
||||||
|
|
||||||
|
public List<string> vertexes_str { get; set; }
|
||||||
|
|
||||||
|
public List<string> normals_str { get; set; }
|
||||||
|
|
||||||
|
public CallbackGeomListener()
|
||||||
|
{
|
||||||
|
vertexes = new List<double>();
|
||||||
|
normals = new List<double>();
|
||||||
|
vertexes_str = new List<string>();
|
||||||
|
normals_str = new List<string>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Line(InwSimpleVertex v1, InwSimpleVertex v2)
|
||||||
|
{
|
||||||
|
// do your work
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Point(InwSimpleVertex v1)
|
||||||
|
{
|
||||||
|
// do your work
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SnapPoint(InwSimpleVertex v1)
|
||||||
|
{
|
||||||
|
// do your work
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Triangle(InwSimpleVertex v1, InwSimpleVertex v2, InwSimpleVertex v3)
|
||||||
|
{
|
||||||
|
//var v1Str = TranslationUtils.TranslationCoordLCS2WCS(v1, LCS2WCS);
|
||||||
|
//vertexes.AddRange(v1Str);
|
||||||
|
//var v2Str = TranslationUtils.TranslationCoordLCS2WCS(v2, LCS2WCS);
|
||||||
|
//vertexes.AddRange(v2Str);
|
||||||
|
//var v3Str = TranslationUtils.TranslationCoordLCS2WCS(v3, LCS2WCS);
|
||||||
|
//vertexes.AddRange(v3Str);
|
||||||
|
|
||||||
|
//var n1Str = TranslationUtils.TranslationNormalLCS2WCS(v1, LCS2WCS);
|
||||||
|
//normals.AddRange(n1Str);
|
||||||
|
//var n2Str = TranslationUtils.TranslationNormalLCS2WCS(v2, LCS2WCS);
|
||||||
|
//normals.AddRange(n2Str);
|
||||||
|
//var n3Str = TranslationUtils.TranslationNormalLCS2WCS(v3, LCS2WCS);
|
||||||
|
//normals.AddRange(n3Str);
|
||||||
|
|
||||||
|
//vertexes_str.Add(TranslationUtils.TranslationCoordLCS2WCSStr(v1, LCS2WCS));
|
||||||
|
//vertexes_str.Add(TranslationUtils.TranslationCoordLCS2WCSStr(v2, LCS2WCS));
|
||||||
|
//vertexes_str.Add(TranslationUtils.TranslationCoordLCS2WCSStr(v3, LCS2WCS));
|
||||||
|
|
||||||
|
//normals_str.Add(TranslationUtils.TranslationNormalLCS2WCSStr(v1, LCS2WCS));
|
||||||
|
//normals_str.Add(TranslationUtils.TranslationNormalLCS2WCSStr(v2, LCS2WCS));
|
||||||
|
//normals_str.Add(TranslationUtils.TranslationNormalLCS2WCSStr(v3, LCS2WCS));
|
||||||
|
|
||||||
|
var v1Str = TranslationUtils.TranslationCoordLCS2WCS(v1);
|
||||||
|
vertexes.AddRange(v1Str);
|
||||||
|
var v2Str = TranslationUtils.TranslationCoordLCS2WCS(v2);
|
||||||
|
vertexes.AddRange(v2Str);
|
||||||
|
var v3Str = TranslationUtils.TranslationCoordLCS2WCS(v3);
|
||||||
|
vertexes.AddRange(v3Str);
|
||||||
|
|
||||||
|
var n1Str = TranslationUtils.TranslationNormalLCS2WCS(v1);
|
||||||
|
normals.AddRange(n1Str);
|
||||||
|
var n2Str = TranslationUtils.TranslationNormalLCS2WCS(v2);
|
||||||
|
normals.AddRange(n2Str);
|
||||||
|
var n3Str = TranslationUtils.TranslationNormalLCS2WCS(v3);
|
||||||
|
normals.AddRange(n3Str);
|
||||||
|
|
||||||
|
vertexes_str.Add(TranslationUtils.TranslationCoordLCS2WCSStr(v1));
|
||||||
|
vertexes_str.Add(TranslationUtils.TranslationCoordLCS2WCSStr(v2));
|
||||||
|
vertexes_str.Add(TranslationUtils.TranslationCoordLCS2WCSStr(v3));
|
||||||
|
|
||||||
|
normals_str.Add(TranslationUtils.TranslationNormalLCS2WCSStr(v1));
|
||||||
|
normals_str.Add(TranslationUtils.TranslationNormalLCS2WCSStr(v2));
|
||||||
|
normals_str.Add(TranslationUtils.TranslationNormalLCS2WCSStr(v3));
|
||||||
|
}
|
||||||
|
|
||||||
|
~CallbackGeomListener()
|
||||||
|
{
|
||||||
|
//sw.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,134 @@
|
|||||||
|
using Autodesk.Navisworks.Api;
|
||||||
|
using Autodesk.Navisworks.Api.Plugins;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using System.Windows;
|
||||||
|
using Application = Autodesk.Navisworks.Api.Application;
|
||||||
|
|
||||||
|
using ComApi = Autodesk.Navisworks.Api.Interop.ComApi;
|
||||||
|
using LjsGo.Navisworks.GraphicsAssignment.ExportGeometryToJson.Models;
|
||||||
|
using System.IO;
|
||||||
|
using System.Reflection;
|
||||||
|
using Autodesk.Navisworks.Api.ComApi;
|
||||||
|
using LjsGo.Navisworks.GraphicsAssignment.ExportGeometryToJson;
|
||||||
|
using Autodesk.Navisworks.Api.Interop.ComApi;
|
||||||
|
|
||||||
|
namespace LjsGo.Navisworks.GraphicsAssignment
|
||||||
|
{
|
||||||
|
//基本插件
|
||||||
|
[Plugin("Basic", "ADSK", ToolTip = "Popups", DisplayName = "TestTest")]//名字,开发者号(四位字串),提示,用户界面显示名
|
||||||
|
[AddInPlugin(AddInLocation.AddIn)]//设定插件的位置
|
||||||
|
public class ExportGeometryToJsonCmd : AddInPlugin
|
||||||
|
{
|
||||||
|
private static string AssemblyPath = Path.GetDirectoryName(typeof(ExportGeometryToJsonCmd).Assembly.Location);
|
||||||
|
public override int Execute(params string[] parameters)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
//当前文档
|
||||||
|
Document doc = Application.ActiveDocument;//application是运行了之后自动提供的
|
||||||
|
|
||||||
|
// get the current selection
|
||||||
|
ModelItemCollection oModelColl = Application.ActiveDocument.CurrentSelection.SelectedItems;
|
||||||
|
|
||||||
|
//convert to COM selection
|
||||||
|
InwOpState oState = ComApiBridge.State;
|
||||||
|
InwOpSelection oSel = ComApiBridge.ToInwOpSelection(oModelColl);
|
||||||
|
|
||||||
|
// create the callback object
|
||||||
|
|
||||||
|
|
||||||
|
var instances = new List<Instance>();
|
||||||
|
var meshs = new List<Mesh>();
|
||||||
|
var materials = new List<Material> { new Material { color = "#808080", transparent = 1.0 }};
|
||||||
|
ModelData modelData = new ModelData
|
||||||
|
{
|
||||||
|
instances = instances,
|
||||||
|
meshes = meshs,
|
||||||
|
materials = materials,
|
||||||
|
};
|
||||||
|
|
||||||
|
var instanceIndex = 0;
|
||||||
|
foreach (InwOaPath3 path in oSel.Paths())
|
||||||
|
{
|
||||||
|
Instance instance = new Instance
|
||||||
|
{
|
||||||
|
id = Guid.NewGuid().ToString(),
|
||||||
|
info = new { Name = "test" },
|
||||||
|
mesh = instanceIndex,
|
||||||
|
visible = 1,
|
||||||
|
};
|
||||||
|
instances.Add(instance);
|
||||||
|
|
||||||
|
CallbackGeomListener callbkListener = new CallbackGeomListener();
|
||||||
|
var vertices_str = new List<string>();
|
||||||
|
var normals_str = new List<string>();
|
||||||
|
var vertices = new List<double>();
|
||||||
|
var normals = new List<double>();
|
||||||
|
var indices = new List<int>();
|
||||||
|
foreach (InwOaFragment3 frag in path.Fragments())
|
||||||
|
{
|
||||||
|
InwLTransform3f3 localToWorld = (InwLTransform3f3)(object)frag.GetLocalToWorldMatrix();
|
||||||
|
callbkListener.LCS2WCS = localToWorld;
|
||||||
|
var transfrom = new List<double>();
|
||||||
|
foreach (double item in (Array)localToWorld.Matrix)
|
||||||
|
{
|
||||||
|
transfrom.Add(item);
|
||||||
|
}
|
||||||
|
instance.transform = transfrom.ToArray();
|
||||||
|
// generate the primitives
|
||||||
|
frag.GenerateSimplePrimitives(nwEVertexProperty.eNORMAL, callbkListener);
|
||||||
|
vertices_str.AddRange(callbkListener.vertexes_str);
|
||||||
|
normals_str.AddRange(callbkListener.normals_str);
|
||||||
|
vertices.AddRange(callbkListener.vertexes);
|
||||||
|
normals.AddRange(callbkListener.normals);
|
||||||
|
|
||||||
|
for (int q = 0; q < callbkListener.vertexes_str.Count && q < callbkListener.normals_str.Count; q++)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < vertices_str.Count && i < normals_str.Count; i++)
|
||||||
|
{
|
||||||
|
if (vertices_str[i] == callbkListener.vertexes_str[q] && normals_str[i] == callbkListener.normals_str[q])
|
||||||
|
{
|
||||||
|
indices.Add(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Mesh mesh = new Mesh()
|
||||||
|
{
|
||||||
|
vertices = vertices,
|
||||||
|
normals = normals,
|
||||||
|
indices = indices,
|
||||||
|
material = 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
meshs.Add(mesh);
|
||||||
|
instanceIndex++;
|
||||||
|
}
|
||||||
|
|
||||||
|
var json = Kooboo.Json.JsonSerializer.ToJson(modelData);
|
||||||
|
|
||||||
|
var fileInfo = new FileInfo(doc.FileName);
|
||||||
|
var dir = fileInfo.Directory.FullName;
|
||||||
|
|
||||||
|
var savePath = Path.Combine(dir, "test.json");
|
||||||
|
File.WriteAllText(savePath, json);
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.ToString());
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace LjsGo.Navisworks.GraphicsAssignment.ExportGeometryToJson.Models
|
||||||
|
{
|
||||||
|
public class Instance
|
||||||
|
{
|
||||||
|
public string id { get; set; }
|
||||||
|
public double[] transform { get; set; }
|
||||||
|
public double visible { get; set; }
|
||||||
|
public int mesh { get; set; }
|
||||||
|
public object info { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace LjsGo.Navisworks.GraphicsAssignment.ExportGeometryToJson.Models
|
||||||
|
{
|
||||||
|
public class InstanceInfo
|
||||||
|
{
|
||||||
|
public InstanceInfo()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using ComBridge = Autodesk.Navisworks.Api.ComApi.ComApiBridge;
|
||||||
|
using COMApi = Autodesk.Navisworks.Api.Interop.ComApi;
|
||||||
|
|
||||||
|
namespace LjsGo.Navisworks.GraphicsAssignment.ExportGeometryToJson.Models
|
||||||
|
{
|
||||||
|
public class LineTest
|
||||||
|
{
|
||||||
|
public string Start { get; set; }
|
||||||
|
public string End { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace LjsGo.Navisworks.GraphicsAssignment.ExportGeometryToJson.Models
|
||||||
|
{
|
||||||
|
public class Material
|
||||||
|
{
|
||||||
|
public string color { get; set; }
|
||||||
|
public double transparent { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace LjsGo.Navisworks.GraphicsAssignment.ExportGeometryToJson.Models
|
||||||
|
{
|
||||||
|
public class Mesh
|
||||||
|
{
|
||||||
|
public List<double> vertices { get; set; }
|
||||||
|
public List<int> indices { get; set; }
|
||||||
|
public List<double> normals { get; set; }
|
||||||
|
public int material { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace LjsGo.Navisworks.GraphicsAssignment.ExportGeometryToJson.Models
|
||||||
|
{
|
||||||
|
public class ModelData
|
||||||
|
{
|
||||||
|
public List<Instance> instances { get; set; }
|
||||||
|
public List<Mesh> meshes { get; set; }
|
||||||
|
public List<Material> materials { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,130 @@
|
|||||||
|
using Autodesk.Navisworks.Api.Interop.ComApi;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace LjsGo.Navisworks.GraphicsAssignment.ExportGeometryToJson
|
||||||
|
{
|
||||||
|
public class TranslationUtils
|
||||||
|
{
|
||||||
|
public TranslationUtils()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
public static List<double> TranslationNormalLCS2WCS(InwSimpleVertex v1, InwLTransform3f3 LCS2WCS)
|
||||||
|
{
|
||||||
|
Array array_v1 = (Array)(object)v1.normal;
|
||||||
|
|
||||||
|
//var v1Str = "[" + Convert.ToDouble(array_v1.GetValue(1)) + "," +
|
||||||
|
// Convert.ToDouble(array_v1.GetValue(2)) + "," +
|
||||||
|
// Convert.ToDouble(array_v1.GetValue(3)) + "]";
|
||||||
|
|
||||||
|
var result = new List<double>
|
||||||
|
{
|
||||||
|
Convert.ToDouble(array_v1.GetValue(1)),
|
||||||
|
Convert.ToDouble(array_v1.GetValue(2)),
|
||||||
|
Convert.ToDouble(array_v1.GetValue(3)),
|
||||||
|
};
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<double> TranslationCoordLCS2WCS(InwSimpleVertex v1, InwLTransform3f3 LCS2WCS)
|
||||||
|
{
|
||||||
|
Array array_v1 = (Array)(object)v1.coord;
|
||||||
|
double xTrans = LCS2WCS.GetTranslation().data1;
|
||||||
|
double yTrans = LCS2WCS.GetTranslation().data2;
|
||||||
|
double zTrans = LCS2WCS.GetTranslation().data3;
|
||||||
|
|
||||||
|
//var v1Str = "[" + (Convert.ToDouble(array_v1.GetValue(1)) + xTrans).ToString() + "," +
|
||||||
|
// (Convert.ToDouble(array_v1.GetValue(2)) + yTrans).ToString() + "," +
|
||||||
|
// (Convert.ToDouble(array_v1.GetValue(3)) + zTrans).ToString() + "]";
|
||||||
|
|
||||||
|
var result = new List<double>
|
||||||
|
{
|
||||||
|
Convert.ToDouble(array_v1.GetValue(1)) + xTrans,
|
||||||
|
Convert.ToDouble(array_v1.GetValue(2)) + yTrans,
|
||||||
|
Convert.ToDouble(array_v1.GetValue(3)) + zTrans
|
||||||
|
};
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string TranslationNormalLCS2WCSStr(InwSimpleVertex v1, InwLTransform3f3 LCS2WCS)
|
||||||
|
{
|
||||||
|
Array array_v1 = (Array)(object)v1.normal;
|
||||||
|
|
||||||
|
var v1Str = "[" + Convert.ToDouble(array_v1.GetValue(1)) + "," +
|
||||||
|
Convert.ToDouble(array_v1.GetValue(2)) + "," +
|
||||||
|
Convert.ToDouble(array_v1.GetValue(3)) + "]";
|
||||||
|
|
||||||
|
return v1Str;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string TranslationCoordLCS2WCSStr(InwSimpleVertex v1, InwLTransform3f3 LCS2WCS)
|
||||||
|
{
|
||||||
|
Array array_v1 = (Array)(object)v1.coord;
|
||||||
|
double xTrans = LCS2WCS.GetTranslation().data1;
|
||||||
|
double yTrans = LCS2WCS.GetTranslation().data2;
|
||||||
|
double zTrans = LCS2WCS.GetTranslation().data3;
|
||||||
|
|
||||||
|
var v1Str = "[" + (Convert.ToDouble(array_v1.GetValue(1)) + xTrans).ToString() + "," +
|
||||||
|
(Convert.ToDouble(array_v1.GetValue(2)) + yTrans).ToString() + "," +
|
||||||
|
(Convert.ToDouble(array_v1.GetValue(3)) + zTrans).ToString() + "]";
|
||||||
|
|
||||||
|
return v1Str;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<double> TranslationNormalLCS2WCS(InwSimpleVertex v1)
|
||||||
|
{
|
||||||
|
Array array_v1 = (Array)(object)v1.normal;
|
||||||
|
|
||||||
|
var result = new List<double>
|
||||||
|
{
|
||||||
|
Convert.ToDouble(array_v1.GetValue(1)),
|
||||||
|
Convert.ToDouble(array_v1.GetValue(2)),
|
||||||
|
Convert.ToDouble(array_v1.GetValue(3)),
|
||||||
|
};
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<double> TranslationCoordLCS2WCS(InwSimpleVertex v1)
|
||||||
|
{
|
||||||
|
Array array_v1 = (Array)(object)v1.coord;
|
||||||
|
|
||||||
|
var result = new List<double>
|
||||||
|
{
|
||||||
|
Convert.ToDouble(array_v1.GetValue(1)),
|
||||||
|
Convert.ToDouble(array_v1.GetValue(2)),
|
||||||
|
Convert.ToDouble(array_v1.GetValue(3))
|
||||||
|
};
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string TranslationNormalLCS2WCSStr(InwSimpleVertex v1)
|
||||||
|
{
|
||||||
|
Array array_v1 = (Array)(object)v1.normal;
|
||||||
|
|
||||||
|
var v1Str = "[" + Convert.ToDouble(array_v1.GetValue(1)) + "," +
|
||||||
|
Convert.ToDouble(array_v1.GetValue(2)) + "," +
|
||||||
|
Convert.ToDouble(array_v1.GetValue(3)) + "]";
|
||||||
|
|
||||||
|
return v1Str;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string TranslationCoordLCS2WCSStr(InwSimpleVertex v1)
|
||||||
|
{
|
||||||
|
Array array_v1 = (Array)(object)v1.coord;
|
||||||
|
|
||||||
|
var v1Str = "[" + Convert.ToDouble(array_v1.GetValue(1)) + "," +
|
||||||
|
Convert.ToDouble(array_v1.GetValue(2)) + "," +
|
||||||
|
Convert.ToDouble(array_v1.GetValue(3)) + "]";
|
||||||
|
|
||||||
|
return v1Str;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net472</TargetFramework>
|
||||||
|
<UseWpf>True</UseWpf>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Kooboo.Json" Version="1.0.8" />
|
||||||
|
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="Autodesk.Navisworks.Api">
|
||||||
|
<HintPath>..\..\..\..\..\..\Program Files\Autodesk\Navisworks Manage 2019\Autodesk.Navisworks.Api.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Autodesk.Navisworks.ComApi">
|
||||||
|
<HintPath>..\..\..\..\..\..\Program Files\Autodesk\Navisworks Manage 2019\Autodesk.Navisworks.ComApi.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Autodesk.Navisworks.Controls">
|
||||||
|
<HintPath>..\..\..\..\..\..\Program Files\Autodesk\Navisworks Manage 2019\Autodesk.Navisworks.Controls.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Autodesk.Navisworks.Interop.ComApi">
|
||||||
|
<HintPath>..\..\..\..\..\..\Program Files\Autodesk\Navisworks Manage 2019\Autodesk.Navisworks.Interop.ComApi.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="PresentationCore" />
|
||||||
|
<Reference Include="PresentationFramework" />
|
||||||
|
<Reference Include="System.Windows" />
|
||||||
|
<Reference Include="System.Xaml" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
</Project>
|
1
20210129/ljs/test.json
Normal file
1
20210129/ljs/test.json
Normal file
File diff suppressed because one or more lines are too long
BIN
20210129/ljs/test.png
Normal file
BIN
20210129/ljs/test.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 87 KiB |
Loading…
Reference in New Issue
Block a user