重构GeometryCacheManager以使用ModelItemAnalysisHelper获取ModelItem完整路径,移除冗余代码
This commit is contained in:
parent
a3bee9a0ba
commit
97bf6dbecd
@ -5,6 +5,7 @@ using System.Linq;
|
||||
using Autodesk.Navisworks.Api;
|
||||
using ComApi = Autodesk.Navisworks.Api.Interop.ComApi;
|
||||
using ComApiBridge = Autodesk.Navisworks.Api.ComApi.ComApiBridge;
|
||||
using NavisworksTransport.Utils;
|
||||
|
||||
namespace NavisworksTransport.Utils
|
||||
{
|
||||
@ -192,8 +193,8 @@ namespace NavisworksTransport.Utils
|
||||
|
||||
var result = new List<Triangle3D>();
|
||||
|
||||
// 获取ModelItem的所有路径
|
||||
var itemPaths = GetModelItemPaths(modelItem);
|
||||
// 获取ModelItem的完整路径
|
||||
var itemPaths = ModelItemAnalysisHelper.GetModelItemIndexPaths(modelItem);
|
||||
|
||||
// 收集所有路径下的片段
|
||||
foreach (var pathKey in itemPaths)
|
||||
@ -263,31 +264,6 @@ namespace NavisworksTransport.Utils
|
||||
return count;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取ModelItem的所有路径
|
||||
/// </summary>
|
||||
/// <param name="modelItem">模型项</param>
|
||||
/// <returns>路径列表</returns>
|
||||
private List<string> GetModelItemPaths(ModelItem modelItem)
|
||||
{
|
||||
var paths = new List<string>();
|
||||
|
||||
// 转换为COM选择
|
||||
var modelCollection = new ModelItemCollection();
|
||||
modelCollection.Add(modelItem);
|
||||
var comSelection = ComApiBridge.ToInwOpSelection(modelCollection);
|
||||
|
||||
// 遍历所有路径
|
||||
foreach (ComApi.InwOaPath3 path in comSelection.Paths())
|
||||
{
|
||||
var pathArray = ((Array)path.ArrayData).ToArray<int>();
|
||||
var pathKey = string.Join(",", pathArray);
|
||||
paths.Add(pathKey);
|
||||
}
|
||||
|
||||
return paths;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取指定路径下的所有片段
|
||||
/// </summary>
|
||||
|
||||
@ -2,6 +2,8 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Autodesk.Navisworks.Api;
|
||||
using ComApi = Autodesk.Navisworks.Api.Interop.ComApi;
|
||||
using ComApiBridge = Autodesk.Navisworks.Api.ComApi.ComApiBridge;
|
||||
|
||||
namespace NavisworksTransport.Utils
|
||||
{
|
||||
@ -14,6 +16,33 @@ namespace NavisworksTransport.Utils
|
||||
|
||||
#region 辅助方法
|
||||
|
||||
/// <summary>
|
||||
/// 获取ModelItem的完整路径
|
||||
/// </summary>
|
||||
/// <param name="modelItem">模型项</param>
|
||||
/// <returns>路径列表</returns>
|
||||
public static List<string> GetModelItemIndexPaths(ModelItem modelItem)
|
||||
{
|
||||
var paths = new List<string>();
|
||||
|
||||
// 转换为COM选择
|
||||
var modelCollection = new ModelItemCollection
|
||||
{
|
||||
modelItem
|
||||
};
|
||||
var comSelection = ComApiBridge.ToInwOpSelection(modelCollection);
|
||||
|
||||
// 遍历完整路径
|
||||
foreach (ComApi.InwOaPath3 path in comSelection.Paths())
|
||||
{
|
||||
var pathArray = ((Array)path.ArrayData).ToArray<int>();
|
||||
var pathKey = string.Join(",", pathArray);
|
||||
paths.Add(pathKey);
|
||||
}
|
||||
|
||||
return paths;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检查一个ModelItem是否是另一个ModelItem的子节点
|
||||
/// </summary>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user